diff --git a/Library/LaunchAgents/me.00dani.mediakeys-mpd.plist b/Library/LaunchAgents/me.00dani.mediakeys-mpd.plist new file mode 100644 index 0000000..de30aaa --- /dev/null +++ b/Library/LaunchAgents/me.00dani.mediakeys-mpd.plist @@ -0,0 +1,16 @@ + + + + + Label + me.00dani.mediakeys-mpd + ProgramArguments + + zsh + -lc + mediakeys-mpd + + RunAtLoad + + + diff --git a/local/bin/mediakeys-cmus b/local/bin/mediakeys-cmus new file mode 100755 index 0000000..6354ee7 --- /dev/null +++ b/local/bin/mediakeys-cmus @@ -0,0 +1,32 @@ +#!/usr/bin/env python +import osxmmkeys +import subprocess +import time + +commands = { + 'play_pause': '-u', + 'next_track': '-n', + 'prev_track': '-r' +} + +class CmusKeys(): + def __init__(self): + def cmusRemote(command, flag): + def f(): + print(command) + subprocess.call(['cmus-remote', flag]) + return False + return f + + self.tap = osxmmkeys.Tap() + for command, flag in commands.items(): + self.tap.on(command, cmusRemote(command, flag)) + + def run(self): + self.tap.start() + try: + while True: time.sleep(1) + except (KeyboardInterrupt, SystemExit): + self.tap.stop() + +if __name__ == '__main__': CmusKeys().run() diff --git a/local/bin/mediakeys-mpd b/local/bin/mediakeys-mpd new file mode 100755 index 0000000..8e800dc --- /dev/null +++ b/local/bin/mediakeys-mpd @@ -0,0 +1,32 @@ +#!/usr/bin/env python +import osxmmkeys +import subprocess +import time + +commands = { + 'play_pause': 'toggle', + 'next_track': 'next', + 'prev_track': 'cdprev' +} + +class MpdKeys(): + def __init__(self): + def mpdRemote(command, flag): + def f(): + print(command) + subprocess.call(['mpc', flag]) + return False + return f + + self.tap = osxmmkeys.Tap() + for command, flag in commands.items(): + self.tap.on(command, mpdRemote(command, flag)) + + def run(self): + self.tap.start() + try: + while True: time.sleep(1) + except (KeyboardInterrupt, SystemExit): + self.tap.stop() + +if __name__ == '__main__': MpdKeys().run()