MPD Query

So I mentioned in another post that I use mpd and ncmpcpp to listen to music. The positive thing about this is that I can just close ncmpcpp when I don’t need it anymore and the music will continue playing, since mpd is responsible for the sound which is running completely in the background. Now sadly I have no indicator about what song is playing right now.

So I looked if anybody made a patch for dwm to display the current song, but everything I found didn’t really work for me. And I didn’t want a bash script to be running in the background. So I found a few people suggesting to make a simple C program to query the current song.

Now this is easier said than done, since I have no idea how to use mpd and C. The first thing I did was download the source code of mpd and copied the include directory into my project folder. So now I can write a program utilizing code from mpd. Now for the tricky part: Getting my program to connect to mpd and get the song name and some other information. I had some example code which showed how to connect and get the play time of the current song, so that helped a little bit, but getting the song name doesn’t work the same way.

For experienced people this task probably would be a thing of ten minutes but I not only had to deal with how mpd worked I also had to figure out how C works. And most time that was me writing like three lines of code, compiling it and finding out it compiled fine but crashed when running. So here’s what I have done so far:

Created a Makefile where the include directory (which containes the headers of mpd) is:


VERSION = 3.02
CC      = /usr/bin/gcc

mpdq: mpdq.c
    $(CC) -o mpdq -lmpdclient mpdq.c

So this way compiling is just the command ‘make’. Next up is writing the actual code which started by me finding out how the main method looks in C and then moving onto actually fiddling with mpd. To work with mpd I needed these two headers:

#include <mpd/client.h>
#include <mpd/stats.h>

When those are included and the compiler doesn’t complain about not finding them you should be able to access the necessary methods to connect and query information from mpd:

struct mpd_connection  *connection = mpd_connection_new(NULL, 0, 0);

This will open a connection to the local mpd and return the pointer to the connection if it succeeded. The three arguments are only needed if the connection is to another computer. After that we want to get the current song and from that we can read most Song tags:

// Get current song as a struct
struct song = mpd_run_current_song(connection);
// Read name and artist
char *song_name   = (char *) mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
char *artist_name = (char *) mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);

And that is technically everything important to read information from mpd. The only other things I did were putting this in a loop, adding a command to make it appear in the dwm bar, differentiating between paused/playing and  cleaning up when closing. That’s all I have done up until now. I’ll see if I can get some controls like pause/play into the dwm bar but for now this’ll suffice.


Here‘s the source code and here‘s a binary build. Just give it the run flag with chmod a+x and when running it should display the current song in the top left corner (Provided you use dwm and a song is playing in mpd :P).

Rocket League on Linux

So recently Rocket League got a linux version, which is currently in beta. But since I’m currently using Linux more than windows I thought I’d give it a try.

On Windows my controller just works when plugged in and is directly configured correctly. On linux, sadly it needs a little more work. Nothing surprising. So what I did was look around and found out that the default driver for controllers and joysticks, xpad, does not support Xbox controllers and any controllers that mimic them. Mine is some cheap Xbox 360 knockoff but it works just like an original one and I never had any issues on Windows.

So for linux, you’ll need a custom driver called xboxdrv. For the arch linux users, you can get it on the AUR here. I suggest you use an extention for pacman to support the AUR like yaourt, which makes installing software from the AUR a whole lot easier.

So when I got my hands on xboxdrv I started it as root (which is required) just to find out that Rocket League does not like it. Loading the driver works perfectly and programs like PPSSPP or other games work just fine. But in Rocket League I had several problems like constanly going in reverse without pressing any button, constantly looking up and other strange mismappings for the buttons. So after a lot of googling I stumbled upon someone else who happened to have issues with Rocket League and his controller as well. He posted his config for xboxdrv, which I promptly tried out and reduced to the important part. And with that config it worked perfectly without any issues and the exact same button mappings as on windows.

So here’s what I did:

Write this to a config file e.g. /home/username/xboxdrv.conf

 silent = true
 mimic-xpad = true

and then run xboxdrv with the config:

$ sudo xboxdrv --detach-kernel-driver --config /home/username/xboxdrv.conf

And that’s it you can set it up so the driver runs in the background as a daemon but I’m waay to lazy to do that since I only need it for Rocket League 😛


So my schedule for writng these things is rather random and so I thought I just I’d write about this pretty interesting tool: tox or rather utox. Tox is a chat protocoll which is focused on being fully encrypted and decentralized. Making it a very good alternative to other services which do not provide this level of security and privacy.

Tox is opensource and thus allows everyone to make their own chat client. The one I use is utox. It’s a lightweight program that runs on all major operating systems including mobiles.

uTox offers a bright and dark theme

Another goal of tox clients is to offer a zero configuration experience. No installation process and no setup time, just launch it and it works. When launching any client that uses the tox protocoll you’ll get a tox ID. This is what other people need to add you as a friend. The ID is a ~76 character long string consisting of letters and numbers, so it’s rather hard to remember but if you’re using uTox you can get yourself a tox ID which looks something like this: That way people have it easier adding you.

Now the cool thing about tox that it isn’t limited to text, it allows you to quickly share screenshots of your desktop or just any file you have laying around with no maximum file limit. You can also do voice calls or video calls, in which you can use your desktop as a video input to share your desktop. Those things can also be done with multiple people in a groupchat.

Left: uTox on Linux / Right: Antox on Android

So to sum it up it’s a pretty useful tool that doesn’t hurt to try out. It’s still in early development though so you’ll experience some bugs and missing features.

btw my tox id is

Arch linux and dwm

So this is not the first time that I use arch and dwm, but after getting a new video card and cpu I took a break from using it and went back to windows.

Now that I’ve used windows for a while I decided to take a look at arch again. Sadly, like last time I used it, I had a few annoying issues when installing it. But those were mostly faults on my side.

Arch linux is a really customizable linux distribution which allows you to modify it from the ground up to fit your needs. That also means that installing process takes place in the console. No fancy GUIs. But the basic installation is a pretty straight forward process if you follow the guide.

What you get when booting the installation medium

Sounds like a doable thing, right? Well when I did this the first time the only issues I had were with dualbooting. Which ended up toasting my bootmanager. But that can be fixed with a windows installation disk. So booting the installation medium this time just got me a black screen. Fantastic. Later I found out that that is because I have a “fairly” new nvidia card which need the extra kernel parameter nomodeset to even get to the console.

So after all that and making sure that grub played nice with my windows partition I ended up installing xserver and other things I needed. That was when arch asks you which package you want for libgl. Theres a vesa package (I think that’s the opensource one) and three nvidia packages. Great. Now on the wiki it tells you which you need for your video card but reading the wiki is for loosers so I used the next best package. After installing the nouveau driver, which is the opensource driver for nvidia cards everything looked good. Until I rebootet and got a blackscreen instead of dwm. Now that’s not the first time I had that happend, I once had that on ubuntu as well when I installed the video card driver.

So the first thing where I don’ goofed is in the .xinitrc file. That file is executed when you start the xserver (which is responsible for the fancy nancy graphical stuffs). In there you tell it what window manager to start. But before starting my window manager I ran another command which prevented my window manager from starting. Soo yeah, that explained the blackscreen. After fixing that I found my desktop to be in a very low resolution, but at least I saw a desktop.

I spend about an hour trying to fix this problem by intalling the nvidia drivers from the repositories and the offical website switching between blackscreens and a low res desktop and ended up reinstalling arch completely.

This time I directly installed the proprietary drivers and tadaa, everything worked out fine. I still need to configure a few things like auto mountin usb drives and mounting my windows partition. But all in all I’m happy to get a break from windows from time to time and use linux.

My current setup (Open programs are caja and surf)

For dwm I applied the following patches systray and pertag so I have a sytem tray aswell as seperate modes for all virtual desktops.

That’s it. I also installed mpd and ncmpcpp, just because it looks cool 😀