diff --git a/flake.lock b/flake.lock index fea37482..3f37937e 100644 --- a/flake.lock +++ b/flake.lock @@ -169,6 +169,22 @@ "type": "github" } }, + "miro": { + "flake": false, + "locked": { + "lastModified": 1644177791, + "narHash": "sha256-t8L6UboaOcg6JkGjX1NTd13Yw7ATySGxmnkJ7wUyZAE=", + "owner": "miromannino", + "repo": "miro-windows-manager", + "rev": "faa6f5f0bc025cc2465f3198609d2123d86101c2", + "type": "github" + }, + "original": { + "owner": "miromannino", + "repo": "miro-windows-manager", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": [ @@ -365,6 +381,7 @@ "emacs-overlay": "emacs-overlay", "home-manager": "home-manager", "impermanence": "impermanence", + "miro": "miro", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "nixpkgs-darwin": "nixpkgs-darwin", @@ -375,6 +392,7 @@ "pandoc-latex-template": "pandoc-latex-template", "private": "private", "rnix-lsp": "rnix-lsp", + "spoons": "spoons", "utils": "utils_2", "x": "x", "xynoblog": "xynoblog", @@ -383,6 +401,22 @@ "zsh-vim-mode": "zsh-vim-mode" } }, + "spoons": { + "flake": false, + "locked": { + "lastModified": 1667424431, + "narHash": "sha256-ShfiwQluh89aFmqSKL4Q5X9BECm3qP6jreYGIV0Qb/g=", + "owner": "Hammerspoon", + "repo": "Spoons", + "rev": "b36b6f6c654b787be11b6acde1f9ec4fcd217669", + "type": "github" + }, + "original": { + "owner": "Hammerspoon", + "repo": "Spoons", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1656928814, diff --git a/flake.nix b/flake.nix index 092adbd0..9ce24c97 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,13 @@ agkozak-zsh-prompt.url = "github:agkozak/agkozak-zsh-prompt"; agkozak-zsh-prompt.flake = false; + ## hammerspoon + miro.url = "github:miromannino/miro-windows-manager"; + miro.flake = false; + spoons.url = "github:Hammerspoon/Spoons"; + spoons.flake = false; + + #other dependencies pandoc-latex-template.url = "github:Wandmalfarbe/pandoc-latex-template"; diff --git a/hosts/daedalus/default.nix b/hosts/daedalus/default.nix index a71257f0..307169e5 100644 --- a/hosts/daedalus/default.nix +++ b/hosts/daedalus/default.nix @@ -66,6 +66,8 @@ in pkgs.substituteAll { src = ./hammerspoon.lua; inherit notmuchMails; }; + home.file.".hammerspoon/Spoons/MiroWindowsManager.spoon".source = "${inputs.miro}/MiroWindowsManager.spoon"; + home.file.".hammerspoon/Spoons/MusicAppMediaFix.spoon".source = "${inputs.spoons}/Source/MusicAppMediaFix.spoon"; home.file.".finicky.js".source = ./finicky.js; programs.home-manager.enable = true; diff --git a/hosts/daedalus/hammerspoon.lua b/hosts/daedalus/hammerspoon.lua index 8bb36113..81163790 100644 --- a/hosts/daedalus/hammerspoon.lua +++ b/hosts/daedalus/hammerspoon.lua @@ -55,28 +55,28 @@ local usbDevice = { local function languageIsGerman() return hs.host.locale.preferredLanguages()[1]:sub(0, 2) == "de" end -local function maximizeCurrentWindow() hs.window.focusedWindow():maximize() end - +-- local function maximizeCurrentWindow() hs.window.focusedWindow():maximize() end +-- local function centerCurrentWindow() hs.window.focusedWindow():centerOnScreen() end - -local function moveCurrentWindowToLeftHalf() - local win = hs.window.focusedWindow() - local screenFrame = win:screen():frame() - local newFrame = hs.geometry.rect(screenFrame.x, screenFrame.y, screenFrame.w / 2, screenFrame.h) - win:setFrame(newFrame) -end - -local function moveCurrentWindowToRightHalf() - local win = hs.window.focusedWindow() - local screenFrame = win:screen():frame() - local newFrame = hs.geometry.rect(screenFrame.x + screenFrame.w / 2, screenFrame.y, screenFrame.w / 2, screenFrame.h) - win:setFrame(newFrame) -end - -local function moveCurentWindowToNextScreen() - local win = hs.window.focusedWindow() - win:moveToScreen(win:screen():next()) -end +-- +-- local function moveCurrentWindowToLeftHalf() +-- local win = hs.window.focusedWindow() +-- local screenFrame = win:screen():frame() +-- local newFrame = hs.geometry.rect(screenFrame.x, screenFrame.y, screenFrame.w / 2, screenFrame.h) +-- win:setFrame(newFrame) +-- end +-- +-- local function moveCurrentWindowToRightHalf() +-- local win = hs.window.focusedWindow() +-- local screenFrame = win:screen():frame() +-- local newFrame = hs.geometry.rect(screenFrame.x + screenFrame.w / 2, screenFrame.y, screenFrame.w / 2, screenFrame.h) +-- win:setFrame(newFrame) +-- end +-- +-- local function moveCurentWindowToNextScreen() +-- local win = hs.window.focusedWindow() +-- win:moveToScreen(win:screen():next()) +-- end local function moveMouseToWindowCenter() local windowCenter = hs.window.frontmostWindow():frame().center @@ -263,12 +263,24 @@ function showHideBundleId(bundleId) end end -hs.hotkey.bind(modifiers.window, hs.keycodes.map.left, moveCurrentWindowToLeftHalf) -hs.hotkey.bind(modifiers.window, hs.keycodes.map.right, moveCurrentWindowToRightHalf) -hs.hotkey.bind(modifiers.window, hs.keycodes.map.down, moveCurentWindowToNextScreen) -hs.hotkey.bind(modifiers.window, hs.keycodes.map["return"], maximizeCurrentWindow) +-- hs.hotkey.bind(modifiers.window, hs.keycodes.map.left, moveCurrentWindowToLeftHalf) +-- hs.hotkey.bind(modifiers.window, hs.keycodes.map.right, moveCurrentWindowToRightHalf) +-- hs.hotkey.bind(modifiers.window, hs.keycodes.map.down, moveCurentWindowToNextScreen) +-- hs.hotkey.bind(modifiers.window, hs.keycodes.map["return"], maximizeCurrentWindow) hs.hotkey.bind(modifiers.window, "c", centerCurrentWindow) +hs.loadSpoon("MiroWindowsManager") +hs.window.animationDuration = 0 +spoon.MiroWindowsManager:bindHotkeys({ + up = {modifiers.window, "up"}, + right = {modifiers.window, "right"}, + down = {modifiers.window, "down"}, + left = {modifiers.window, "left"}, + fullscreen = {modifiers.window, "return"}, + nextscreen = {modifiers.hyper, "right"} +}) + + hs.hotkey.bind(modifiers.hyper, "[", moveMouseToWindowCenter) hs.hotkey.bind(modifiers.hyper, "m", moveMouseToUpperLeft) hs.hotkey.bind(modifiers.hyper, "o", moveMouseToUpperRight)