Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to register a dummy panel so that multimedia keys work properly when using weirdo WMs
#!/usr/bin/env python3
# Michael J. Sullivan (
# Stupid little script to make gnome/unity media keys work when running
# weirdo window managers like xmonad and notion.
# Directions:
# With unity-settings-daemon running, run this script in the background.
# Tested on Ubuntu 15.04 using notion.
# unity-settings-daemon manages the keys (I think?), but only does it these
# days if there is a registered "Panel", which is, of course, done with
# a dbus call. So just do that, I guess.
# python dbus stuff cribbed from
# The dance necessary to make this work was figured out from
import sys, signal
import dbus
def main(args):
bus = dbus.SessionBus()
# Register ourselves as an org.gnome.Panel
proxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
iface = dbus.Interface(proxy, "org.freedesktop.DBus")
res = iface.RequestName("org.gnome.Panel", 1)
# 1 and 4 mean we succeeded
if res == 1 or res == 4:
# 2 and 3 means there is already a panel running
elif res == 2 or res == 3:
sys.stderr.write("fake-panel: there is already a panel")
return 1
# Anything else is ??
sys.stderr.write("fake-panel: unexpected reply: %s\n" % res)
return 1
except dbus.DBusException as e:
sys.stderr.write("fake-panel: got dbus error: %s\n" % e)
return 1
# Now just keep on idling forever so we hang onto the name.
while True:
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment