I use Rhythmbox to play music on my hi-fi system. There is a command line element for Rhythmbox called rhythmbox-client. This element can be used to initiate a series of commands in Rhythmbox. The problem is that these commands end up being a bit longish if you are attached to that machine via ssh. Here is an example:
DISPLAY=:0.0 rhythmbox-client –play-pause
That’s a lot of typing especially when you are attached via ssh from your Android phone. It was just too tedious to type all that out on that on-screen keyboard. So I wrote a script that would manage the arguments I felt were most important.
## #!/bin/bash # by JamesIsIn from JamesIsIn.com # Do something nice today. if [ "$1" = "n" ]; then argument="--next --print-playing" printf "\nI am skipping to the next track:\n\n" elif [ "$1" = "p" ]; then argument="--play-pause" printf "\nI am toggling between play and pause.\n\n" elif [ "$1" = "s" ]; then argument="--print-playing" printf "\nThis is what is currently playing:\n\n" # if [ "$1" = "q" ]; then # $argument="--enqueue" else [ argument = "" ]; printf "\nI'm sorry. I only understand the following commands:\n\n" printf "p (play/pause)\n\n" printf "s (show what's playing)\n\n" printf "n (skip to next track)\n\n" printf "Please try again.\n\n" exit # I could add --enqueue but I have to figure out to make it work fi # assuming DISPLAY does not matter for local runs (though this is for a single monitor configuration) DISPLAY=:0.0 rhythmbox-client $argument echo exit ##
The use of DISPLAY is required so that rhythmbox-client knows on which monitor Rhythmbox is present. The configuration above is for a single monitor arrangement. You’re on your own to figure out what you need in there if you have a different monitor configuration.
So, using my script, if you wanted to issue the same command I mentioned above you would merely type:
(Now I just need to streamline the ssh command and this whole procedure will be much easier and thereby more impressive.)
I placed this script in /usr/local/bin on the hi-fi machine. I called it merely Rb. That way the script is available to all users on that machine. Be sure to make the file executable:
sudo chmod a+x /usr/local/bin/Rb
(Since I use my server as a proper server now I moved my script to the share: /media/[share]/Rb so that it would be available across the network.)
Have fun with that.
10 thoughts on “Script for Skipping Tracks”
Ubuntu is moving to Banshee as its default media library application. I have a script for Banshee:
A New Script for Skipping Tracks.
Ubuntu has reverted their default player to Rhythmbox for 12.04 which comes out at the end of April.
Clementine is an up-and-coming media library player. You can read my full article here:
Oh, My Darling! Musica!
I’ll see about adjusting my script for use with Clementine.
Rhythmbox has a plugin suite (I went overboard on FB for non-techies, not that I qualify either really : )
Maybe you can adapt some of their EQ code. Clementine is the bomb : ) I always bitch about new GUIs, and still boot up Gnome half the time, but I really like the Unity volume widget. Gives you straight access to your apps. Only thing sorely missing from it is: EQ. There are ALSA EQs. Maybe you should write a plug in that integrates with ALSA and Pulseaudio there? Just saying… so one doesn’t have to apt-get separate plugins… Y’know?
A devout audiophile would tend to shun an EQ. (Use proper gear and let the music shine through.)
As to those RB plugins:
sudo add-apt-repository ppa:fossfreedom/rhythmbox-plugins
sudo apt-get update
sudo apt-get install rhythmbox-plugin-complete
I know you’re not Santa James… but wouldn’t it be cool to have a persistent bar graphic display with peak hold doing its thing across the bottom of your screen? Bottom 10% real estate. Click to tweak EQ and display… I’m still lacking the code chops, for now. Sort of Winampesque… but client independent…
Probably want to find a real coder. I just (struggle to) do scripting.
Out of curiosity, what does “longish” constitute? Noticeably, obviously, but it can’t be SSH’s fault. I mentioned on FB that Rhythymbox has a plug in suite, and that among them is EQ. Gotta be open-source. You could probably tweak that code for Banshee (or go ALSA). A nice blanket interface for that makes a bit more sense to me; but I don’t know how to code it.
There is an example after the first paragraph. My script ends up being just four characters (inclusive). Way shorter.