Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

multimediakeys

J.Rios edited this page May 4, 2019 · 1 revision

Multimedia Keys

Guayadeque supports multimedia keys out of the box. Refer to the documentation of your distribution/desktop Environment for instructions on how to set up your multimedia keys and keyboard shortcuts. Normally this can be easily done via GUI in Gnome or KDE.

Ubuntu: https://help.ubuntu.com/community/KeyTouch ArchLinux: https://wiki.archlinux.org/index.php/Extra_Keyboard_Keys Gentoo: http://en.gentoo-wiki.com/wiki/Multimedia_Keys (instructions for different desktop environments)

You can also define the actions for your multimedia keys independently via xbindkeys. Instructions on how to set up xbindkeys can be found here: https://help.ubuntu.com/community/KeyboardShortcuts#Text_Entry_Shortcuts https://wiki.archlinux.org/index.php/Xbindkeys http://en.gentoo-wiki.com/wiki/Multimedia_Keys#Non_window_manager_specific_-_xbindkeys
If you use this approach you need to specify the appropriate dbus-commands as follows...
Either rewinds to the beginning of the track (if playing) or starts playing:

dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Play
Pause or unpause:
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Pause
self-explaining:
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Stop
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Next
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Prev


It is also possible to change the guayadeque-volume with hotkeys (not the system volume). We need some custom scripts for that:
volumeplus.sh

#!/bin/bash
a=$(echo $(dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet) | awk '{print $8}')
b=$(($a+8))
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet int32:$b

volumeminus.sh

#!/bin/bash
a=$(echo $(dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet) | awk '{print $8}')
b=$(($a-8))
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet int32:$b

This will increase/lower volume by 8%. Now we can bind those scripts with xbindkeys to any hotkey.


Another feature someone could think of is an application-key which will start guayadeque or minimize/maximize it depending on the window-state; all with a single key. This can be achieved with a simple python-script: click here

Copy the code to a file like "guayadequetoggle.py", make it executable and bind it to a key via the configuration-tools of your desktop environment or xbindkeys. To use it for another application you just have to change line 15 and 29. Keep in mind that you need the appropriate python bindings. For me libwnck-python was missing. Because this script just reads the titles of any given window, names can be ambigous. Sometimes it helps to change line 15 to something like this:

if window.get_name().endswith('Mozilla Firefox'):


Here is an example of an ~/.xbindkeysrc file with guayadeque-hotkeys defined:

## Guayadeque hotkeys
# Pause/Play
"dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Pause"
	m:0x10 + c:172
# previous track	
"dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Prev"
	m:0x10 + c:173
# next track
"dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Next"
	m:0x10 + c:171
# increase guayadeque-volume
"exec /home/jule/.volumeplus.sh"
	m:0x10 + c:86
# decrease guayadeque-volume
"exec /home/jule/.volumeminus.sh"
	m:0x10 + c:82
# toggle/start guayadeque
"exec /home/jule/.guayadequetoggle.py"
        m:0x10 + c:81
Clone this wiki locally