diff --git a/.hammerspoon/init.lua b/.hammerspoon/init.lua index 2739054..8516cc9 100644 --- a/.hammerspoon/init.lua +++ b/.hammerspoon/init.lua @@ -3,25 +3,30 @@ local smash = {"cmd", "alt", "ctrl", "shift"} -- Window management -function chunkc (args) - hs.task.new("/usr/local/bin/chunkc", nil, args) - :start() -end +-- TODO implement desktop and window gaps +hs.urlevent.bind("wm", function(eventName, params) + local log = hs.logger.new("wm", "debug") -hs.hotkey.bind(mash, "left", function() - chunkc({"tiling::window", "--warp", "west"}) -end) -hs.hotkey.bind(mash, "right", function() - chunkc({"tiling::window", "--warp", "east"}) -end) -hs.hotkey.bind(mash, "up", function() - chunkc({"tiling::window", "--warp", "north"}) -end) -hs.hotkey.bind(mash, "down", function() - chunkc({"tiling::window", "--warp", "south"}) -end) -hs.hotkey.bind(mash, "z", function() - chunkc({"tiling::window", "--toggle", "fullscreen"}) + local win = hs.window.focusedWindow() -- TODO figure out why focusedWindow doesn't work + -- local win = hs.window.frontmostWindow() + local f = win:frame() + local screen = win:screen() + local max = screen:frame() + + local t = { + left = function(f) return hs.layout.left50 end, + right = function(f) return hs.layout.right50 end, + ne = function(f) return { 0.5, 0, 0.5, 0.5 } end, + nw = function(f) return { 0, 0, 0.5, 0.5 } end, + se = function(f) return { 0.5, 0.5, 0.5, 0.5 } end, + sw = function(f) return { 0, 0.5, 0.5, 0.5 } end, + max = function(f) return hs.layout.maximized end, + } + + local unitRect = hs.geometry(t[params["layout"]](f)) + local frame = unitRect:fromUnitRect(max) + win:setFrame(frame) + -- win:focus() end) hs.loadSpoon("ReloadConfiguration") diff --git a/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/icon.png b/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/icon.png new file mode 100644 index 0000000..2ddc88a Binary files /dev/null and b/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/icon.png differ diff --git a/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/info.plist b/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/info.plist new file mode 100644 index 0000000..ec64606 --- /dev/null +++ b/Alfred.alfredpreferences/workflows/user.workflow.009A9FEA-698A-48E3-A5E9-E3C8C422CC6A/info.plist @@ -0,0 +1,257 @@ + + + + + bundleid + dev.kejadlen.hammerspoon + category + Tools + connections + + 3B186D08-EE0B-478D-94CF-DA1E9EBDA477 + + + destinationuid + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 64E1CBFD-F669-470E-AF5D-A4C8E53A06E9 + + + destinationuid + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + modifiers + 0 + modifiersubtext + + vitoclose + + + + B179BB0D-FB64-4011-A70E-83A5530A4C19 + + + destinationuid + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + modifiers + 0 + modifiersubtext + + vitoclose + + + + B435EAE0-B272-46D0-986C-EB80EB34BD10 + + + destinationuid + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + modifiers + 0 + modifiersubtext + + vitoclose + + + + + createdby + Alpha Chen + description + + disabled + + name + hammerspoon + objects + + + config + + argumenttype + 0 + keyword + wm + subtext + + text + hammerspoon window manager + withspace + + + type + alfred.workflow.input.keyword + uid + B435EAE0-B272-46D0-986C-EB80EB34BD10 + version + 1 + + + config + + browser + org.hammerspoon.Hammerspoon + spaces + + url + hammerspoon://wm?layout={query} + utf8 + + + type + alfred.workflow.action.openurl + uid + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + version + 1 + + + config + + action + 0 + argument + 3 + argumenttext + left + focusedappvariable + + focusedappvariablename + + hotkey + 123 + hotmod + 12320768 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3B186D08-EE0B-478D-94CF-DA1E9EBDA477 + version + 2 + + + config + + action + 0 + argument + 3 + argumenttext + right + focusedappvariable + + focusedappvariablename + + hotkey + 124 + hotmod + 12320768 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 64E1CBFD-F669-470E-AF5D-A4C8E53A06E9 + version + 2 + + + config + + action + 0 + argument + 3 + argumenttext + max + focusedappvariable + + focusedappvariablename + + hotkey + 6 + hotmod + 1835008 + hotstring + Z + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + B179BB0D-FB64-4011-A70E-83A5530A4C19 + version + 2 + + + readme + + uidata + + 01F0EFEF-6E0E-4B8F-8A96-25E48B5BF995 + + xpos + 365 + ypos + 35 + + 3B186D08-EE0B-478D-94CF-DA1E9EBDA477 + + xpos + 35 + ypos + 145 + + 64E1CBFD-F669-470E-AF5D-A4C8E53A06E9 + + xpos + 35 + ypos + 255 + + B179BB0D-FB64-4011-A70E-83A5530A4C19 + + xpos + 35 + ypos + 365 + + B435EAE0-B272-46D0-986C-EB80EB34BD10 + + xpos + 35 + ypos + 35 + + + webaddress + https://github.com/kejadlen/hammerspoon.alfredworkflow + +