Switch to the amazing chunkwm and skhd, eliminating the need for a separate mpd-mediakeys service

This commit is contained in:
Danielle McLean 2018-07-30 13:21:14 +10:00
parent 79e7fccab4
commit cc4d9c2b2e
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240
6 changed files with 380 additions and 36 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>me.00dani.chunkwm</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/chunkwm</string>
<string>-c</string>
<string>/Users/dani/.config/chunkwm/chunkwmrc</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

View file

@ -5,12 +5,12 @@
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>me.00dani.mpd-mediakeys</string>
<string>me.00dani.skhd</string>
<key>ProgramArguments</key>
<array>
<string>zsh</string>
<string>-lc</string>
<string>exec mpd-mediakeys</string>
<string>/usr/local/bin/skhd</string>
<string>-c</string>
<string>/Users/dani/.config/skhd/skhdrc</string>
</array>
<key>RunAtLoad</key>
<true/>

137
config/chunkwm/chunkwmrc Executable file
View file

@ -0,0 +1,137 @@
#!/bin/bash
#
# NOTE: any 'chunkc' command that is run from this config file
# that is NOT 'chunkc core::<..>' or 'chunkc set ..'
# MUST be put in the background using &
#
# e.g:
# chunkc tiling::rule --owner Finder --name Copy --state float &
#
#
# NOTE: specify the absolutepath of the file to use for logging.
# 'stdout' or 'stderr' can be used instead of an actual filepath.
#
chunkc core::log_file stdout
#
# NOTE: specify the desired level of logging.
#
# - none, debug, warn, error
#
chunkc core::log_level warn
#
# NOTE: specify the absolutepath to the directory to use when loading a plugin.
#
chunkc core::plugin_dir /usr/local/opt/chunkwm/share/chunkwm/plugins
#
# NOTE: if enabled, chunkwm will monitor the specified plugin_dir
# and automatically reload any '.so' file that is changed.
#
chunkc core::hotload 0
#
# NOTE: the following are config variables for the chunkwm-tiling plugin.
#
chunkc set custom_bar_enabled 0
chunkc set custom_bar_all_monitors 0
chunkc set custom_bar_offset_top 20
chunkc set custom_bar_offset_bottom 0
chunkc set custom_bar_offset_left 0
chunkc set custom_bar_offset_right 0
chunkc set global_desktop_mode bsp
chunkc set global_desktop_offset_top 0
chunkc set global_desktop_offset_bottom 0
chunkc set global_desktop_offset_left 0
chunkc set global_desktop_offset_right 0
chunkc set global_desktop_offset_gap 0
#
# NOTE: syntax for desktop-specific settings
#
# chunkc set 2_desktop_mode monocle
# chunkc set 5_desktop_mode float
# chunkc set 3_desktop_offset_top 190
# chunkc set 3_desktop_offset_bottom 190
# chunkc set 3_desktop_offset_left 190
# chunkc set 3_desktop_offset_right 190
# chunkc set 3_desktop_offset_gap 30
#
chunkc set desktop_padding_step_size 10.0
chunkc set desktop_gap_step_size 5.0
chunkc set bsp_spawn_left 1
chunkc set bsp_optimal_ratio 1.618
chunkc set bsp_split_mode optimal
chunkc set bsp_split_ratio 0.5
chunkc set monitor_focus_cycle 1
chunkc set window_focus_cycle monitor
chunkc set mouse_follows_focus intrinsic
chunkc set window_float_next 0
chunkc set window_region_locked 1
chunkc set mouse_move_window \"fn 1\"
chunkc set mouse_resize_window \"fn 2\"
chunkc set mouse_motion_interval 35
chunkc set preselect_border_color 0xffd75f5f
chunkc set preselect_border_width 5
#
# NOTE: these settings require chwm-sa.
# (https://github.com/koekeishiya/chwm-sa)
#
chunkc set window_float_topmost 1
chunkc set window_fade_inactive 0
chunkc set window_fade_alpha 0.85
chunkc set window_fade_duration 0.25
chunkc set window_use_cgs_move 1
#
# NOTE: the following are config variables for the chunkwm-border plugin.
#
chunkc set focused_border_color 0xff0f6288
chunkc set focused_border_width 5
chunkc set focused_border_radius 0
chunkc set focused_border_skip_floating 0
chunkc set focused_border_skip_monocle 0
#
# NOTE: the following are config variables for the chunkwm-ffm plugin.
#
chunkc set ffm_bypass_modifier fn
chunkc set ffm_standby_on_float 1
#
# NOTE: specify plugins to load when chunkwm starts.
#
chunkc core::load border.so
chunkc core::load tiling.so
chunkc core::load ffm.so
chunkc tiling::rule --owner Fantastical --state float &
chunkc tiling::rule --owner Tweetbot --name '"New Tweet"' --state float &
#
# NOTE: sample rules for the tiling plugin
#
chunkc tiling::rule --owner Finder --name Copy --state float &
chunkc tiling::rule --owner \"App Store\" --state float &
chunkc tiling::rule --owner Emacs --except "^$" --state tile &

196
config/skhd/skhdrc Normal file
View file

@ -0,0 +1,196 @@
# NOTE(koekeishiya): A list of all built-in modifier and literal keywords can
# be found at https://github.com/koekeishiya/skhd/issues/1
#
# A hotkey is written according to the following rules:
#
# hotkey = <mode> '<' <action> | <action>
#
# mode = 'name of mode' | <mode> ',' <mode>
#
# action = <keysym> ':' <command> | <keysym> '->' ':' <command>
# <keysym> ';' <mode> | <keysym> '->' ';' <mode>
#
# keysym = <mod> '-' <key> | <key>
#
# mod = 'built-in mod keyword' | <mod> '+' <mod>
#
# key = <literal> | <keycode>
#
# literal = 'single letter or built-in keyword'
#
# keycode = 'apple keyboard kVK_<Key> values (0x3C)'
#
# -> = keypress is not consumed by skhd
#
# command = command is executed through '$SHELL -c' and
# follows valid shell syntax. if the $SHELL environment
# variable is not set, it will default to '/bin/bash'.
# when bash is used, the ';' delimeter can be specified
# to chain commands.
#
# to allow a command to extend into multiple lines,
# prepend '\' at the end of the previous line.
#
# an EOL character signifies the end of the bind.
#
#
# NOTE(koekeishiya): A mode is declared according to the following rules:
#
# mode_decl = '::' <name> '@' ':' <command> | '::' <name> ':' <command> |
# '::' <name> '@' | '::' <name>
#
# name = desired name for this mode,
#
# @ = capture keypresses regardless of being bound to an action
#
# command = command is executed through '$SHELL -c' and
# follows valid shell syntax. if the $SHELL environment
# variable is not set, it will default to '/bin/bash'.
# when bash is used, the ';' delimeter can be specified
# to chain commands.
#
# to allow a command to extend into multiple lines,
# prepend '\' at the end of the previous line.
#
# an EOL character signifies the end of the bind.
# add an on_enter command to the default mode
# :: default : chunkc border::color 0xff775759
#
# defines a new mode 'test' with an on_enter command, that captures keypresses
# :: test @ : chunkc border::color 0xff24ccaa
#
# from 'default' mode, activate mode 'test'
# cmd - x ; test
#
# from 'test' mode, activate mode 'default'
# test < cmd - x ; default
#
# launch a new terminal instance when in either 'default' or 'test' mode
# default, test < cmd - return : open -na /Applications/Terminal.app
rctrl - return : /Applications/Kitty.app/Contents/MacOS/kitty --single-instance\
--directory=$HOME --listen-on=unix:$XDG_CACHE_HOME/kitty/kitty.sock
# open qutebrowser
rctrl + shift - return : ~/.local/bin/qtb
# close focused window
rctrl - q : chunkc tiling::window --close
# focus window
rctrl - j : chunkc tiling::window --focus next
rctrl - k : chunkc tiling::window --focus prev
cmd - tab : chunkc tiling::window --focus prev
cmd + shift - tab : chunkc tiling::window --focus next
# equalize size of windows (mod+=)
rctrl - 0x18 : chunkc tiling::desktop --equalize
# move window
rctrl + shift - j : chunkc tiling::window --warp next
rctrl + shift - k : chunkc tiling::window --warp prev
# make floating window fill screen
shift + alt - up : chunkc tiling::window --grid-layout 1:1:0:0:1:1
# make floating window fill left-half of screen
shift + alt - left : chunkc tiling::window --grid-layout 1:2:0:0:1:1
# make floating window fill right-half of screen
shift + alt - right : chunkc tiling::window --grid-layout 1:2:1:0:1:1
# fast focus desktop
rctrl - x : chunkc tiling::desktop --focus $(chunkc get _last_active_desktop)
rctrl - z : chunkc tiling::desktop --focus prev
rctrl - c : chunkc tiling::desktop --focus next
rctrl - 1 : chunkc tiling::desktop --focus 1
rctrl - 2 : chunkc tiling::desktop --focus 2
rctrl - 3 : chunkc tiling::desktop --focus 3
rctrl - 4 : chunkc tiling::desktop --focus 4
rctrl - 5 : chunkc tiling::desktop --focus 5
rctrl - 6 : chunkc tiling::desktop --focus 6
# send window to desktop
rctrl + shift - x : chunkc tiling::window --send-to-desktop $(chunkc get _last_active_desktop)
rctrl + shift - z : chunkc tiling::window --send-to-desktop prev
rctrl + shift - c : chunkc tiling::window --send-to-desktop next
rctrl + shift - 1 : chunkc tiling::window --send-to-desktop 1
rctrl + shift - 2 : chunkc tiling::window --send-to-desktop 2
rctrl + shift - 3 : chunkc tiling::window --send-to-desktop 3
rctrl + shift - 4 : chunkc tiling::window --send-to-desktop 4
rctrl + shift - 5 : chunkc tiling::window --send-to-desktop 5
rctrl + shift - 6 : chunkc tiling::window --send-to-desktop 6
# send window to desktop and follow focus
# shift + cmd - x : chunkc tiling::window --send-to-desktop $(chunkc get _last_active_desktop); chunkc tiling::desktop --focus $(chunkc get _last_active_desktop)
# shift + cmd - z : chunkc tiling::window --send-to-desktop prev; chunkc tiling::desktop --focus prev
# shift + cmd - c : chunkc tiling::window --send-to-desktop next; chunkc tiling::desktop --focus next
# shift + cmd - 1 : chunkc tiling::window --send-to-desktop 1; chunkc tiling::desktop --focus 1
# shift + cmd - 2 : chunkc tiling::window --send-to-desktop 2; chunkc tiling::desktop --focus 2
# shift + cmd - 3 : chunkc tiling::window --send-to-desktop 3; chunkc tiling::desktop --focus 3
# shift + cmd - 4 : chunkc tiling::window --send-to-desktop 4; chunkc tiling::desktop --focus 4
# shift + cmd - 5 : chunkc tiling::window --send-to-desktop 5; chunkc tiling::desktop --focus 5
# shift + cmd - 6 : chunkc tiling::window --send-to-desktop 6; chunkc tiling::desktop --focus 6
# shift + cmd - 7 : chunkc tiling::window --send-to-desktop 7; chunkc tiling::desktop --focus 7
# focus monitor
rctrl - w : chunkc tiling::monitor -f 1
rctrl - e : chunkc tiling::monitor -f 2
# send window to monitor and follow focus
rctrl + shift - w : chunkc tiling::window --send-to-monitor 1; chunkc tiling::monitor -f 1
rctrl + shift - e : chunkc tiling::window --send-to-monitor 2; chunkc tiling::monitor -f 2
# set insertion point for focused container
# ctrl + alt - f : chunkc tiling::window --use-insertion-point cancel
# ctrl + alt - h : chunkc tiling::window --use-insertion-point west
# ctrl + alt - j : chunkc tiling::window --use-insertion-point south
# ctrl + alt - k : chunkc tiling::window --use-insertion-point north
# ctrl + alt - l : chunkc tiling::window --use-insertion-point east
# rotate tree
rctrl - space : chunkc tiling::desktop --rotate 90
# mirror tree
rctrl - m : chunkc tiling::desktop --mirror horizontal
rctrl + shift - m : chunkc tiling::desktop --mirror vertical
# toggle desktop offset
# alt - a : chunkc tiling::desktop --toggle offset
# toggle window fullscreen
rctrl - f : chunkc tiling::window --toggle fullscreen
# toggle window native fullscreen
rctrl + shift - f : chunkc tiling::window --toggle native-fullscreen
# toggle window parent zoom
alt - d : chunkc tiling::window --toggle parent
# toggle window split type
alt - e : chunkc tiling::window --toggle split
# toggle window fade
alt - q : chunkc tiling::window --toggle fade
# float / unfloat window and center on screen
alt - t : chunkc tiling::window --toggle float;\
chunkc tiling::window --grid-layout 4:4:1:1:2:2
# toggle sticky, float and resize to picture-in-picture size
alt - s : chunkc tiling::window --toggle sticky;\
chunkc tiling::window --grid-layout 5:5:4:0:1:1
# float next window to be tiled
# shift + alt - t : chunkc set window_float_next 1
# change layout of desktop
rctrl - a : chunkc tiling::desktop --layout bsp
rctrl - s : chunkc tiling::desktop --layout monocle
rctrl - d : chunkc tiling::desktop --layout float
play : mpc toggle
rewind : mpc cdprev
fast : mpc next

View file

@ -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
View 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