Switch to the amazing chunkwm and skhd, eliminating the need for a separate mpd-mediakeys service
This commit is contained in:
parent
79e7fccab4
commit
cc4d9c2b2e
6 changed files with 380 additions and 36 deletions
|
@ -1,32 +0,0 @@
|
|||
#!/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()
|
25
local/bin/qtb
Executable file
25
local/bin/qtb
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# The arguments should be a command to run in qutebrowser. If no arguments are
|
||||
# provided, then :open -w is run by default.
|
||||
cmd=($@)
|
||||
(( $# < 1 )) && cmd=(:open -w)
|
||||
|
||||
# There should only be one qutebrowser socket, but just in case we only take
|
||||
# the first result we find.
|
||||
sockets=( ${TMPDIR}qutebrowser/ipc*(N) )
|
||||
SOCKET=$sockets[1]
|
||||
|
||||
if [[ -w $SOCKET ]]; then
|
||||
# We have a legit socket. Let's send the commands to qutebrowser. Yay!
|
||||
jo target_arg=null protocol_version=1 cwd=$PWD "args[]=$cmd" | socat - UNIX-CONNECT:$SOCKET
|
||||
else
|
||||
# No socket. Let's start qutebrowser!
|
||||
open -a qutebrowser.app
|
||||
# If we were given commands to run, we still wanna run them once qutebrowser
|
||||
# starts, so wait a little while and then re-exec this script.
|
||||
if (( $# )); then
|
||||
sleep 5
|
||||
exec qtb "$@"
|
||||
fi
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue