Amarok is my favourite music player. I like to listen to music when I go to sleep, but I don’t want the music to keep playing all night long. This is why I’ve added a sleep feature to radio.py. Unfortunately, Amarok doesn’t have built-in sleep functionality, but the Amarok developers left an open door for us to implement it with ease by means of interfaces that allow us to control Amarok from the command line.
The first solution uses Amarok itself. The Amarok developers have provided means of controlling Amarok via the command line. So we’ll combine this with the sleep command, and run the following in a console:
sleep 120m; amarok --stop
This will cause Amarok to stop after 120 minutes. The sleep command takes a number and a suffix that can be one of s, m, h, and d (for seconds, minutes, hours, and days). You can use it to easily set the duration before playback halts.
Another solution, a more general one, would be to use DCOP. Amarok provides a very extensive DCOP interface that allows us to control most of its features, including, of course, stopping playback. So we could also use
sleep 1h; dcop amarok player stop
To stop Amarok in one hour.
A little note about the last solution. This post is written for Amarok 1.4 and not 2.0, as I hadn’t switched yet to KDE 4. DCOP was replaced in KDE 4 by D-Bus, and the last solution would probably not work. However, you could probably adjust it easily to the new D-Bus interface.
thanks, I wanted this for the same reason