Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 222 lines (196 sloc) 6.55 KB
#!/usr/bin/python2
import pygtk
import gtk
import subprocess
pygtk.require('2.0')
volume = 'amixer sset Master 1%'
suspend = 'dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend'
deadbeef = 'deadbeef --'
deadbeef_click_cmds = {
1: deadbeef + 'play-pause',
2: suspend,
8: deadbeef + 'prev',
9: deadbeef + 'next'
}
mpc = 'mpc -q '
click_cmds = {
1: mpc + 'toggle',
2: suspend,
8: mpc + 'prev',
9: mpc + 'next'
}
scroll_cmds = {
gtk.gdk.SCROLL_UP: volume + '+',
gtk.gdk.SCROLL_DOWN: volume + '-'
}
svg_data = r"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="570"
height="350"
id="svg2">
<path
d="m 79,167 60,0"
id="path3850"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="60"
height="160"
rx="18"
ry="18"
x="79"
y="87"
id="rect3840"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="356"
height="336"
rx="37"
ry="37"
x="99"
y="7"
id="rect2985"
style="fill:#000000;fill-opacity:1;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="100"
height="200"
rx="20"
ry="20"
x="139"
y="47"
id="rect3759"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="40"
height="200"
rx="19"
ry="20"
x="259"
y="47"
id="rect3801"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 281,127 0,40 -16,-12 0,-16 z"
id="path3854"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 285,143 0,8"
id="path3856"
style="fill:none;stroke:#555555;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 289,135 0,24"
id="path3858"
style="fill:none;stroke:#555555;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 293,131 0,32"
id="path3860"
style="fill:none;stroke:#555555;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 267,207 24,0"
id="path3862"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 267,87 24,0"
id="path3864"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 279,75 0,24"
id="path3866"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="20"
height="60"
ry="0"
x="159"
y="167"
id="rect3868"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="20"
height="60"
x="199"
y="167"
id="rect3883"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 167,71 0,56 44,-30 z"
id="path3885"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="12"
height="36"
ry="0"
x="59"
y="117"
id="rect3892"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 33,151 53,135 33,119 z"
id="path3894"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 7,151 27,135 7,119 z"
id="path3894-0"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="12"
height="36"
ry="0"
x="-19"
y="182"
transform="scale(-1,1)"
id="rect3892-7"
style="fill:none;stroke:#555555;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 45,215 25,199 45,183 z"
id="path3894-6"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 71,215 51,199 71,183 z"
id="path3894-0-6"
style="fill:none;stroke:#555555;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
width="100"
height="200"
rx="20"
ry="20"
x="319"
y="47"
id="rect3759-0"
style="fill:none;stroke:#222222;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</svg>"""
def click(widget, event):
cmd = click_cmds[event.button]
subprocess.call(cmd.split(' '))
if (cmd == suspend):
gtk.main_quit()
def scroll(widget, event):
cmd = scroll_cmds[event.direction]
subprocess.call(cmd.split(' '))
def close(widget, event):
gtk.main_quit()
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
event_box = gtk.EventBox()
event_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#000'))
loader = gtk.gdk.PixbufLoader('svg')
loader.write(svg_data)
loader.close()
icon = gtk.Image()
icon.set_from_pixbuf(loader.get_pixbuf())
event_box.add(icon)
window.add(event_box)
window.set_title('Dead Pilot')
window.set_icon_name('deadbeef')
window.fullscreen()
event_box.connect('button_release_event', click)
event_box.connect('scroll_event', scroll)
window.connect('delete_event', close)
icon.show()
event_box.show()
window.show()
gtk.main()