Skip to content

Instantly share code, notes, and snippets.

@oneman
Created April 9, 2010 22:37
Show Gist options
  • Select an option

  • Save oneman/361668 to your computer and use it in GitHub Desktop.

Select an option

Save oneman/361668 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# xmms2-gnome-mediakeys-listener.rb
#
# this xmms2 client connects to the gnome settings daemon
# which broadcast out a dbus signal when those prev, play/pause, next keys are hit on your keyboard
# this listens for those signals and tells xmms2 to do something via simple command line
#
# 2010 rawdod / oneman / drr
require 'dbus'
bus = DBus::SessionBus.instance
service = bus.service("org.gnome.SettingsDaemon")
daemon = service.object("/org/gnome/SettingsDaemon/MediaKeys")
#puts service.introspect
daemon.introspect
daemon.default_iface = "org.gnome.SettingsDaemon.MediaKeys"
#puts service.introspect
#puts daemon.introspect
daemon.on_signal("MediaPlayerKeyPressed") do |x,y|
#puts "Recived: #{x} #{y}"
case y
when "Next"
`xmms2 next`
when "Previous"
`xmms2 prev`
when "Play"
`xmms2 toggleplay`
end
end
#puts service.introspect
#puts daemon.introspect
puts "Its working."
loop = DBus::Main.new
loop << bus
loop.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment