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:
Rb p
(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.