Xmms2 Widgets
How to control xmms2d through widgets
| Languages: |
English • Русский |
This article describes how to make a music player widget for xmms2. It contains play/pause, next and previous track buttons and displays artist - title of the current song. Preview[1]
Requires:
Adjusting your .awesomerc
This is the part of my .awesomerc defining the widgets. I use a textbox for the status-display of xmms2d and iconboxes for the control buttons. As you can see I put the icons in ~/.config/awesome/icons/xmms2/, I suggest you to do it the same way, it is some standard and quite a good place for your awesome customizations. You can make your own icons of course, they have to be in .png format as far as I know. Remember that awesome will crash through clicking on a widget with a wrong image path.
textbox nowplaying {
text = "-" #the - will be replaced by `xmms2 current` piped to awesome-client
}
iconbox xmms2_prev {
image = "/home/wakeup/.config/awesome/icons/xmms2/prev.png"
#on left mouse button click xmms2 prev will be executed as if in a terminal
mouse {
button = "1"
command = "spawn"
arg = "xmms2 prev"
}
}
iconbox xmms2_toggleplay {
image = "/home/wakeup/.config/awesome/icons/xmms2/toggleplay.png"
mouse {
button = "1"
command = "spawn"
arg = "xmms2 toggleplay"
}
}
iconbox xmms2_next {
image = "/home/wakeup/.config/awesome/icons/xmms2/next.png"
mouse {
button = "1"
command = "spawn"
arg = "xmms2 next"
}
}
Script to update "artist - title"
My update-script is located at ~/.config/awesome/scripts/nowplaying and of really simple nature. It is started through the following line in ~/.xinitrc
/home/wakeup/.config/awesome/scripts/nowplaying &
The script
#!/bin/bash
while true
do
song=`xmms2 current`
echo "0 widget_tell nowplaying $song" | /usr/local/bin/awesome-client #tells the textbox-widget mentioned above to display the output of `xmms2 current`
sleep 3
done
Another option for the script is to use [5]. This script supports on-broadcast/signal messaging, so that you don't have to wait 3 seconds for a song update. It also handles changing the icon of the play/pause button depending on the playback state. It also includes (commented out) support for working with cover art and playtime.