From ee9fbc905e4e0bcc36959910246762fcea6d62df Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Wed, 29 Jan 2020 18:06:48 -0500 Subject: [PATCH 1/2] idk what I was doing --- config.json | 121 ++++++++++---------- config/karabiner/karabiner.json | 136 ++++++++++++++++++++++- hammerspoon/global.lua | 3 +- install.py | 7 -- launchagents/local.timods.watchman.plist | 4 +- zsh/dev.sh | 2 +- 6 files changed, 198 insertions(+), 75 deletions(-) diff --git a/config.json b/config.json index e01a154..24fd7e3 100644 --- a/config.json +++ b/config.json @@ -48,77 +48,72 @@ "zsh" ], "casks": [ - "alfred", - {"name": "arq", "when": "home"}, - "bettertouchtool", - "brave-browser", - "dash", - {"name": "epic-games", "when": "home"}, - "fantastical", - "firefox", - "font-fira-code", - "font-fira-mono", - {"name": "franz", "when": "home"}, - {"name": "gog-galaxy", "when": "home"}, - "hammerspoon", - "iina", - {"name": "iridient-developer", "when": "home"}, - {"name": "java8", "when": "home"}, - "keka", - {"name": "keybase", "when": "home"}, - "lunchy", - {"name": "openemu", "when": "home"}, - "osxfuse", - "racket", - {"name": "signal", "when": "home"}, - "skim", - {"name": "steam", "when": "home"}, - "tla-plus-toolbox", - {"name": "transmission", "when": "home"}, - "virtualbox", - {"name": "vmware-fusion", "when": "home"}, - "xquartz" + "alfred", + {"name": "arq", "when": "home"}, + "bettertouchtool", + "brave-browser", + "dash", + {"name": "epic-games", "when": "home"}, + "fantastical", + "firefox", + "font-fira-code", + "font-fira-mono", + {"name": "franz", "when": "home"}, + {"name": "gog-galaxy", "when": "home"}, + "hammerspoon", + "iina", + {"name": "iridient-developer", "when": "home"}, + {"name": "java8", "when": "home"}, + "keka", + {"name": "keybase", "when": "home"}, + "lunchy", + {"name": "openemu", "when": "home"}, + "osxfuse", + "racket", + {"name": "signal", "when": "home"}, + "skim", + {"name": "steam", "when": "home"}, + {"name": "transmission", "when": "home"}, + "virtualbox", + {"name": "vmware-fusion", "when": "home"}, + "xquartz" ], "mas": [ - "Things3", - "Xcode", - "Paprika Recipe Manager 3", - "Keep It", - "Pixelmator", - "Kindle", - "Time Out", - "1Password 7" + "Xcode", + "Paprika Recipe Manager 3", + "Pixelmator", + "Kindle", + "Time Out", + "1Password 7" ], "sources": { - "https://github.com/larkery/zsh-histdb.git": "~/.zsh-histdb/", - "https://github.com/asdf-vm/asdf.git": { - "destination": "~/.asdf", - "post-install": "cd ~/.asdf && git checkout \"$(git describe --abbrev=0 --tags)\"" - }, - "https://github.com/tarjoilija/zgen": { - "symlinks": { - "zgen.zsh": "~/.zgen.zsh", - "_zgen": "~/.zsh/_zgen" - } - }, - "https://github.com/scottwhudson/Lunette.git": { - "symlinks": { - "Lunette.spoon": "~/.hammerspoon/Spoons/" - } + "https://github.com/larkery/zsh-histdb.git": "~/.zsh-histdb/", + "https://github.com/asdf-vm/asdf.git": { + "destination": "~/.asdf", + "post-install": "cd ~/.asdf && git checkout \"$(git describe --abbrev=0 --tags)\"" + }, + "https://github.com/tarjoilija/zgen": { + "symlinks": { + "zgen.zsh": "~/.zgen.zsh", + "_zgen": "~/.zsh/_zgen" } + }, + "https://github.com/scottwhudson/Lunette.git": { + "symlinks": { + "Lunette.spoon": "~/.hammerspoon/Spoons/" + } + } }, "symlinks": { - "dots/.*": "~/", - "zsh/*": "~/.config/zsh/config.sh", - "bin/*": "~/.local/bin/", - "config/*": "~/.config/", - "launchagents/*.plist":"~/Library/LaunchAgents/", - "hammerspoon/*": "~/.hammerspoon/", - "etc/unbound/*": "~/homebrew/opt/unbound/etc/unbound/", - "etc/stubby/*": "~/homebrew/etc/stubby/" + "dots/.*": "~/", + "zsh/*": "~/.config/zsh/config.sh", + "bin/*": "~/.local/bin/", + "config/*": "~/.config/", + "launchagents/*.plist":"~/Library/LaunchAgents/", + "hammerspoon/*": "~/.hammerspoon/" }, "post-install": [ - "brew cleanup", - "find ~/Library/LaunchAgents -name '*.plist' | xargs launchctl load" + "brew cleanup", + "find ~/Library/LaunchAgents -name '*.plist' | xargs launchctl load" ] } diff --git a/config/karabiner/karabiner.json b/config/karabiner/karabiner.json index c9fc307..9b10392 100644 --- a/config/karabiner/karabiner.json +++ b/config/karabiner/karabiner.json @@ -75,6 +75,140 @@ "type": "basic" } ] + }, + { + "description": "SpaceFN: Space enables SpaceFN mode (see: https://geekhack.org/index.php?topic=51069.0)", + "manipulators": [ + { + "from": { + "key_code": "spacebar", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "set_variable": { + "name": "spacefn_mode", + "value": 1 + } + } + ], + "to_after_key_up": [ + { + "set_variable": { + "name": "spacefn_mode", + "value": 0 + } + } + ], + "to_if_alone": [ + { + "key_code": "spacebar" + } + ], + "type": "basic" + } + ] + }, + { + "description": "SpaceFN: Space+[ijkl] to Up, Left, Down, Right", + "manipulators": [ + { + "conditions": [ + { + "name": "spacefn_mode", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "spacefn_mode", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "spacefn_mode", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "spacefn_mode", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + } + ] } ] }, @@ -260,4 +394,4 @@ } } ] -} +} \ No newline at end of file diff --git a/hammerspoon/global.lua b/hammerspoon/global.lua index dd2503b..5963d55 100644 --- a/hammerspoon/global.lua +++ b/hammerspoon/global.lua @@ -89,6 +89,7 @@ else hs.application.launchOrFocusByBundleID('com.apple.mail') hs.osascript.applescript('tell application "Mail" to check for new mail') end ) - hs.hotkey.bind(module.prefix, "a", collectFromFrontmostApp) -- a for Archive + hs.hotkey.bind(module.prefix, "t", launcher("com.culturedcode.ThingsMac")) + --hs.hotkey.bind(module.prefix, "a", collectFromFrontmostApp) -- a for Archive hs.hotkey.bind(module.prefix, "r", todoFromFrontmostApp) -- r for Remember end diff --git a/install.py b/install.py index b7da5a8..9fd9823 100644 --- a/install.py +++ b/install.py @@ -127,7 +127,6 @@ def install_brew(pkgs, tags): with NamedTemporaryFile('w') as tf: tf.write('\n'.join(to_install)) tf.flush() - import pdb; pdb.set_trace() runcmd('xargs <{} brew install'.format(tf.name)) @@ -182,12 +181,6 @@ def install_from_config(config_file, tags): except OSError: pass # FIXME: only do the following four on macos hosts - if platform.system() == 'Darwin': - # check_install_deps_macos() - install_taps(config.get('brew-taps', [])) - install_casks(config.get('casks', []), tags) - install_brew(config.get('brew', []), tags) - # install_mas(config.get('mas', []), tags) install_sources(config.get('sources', {})) install_symlinks(config.get('symlinks', {})) post_install(config) diff --git a/launchagents/local.timods.watchman.plist b/launchagents/local.timods.watchman.plist index fd526e5..1963121 100644 --- a/launchagents/local.timods.watchman.plist +++ b/launchagents/local.timods.watchman.plist @@ -3,12 +3,12 @@ Label - com.github.facebook.watchman + local.timods.watchman Disabled ProgramArguments - /usr/local/bin/watchman + /Users/timods/.local/bin/watchman --foreground --logfile=/usr/local/var/run/watchman/timods-state/log --log-level=1 diff --git a/zsh/dev.sh b/zsh/dev.sh index 7814699..67e035e 100644 --- a/zsh/dev.sh +++ b/zsh/dev.sh @@ -10,7 +10,7 @@ export GDTMPLS="$GOPATH/src/github.com/chronoslynx/godoc-tmpls" export CCACHE_COMPRESS=1 # personal installation prefix -export PREFIX="$HOME/.local" +export INSTALL_PREFIX="$HOME/.local" export XTARGET="i686-elf" export CARGO_HOME="$HOME/.cargo" export CHOOSENIM_NO_ANALYTICS=1 From 42f2c503b235e66e68e4c0fcf4c216efb349fbc4 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Wed, 29 Jan 2020 18:21:07 -0500 Subject: [PATCH 2/2] Add more hammerspoon helpers --- hammerspoon/init.lua | 19 +++++++++++++++++++ hammerspoon/reload.lua | 0 hammerspoon/sleepwake.lua | 27 +++++++++++++++++++++++++++ hammerspoon/usb.lua | 16 ++++++++++++++++ hammerspoon/wifi.lua | 23 +++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 hammerspoon/reload.lua create mode 100644 hammerspoon/sleepwake.lua create mode 100644 hammerspoon/usb.lua create mode 100644 hammerspoon/wifi.lua diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 5f8fa01..9e1a3a8 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -7,3 +7,22 @@ hs.dockicon.hide() local global = require 'global' local keepit = require 'keepit' local mail = require 'mail' + +local sleepwake = require 'sleepwake' +local wifi = require 'wifi' +local usb = require 'usb' +local wifi = require 'wifi' + +function reloadConfig(files) + doReload = false + for _,file in pairs(files) do + if file:sub(-4) == ".lua" then + doReload = true + end + end + if doReload then + hs.reload() + end +end +homewatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start() +hs.alert.show("Config loaded") diff --git a/hammerspoon/reload.lua b/hammerspoon/reload.lua new file mode 100644 index 0000000..e69de29 diff --git a/hammerspoon/sleepwake.lua b/hammerspoon/sleepwake.lua new file mode 100644 index 0000000..c445315 --- /dev/null +++ b/hammerspoon/sleepwake.lua @@ -0,0 +1,27 @@ +require "string" + +local module = {} + +function checkBluetoothResult(rc, stderr, stderr) + if rc ~= 0 then + print(string.format("Unexpected result executing `blueutil`: rc=%d stderr=%s stdout=%s", rc, stderr, stdout)) + end +end + +function bluetooth(power) + print("Setting bluetooth to " .. power) + local t = hs.task.new("/usr/local/bin/blueutil", checkBluetoothResult, {"--power", power}) + t:start() +end + +function f(event) + if event == hs.caffeinate.watcher.systemWillSleep then + bluetooth("off") + elseif event == hs.caffeinate.watcher.screensDidWake then + bluetooth("on") + end +end + +module.watcher = hs.caffeinate.watcher.new(f) +module.watcher:start() +return module diff --git a/hammerspoon/usb.lua b/hammerspoon/usb.lua new file mode 100644 index 0000000..0223fef --- /dev/null +++ b/hammerspoon/usb.lua @@ -0,0 +1,16 @@ +local module = {} + +local evtAdd = "added" +local evtRemove = "removed" + +function usbDeviceCallback(data) + -- TODO set audio output to the FiiO DAC + -- TODO set audio input to the blue snowball + pn = data["productName"] + evt = data["eventType"] +end + +module.watcher = hs.usb.watcher.new(usbDeviceCallback) +module.watcher:start() + +return module diff --git a/hammerspoon/wifi.lua b/hammerspoon/wifi.lua new file mode 100644 index 0000000..4235346 --- /dev/null +++ b/hammerspoon/wifi.lua @@ -0,0 +1,23 @@ +local module = {} +module.watcher = nil +local homeSSID = "chrowireless" +local lastSSID = hs.wifi.currentNetwork() + +function ssidChangedCallback() + newSSID = hs.wifi.currentNetwork() + + if newSSID == homeSSID and lastSSID ~= homeSSID then + -- We just joined our home WiFi network + hs.audiodevice.defaultOutputDevice():setVolume(25) + elseif newSSID ~= homeSSID and lastSSID == homeSSID then + -- We just departed our home WiFi network + hs.audiodevice.defaultOutputDevice():setVolume(0) + end + + lastSSID = newSSID +end + +module.watcher = hs.wifi.watcher.new(ssidChangedCallback) +module.watcher:start() + +return module