From a90e4860a797f066832455650ab16ccb27144bce Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Fri, 10 Aug 2018 14:41:46 -0400 Subject: [PATCH] [provisioning] Add chunkwm --- .chunkwmrc | 113 +++++++++ .skhdrc | 226 ++++++++++++++++++ .../LaunchAgents/com.koekeishiya.skhd.plist | 27 +++ recipes/_launchd | 18 ++ recipes/_link | 12 + recipes/chunkwm | 22 ++ 6 files changed, 418 insertions(+) create mode 100755 .chunkwmrc create mode 100644 .skhdrc create mode 100644 Library/LaunchAgents/com.koekeishiya.skhd.plist create mode 100644 recipes/_launchd create mode 100644 recipes/_link create mode 100644 recipes/chunkwm diff --git a/.chunkwmrc b/.chunkwmrc new file mode 100755 index 0000000..6154e84 --- /dev/null +++ b/.chunkwmrc @@ -0,0 +1,113 @@ +#!/bin/bash + +# +# NOTE: specify the absolutepath of the file to use for logging. +# 'stdout' and 'stderr' are valid values. +# + +chunkc core::log_file stdout + +# +# NOTE: specify the desired level of logging. +# +# - none, debug, warn, error +# + +chunkc core::log_level error + +# +# NOTE: specify the absolutepath to the directory to use when +# loading a plugin. '~' expansion is supported. +# + +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 global_desktop_mode bsp +# chunkc set 2_desktop_mode monocle +# chunkc set 5_desktop_mode float + +chunkc set global_desktop_offset_top 20 +chunkc set global_desktop_offset_bottom 20 +chunkc set global_desktop_offset_left 20 +chunkc set global_desktop_offset_right 20 +chunkc set global_desktop_offset_gap 15 + +# 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 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 + +# +# NOTE: shell commands require escaped quotes +# to pass value containing a whitespace. +# +# chunkc set mouse_modifier \"cmd shift\" +chunkc set mouse_modifier fn + +chunkc set preselect_border_color 0xffd75f5f +chunkc set preselect_border_width 5 +chunkc set preselect_border_radius 0 + +# +# NOTE: these settings require chwm-sa. +# (https://github.com/koekeishiya/chwm-sa) +# + +chunkc set window_float_topmost 0 +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 0 + +# +# 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 + +# +# NOTE: specify plugins to load when chunkwm starts. +# if chunkc plugin_dir is not set, the absolutepath is necessary. +# + +chunkc core::load border.so +chunkc core::load tiling.so +chunkc core::load ffm.so + +# +# NOTE: shell commands require escaped quotes +# to pass value containing a whitespace. +# + +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 diff --git a/.skhdrc b/.skhdrc new file mode 100644 index 0000000..af96b88 --- /dev/null +++ b/.skhdrc @@ -0,0 +1,226 @@ +# 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 = 'name of mode' | ',' +# +# action = ':' | '->' ':' +# ';' | '->' ';' +# +# keysym = '-' | +# +# mod = 'built-in mod keyword' | '+' +# +# key = | +# +# literal = 'single letter or built-in keyword' +# +# keycode = 'apple keyboard kVK_ 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 = 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 + +# open terminal, blazingly fast compared to iTerm/Hyper +cmd - return : open -na /Applications/Kitty.app + +# open qutebrowser +cmd + shift - return : ~/Scripts/qtb.sh + +# close focused window +alt - w : chunkc tiling::window --close + +# focus window +alt - h : chunkc tiling::window --focus west +alt - j : chunkc tiling::window --focus south +alt - k : chunkc tiling::window --focus north +alt - l : chunkc tiling::window --focus east + +cmd - j : chunkc tiling::window --focus prev +cmd - k : chunkc tiling::window --focus next + +# equalize size of windows +shift + alt - 0 : chunkc tiling::desktop --equalize + +# swap window +shift + alt - h : chunkc tiling::window --swap west +shift + alt - j : chunkc tiling::window --swap south +shift + alt - k : chunkc tiling::window --swap north +shift + alt - l : chunkc tiling::window --swap east + +# move window +shift + cmd - h : chunkc tiling::window --warp west +shift + cmd - j : chunkc tiling::window --warp south +shift + cmd - k : chunkc tiling::window --warp north +shift + cmd - l : chunkc tiling::window --warp east + +# 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 +cmd + alt - x : chunkc tiling::desktop --focus $(chunkc get _last_active_desktop) +cmd + alt - z : chunkc tiling::desktop --focus prev +cmd + alt - c : chunkc tiling::desktop --focus next +cmd + alt - 1 : chunkc tiling::desktop --focus 1 +cmd + alt - 2 : chunkc tiling::desktop --focus 2 +cmd + alt - 3 : chunkc tiling::desktop --focus 3 +cmd + alt - 4 : chunkc tiling::desktop --focus 4 +cmd + alt - 5 : chunkc tiling::desktop --focus 5 +cmd + alt - 6 : chunkc tiling::desktop --focus 6 +cmd + alt - 7 : chunkc tiling::desktop --focus 7 + +# send window to desktop +shift + alt - x : chunkc tiling::window --send-to-desktop $(chunkc get _last_active_desktop) +shift + alt - z : chunkc tiling::window --send-to-desktop prev +shift + alt - c : chunkc tiling::window --send-to-desktop next +shift + alt - 1 : chunkc tiling::window --send-to-desktop 1 +shift + alt - 2 : chunkc tiling::window --send-to-desktop 2 +shift + alt - 3 : chunkc tiling::window --send-to-desktop 3 +shift + alt - 4 : chunkc tiling::window --send-to-desktop 4 +shift + alt - 5 : chunkc tiling::window --send-to-desktop 5 +shift + alt - 6 : chunkc tiling::window --send-to-desktop 6 +shift + alt - 7 : chunkc tiling::window --send-to-desktop 7 + +# 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 +ctrl + alt - z : chunkc tiling::monitor -f prev +ctrl + alt - c : chunkc tiling::monitor -f next +ctrl + alt - 1 : chunkc tiling::monitor -f 1 +ctrl + alt - 2 : chunkc tiling::monitor -f 2 +ctrl + alt - 3 : chunkc tiling::monitor -f 3 + +# send window to monitor and follow focus +ctrl + cmd - z : chunkc tiling::window --send-to-monitor prev; chunkc tiling::monitor -f prev +ctrl + cmd - c : chunkc tiling::window --send-to-monitor next; chunkc tiling::monitor -f next +ctrl + cmd - 1 : chunkc tiling::window --send-to-monitor 1; chunkc tiling::monitor -f 1 +ctrl + cmd - 2 : chunkc tiling::window --send-to-monitor 2; chunkc tiling::monitor -f 2 +ctrl + cmd - 3 : chunkc tiling::window --send-to-monitor 3; chunkc tiling::monitor -f 3 + +# increase region size +shift + alt - a : chunkc tiling::window --use-temporary-ratio 0.1 --adjust-window-edge west +shift + alt - s : chunkc tiling::window --use-temporary-ratio 0.1 --adjust-window-edge south +shift + alt - w : chunkc tiling::window --use-temporary-ratio 0.1 --adjust-window-edge north +shift + alt - d : chunkc tiling::window --use-temporary-ratio 0.1 --adjust-window-edge east + +# decrease region size +shift + cmd - a : chunkc tiling::window --use-temporary-ratio -0.1 --adjust-window-edge west +shift + cmd - s : chunkc tiling::window --use-temporary-ratio -0.1 --adjust-window-edge south +shift + cmd - w : chunkc tiling::window --use-temporary-ratio -0.1 --adjust-window-edge north +shift + cmd - d : chunkc tiling::window --use-temporary-ratio -0.1 --adjust-window-edge east + +# 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 +cmd - r : chunkc tiling::desktop --rotate 90 + +# mirror tree y-axis +# cmd - y : chunkc tiling::desktop --mirror vertical + +# mirror tree x-axis +# cmd - x : chunkc tiling::desktop --mirror horizontal + +# toggle desktop offset +cmd - a : chunkc tiling::desktop --toggle offset + +# toggle window fullscreen +cmd - f : chunkc tiling::window --toggle fullscreen + +# toggle window native fullscreen +shift + alt - f : chunkc tiling::window --toggle native-fullscreen + +# toggle window parent zoom +cmd - d : chunkc tiling::window --toggle parent + +# toggle window split type +cmd - e : chunkc tiling::window --toggle split + +# toggle window fade +cmd - q : chunkc tiling::window --toggle fade + +# float / unfloat window and center on screen +shift + cmd - f : 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 +cmd - 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 +ctrl + alt - a : chunkc tiling::desktop --layout bsp +ctrl + alt - s : chunkc tiling::desktop --layout monocle +ctrl + alt - d : chunkc tiling::desktop --layout float + +ctrl + alt - w : chunkc tiling::desktop --deserialize ~/.chunkwm_layouts/dev_1 diff --git a/Library/LaunchAgents/com.koekeishiya.skhd.plist b/Library/LaunchAgents/com.koekeishiya.skhd.plist new file mode 100644 index 0000000..141e760 --- /dev/null +++ b/Library/LaunchAgents/com.koekeishiya.skhd.plist @@ -0,0 +1,27 @@ + + + + + Label + com.koekeishiya.skhd + ProgramArguments + + /usr/local/bin/skhd + + EnvironmentVariables + + SHELL + /bin/bash + PATH + /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin + + RunAtLoad + + KeepAlive + + StandardOutPath + /tmp/skhd.out + StandardErrorPath + /tmp/skhd.err + + diff --git a/recipes/_launchd b/recipes/_launchd new file mode 100644 index 0000000..b3235b0 --- /dev/null +++ b/recipes/_launchd @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +_recipe _link + +_launchd() { + local service=$1 + local filename="${service}.plist" + local source=${HOME}/dotfiles/Library/LaunchAgents/${filename} + local target=${HOME}/Library/LaunchAgents/${filename} + if launchctl list $service >/dev/null 2>&1; then + echo "[launchd] $service already installed, skipping." + else + mkdir -p ${HOME}/Library/LaunchAgents + _link $source $target + _run "[launchd] Install $service" launchctl load $target + fi +} diff --git a/recipes/_link b/recipes/_link new file mode 100644 index 0000000..a14afbd --- /dev/null +++ b/recipes/_link @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +_link() { + source=$1 + target=$2 + if [ ! -e $target ]; then + _run "[link] Install $target" ln -s $source $target + else + echo "[link] $target already installed, skipping." + fi +} diff --git a/recipes/chunkwm b/recipes/chunkwm new file mode 100644 index 0000000..67f2d05 --- /dev/null +++ b/recipes/chunkwm @@ -0,0 +1,22 @@ +#!/bin/bash +# Description: Tiling window manager for OSX +set -e + +_recipe _launchd +_recipe _link +_recipe brew + +_link ${HOME}/dotfiles/.chunkwmrc \ + ${HOME}/.chunkwmrc +_link ${HOME}/dotfiles/.skhdrc \ + ${HOME}/.skhdrc + +_brew_tap crisidev/homebrew-chunkwm +_brew chunkwm +brew services start chunkwm + +_brew koekeishiya/formulae/skhd +# Use launchd directly rather than brew services so we can configure +# the shell to use bash. There is a significant delay when using zsh +# (my preferred default). +_launchd com.koekeishiya.skhd