Freelancer's Playground! New knowledges every now and then

9Mar/102

Setting Up Global Shortcut For Rhythmbox

Global shortcut, I believe some of you didn't know what it is. It is equal to keyboard shortcut in applications. What make it different is, in normal shortcut, you have to have an active applications. In other word, that particular application need to be on focus. While global shortcut doesn't need to be on focus. It can be in minimized state or even hidden from current desktop. Because, global shortcut work by hooking up to system's message (CMIIW here).

For so many years I've depend on this specific feature when running media player (read: MP3 Player). From Winamp when I was in windows environment to Amarok and Audacious in my current desktop. The reason why I use global shortcut is I like to listen music using headphone in full volume output! But, being working with colleagues I need to pause my music from time to time. I don't like my music to continue without me listening to it. It's true that I can click on pause button before listening to my friend. However, moving from keyboard to mouse and navigating it to pause button is slow!

This is where global shortcut came in handy. I just have to push the shortcut button right away, without switching to mouse. You can look my other post on how to setting global shortcut in amarok (in Bahasa Indonesia). I haven't write how to set it in audacious yet. As for setting in in rhythmbox, you can follow this simple step. For this to work in rhythmbox, we need to call rhythmbox-client with some additional parameter. To look up the parameter simply type rhythmbox-client --help in terminal. For your conveinence, here's the output:

silent@silent-laptop:~$ rhythmbox-client --help
Usage:
  rhythmbox-client [OPTION...]

Help Options:
  -h, --help                 Show help options

Application Options:
  --debug
  --no-start                 Don't start a new instance of Rhythmbox
  --quit                     Quit Rhythmbox
  --no-present               Don't present an existing Rhythmbox window
  --hide                     Hide the Rhythmbox window
  --next                     Jump to next song
  --previous                 Jump to previous song
  --notify                   Show notification of the playing song
  --play                     Resume playback if currently paused
  --pause                    Pause playback if currently playing
  --play-pause               Toggle play/pause mode
  --play-uri=URI to play     Play a specified URI, importing it if necessary
  --enqueue                  Add specified tracks to the play queue
  --clear-queue              Empty the play queue before adding new tracks
  --print-playing            Print the title and artist of the playing song
  --print-playing-format     Print formatted details of the song
  --set-volume               Set the playback volume
  --volume-up                Increase the playback volume
  --volume-down              Decrease the playback volume
  --print-volume             Print the current playback volume
  --mute                     Mute playback
  --unmute                   Unmute playback
  --set-rating               Set the rating of the current song

Since rhythmbox doesn't have GUI interface to setting global shortcut, we will need the help from Gnome's keyboard shortcut tools. Head on to System » Preferences » Keyboard Shortcuts.

Free Image Hosting at www.ImageShack.us

Next step is, create new application shortcut by clicking on "Add" button.

Free Image Hosting at www.ImageShack.us

Fill in "Name" with shortcut name and "Command" with application command. Here's my setting:

Free Image Hosting at www.ImageShack.us
Name Command Shortcut
Rythmbox Play Pause rhythmbox-client --no-start --play-pause WIN+DOWN
Rythmbox Next rhythmbox-client --next --no-start WIN+RIGHT
Rythmbox Prev rhythmbox-client --previous --no-start WIN+LEFT
Rythmbox Volume UP rhythmbox-client --volume-up --no-start WIN+PAGE UP
Rythmbox Volume DOWN rhythmbox-client --volume-down --no-start WIN+PAGE DOWN

Please note that I use --no-start to prevent rhythmbox from starting itself. If you want to autostart it, just remove the parameter.

  • Masye

    Very cool and useful, thank you!

  • http://pulse.yahoo.com/_OXMCJUQT3KDVQNPJCE46HV4BRE Bubka Gob

    To fast seek forward or backward I install this plugin for rhytmbox
    https://launchpad.net/rb-seek-plugin ,
    then I use these commands for global shortcuts  

    rhythmbox-client –seek 5 (seek forward for 5 sec)
    rhythmbox-client –seek -5 (back for 5 sec)
    (for exmpl Ctrl+Alt+Left|Right_Arrows)