summaryrefslogtreecommitdiff
path: root/hammerspoon
diff options
context:
space:
mode:
Diffstat (limited to 'hammerspoon')
-rw-r--r--hammerspoon/init.lua122
1 files changed, 122 insertions, 0 deletions
diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua
index b370312..c130897 100644
--- a/hammerspoon/init.lua
+++ b/hammerspoon/init.lua
@@ -37,3 +37,125 @@ local screenWatcher = hs.screen.watcher.new(updateDockPosition)
screenWatcher:start()
updateDockPosition()
+
+-- Set DNS servers for the Wi-Fi interface
+local function setDNS()
+ local success, output = hs.execute("networksetup -setdnsservers 'Wi-Fi' 9.9.9.9 208.67.222.123 208.67.220.123")
+ if success then
+ hs.alert.show("DNS updated successfully")
+ else
+ hs.alert.show("Failed to update DNS: " .. output)
+ end
+end
+setDNS()
+
+-- Configure and enable/disable an HTTP/HTTPS proxy
+local function setProxy(enable)
+ local state = enable and "on" or "off"
+ hs.execute("networksetup -setwebproxy 'Wi-Fi' 127.0.0.1 7890")
+ hs.execute("networksetup -setsecurewebproxy 'Wi-Fi' 127.0.0.1 7890")
+ hs.execute(string.format("networksetup -setwebproxystate 'Wi-Fi' %s", state))
+ hs.execute(string.format("networksetup -setsecurewebproxystate 'Wi-Fi' %s", state))
+ hs.alert.show("Proxy " .. state)
+end
+setProxy("on")
+
+-- PaperWM.spoon
+PaperWM = hs.loadSpoon("PaperWM")
+PaperWM:bindHotkeys({
+ -- switch to a new focused window in tiled grid
+ focus_left = {{"alt"}, "left"},
+ focus_right = {{"alt"}, "right"},
+ focus_up = {{"alt"}, "up"},
+ focus_down = {{"alt"}, "down"},
+
+ -- switch windows by cycling forward/backward
+ -- (forward = down or right, backward = up or left)
+ focus_prev = {{"alt"}, "k"},
+ focus_next = {{"alt"}, "j"},
+
+ -- move windows around in tiled grid
+ swap_left = {{"alt", "shift"}, "left"},
+ swap_right = {{"alt", "shift"}, "right"},
+ swap_up = {{"alt", "shift"}, "up"},
+ swap_down = {{"alt", "shift"}, "down"},
+
+ -- position and resize focused window
+ center_window = {{"alt", "shift"}, "c"},
+ anchor_window_left = {{"alt", "shift"}, ","},
+ anchor_window_right = {{"alt", "shift"}, "."},
+ full_width = {{"alt", "shift"}, "f"},
+ cycle_width = {{"alt", "shift"}, "r"},
+ reverse_cycle_width = {{"ctrl", "alt", "cmd"}, "r"},
+ cycle_height = {{"alt", "cmd", "shift"}, "r"},
+ reverse_cycle_height = {{"ctrl", "alt", "cmd", "shift"}, "r"},
+
+ -- increase/decrease width
+ increase_width = {{"alt", "shift"}, "l"},
+ decrease_width = {{"alt", "shift"}, "h"},
+
+ -- move focused window into / out of a column
+ slurp_in = {{"alt", "shift"}, "i"},
+ barf_out = {{"alt", "shift"}, "o"},
+
+ -- toggle accordion stacking for the focused column
+ toggle_stack = {{"alt", "shift", "shift"}, "s"},
+
+ -- split screen focused window with left window
+ split_screen = {{ "alt", "shift" }, "s"},
+
+ -- move the focused window into / out of the tiling layer
+ toggle_floating = {{"alt", "shift"}, "escape"},
+ -- raise all floating windows on top of tiled windows
+ focus_floating = {{"alt", "shift"}, "f"},
+
+ -- focus the first / second / etc window in the current space
+ focus_window_1 = {{"alt"}, "1"},
+ focus_window_2 = {{"alt"}, "2"},
+ focus_window_3 = {{"alt"}, "3"},
+ focus_window_4 = {{"alt"}, "4"},
+ focus_window_5 = {{"alt"}, "5"},
+ focus_window_6 = {{"alt"}, "6"},
+ focus_window_7 = {{"alt"}, "7"},
+ focus_window_8 = {{"alt"}, "8"},
+ focus_window_9 = {{"alt"}, "9"},
+
+ -- focus the leftmost / rightmost window in the current space
+ focus_window_first = {{"cmd", "shift"}, "home"},
+ focus_window_last = {{"cmd", "shift"}, "end"},
+
+ -- switch to a new Mission Control space
+ switch_recent_space = {{"ctrl", "alt", "cmd"}, "6"},
+ switch_space_l = {{"alt", "cmd"}, ","},
+ switch_space_r = {{"alt", "cmd"}, "."},
+ switch_space_1 = {{"alt", "cmd"}, "1"},
+ switch_space_2 = {{"alt", "cmd"}, "2"},
+ switch_space_3 = {{"alt", "cmd"}, "3"},
+ switch_space_4 = {{"alt", "cmd"}, "4"},
+ switch_space_5 = {{"alt", "cmd"}, "5"},
+ switch_space_6 = {{"alt", "cmd"}, "6"},
+ switch_space_7 = {{"alt", "cmd"}, "7"},
+ switch_space_8 = {{"alt", "cmd"}, "8"},
+ switch_space_9 = {{"alt", "cmd"}, "9"},
+
+ -- move focused window to a new space and tile
+ move_window_l = {{ "ctrl", "alt", "cmd" }, "left"},
+ move_window_r = {{ "ctrl", "alt", "cmd" }, "right"},
+ move_window_u = {{ "ctrl", "alt", "cmd" }, "up"},
+ move_window_d = {{ "ctrl", "alt", "cmd" }, "down"},
+ move_window_1 = {{"alt", "cmd", "shift"}, "1"},
+ move_window_2 = {{"alt", "cmd", "shift"}, "2"},
+ move_window_3 = {{"alt", "cmd", "shift"}, "3"},
+ move_window_4 = {{"alt", "cmd", "shift"}, "4"},
+ move_window_5 = {{"alt", "cmd", "shift"}, "5"},
+ move_window_6 = {{"alt", "cmd", "shift"}, "6"},
+ move_window_7 = {{"alt", "cmd", "shift"}, "7"},
+ move_window_8 = {{"alt", "cmd", "shift"}, "8"},
+ move_window_9 = {{"alt", "cmd", "shift"}, "9"},
+
+ -- refresh/retile windows (forcedly)
+ refresh_windows = { { "alt", "cmd", "shift" }, "r" },
+ refresh_windows_forcedly = { { "alt", "cmd", "shift" }, "t" },
+
+})
+PaperWM:start()