From 0ddc3ec50d4f36c7c034579717404fe7660aaab8 Mon Sep 17 00:00:00 2001 From: Nantha Sorubakanthan Date: Wed, 10 Jun 2026 20:06:56 +0200 Subject: refactor home.nix hyprland --- nixos/extra/bindings.lua | 52 +++++++++++++++++++++++++++ nixos/extra/env.lua | 8 +++++ nixos/extra/monitor.lua | 6 ++++ nixos/home.nix | 92 ++++++++++-------------------------------------- 4 files changed, 84 insertions(+), 74 deletions(-) create mode 100644 nixos/extra/bindings.lua create mode 100644 nixos/extra/env.lua create mode 100644 nixos/extra/monitor.lua diff --git a/nixos/extra/bindings.lua b/nixos/extra/bindings.lua new file mode 100644 index 0000000..3107b27 --- /dev/null +++ b/nixos/extra/bindings.lua @@ -0,0 +1,52 @@ +local terminal = "alacritty" +local browser = "firefox" +local menu = "hyprlauncher" + +hl.on("hyprland.start", function() + hl.exec_cmd("dunst") + hl.exec_cmd("sh ~/.local/bin/unblock-pipewire.sh") +end) +local mainMod = "SUPER" + +hl.bind(mainMod .. " + A", hl.dsp.window.fullscreen()) +hl.bind(mainMod .. " + C", hl.dsp.window.close()) +hl.bind(mainMod .. " + D", hl.dsp.exec_cmd("hyprpicker -naq")) +hl.bind(mainMod .. " + F", hl.dsp.exec_cmd(browser)) +hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit")) +hl.bind(mainMod .. " + M", hl.dsp.exec_cmd("command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch 'hl.dsp.exit()'")) +hl.bind(mainMod .. " + P", hl.dsp.window.pseudo()) +hl.bind(mainMod .. " + Q", hl.dsp.exec_cmd(terminal)) +hl.bind(mainMod .. " + return", hl.dsp.exec_cmd("~/.local/bin/spawn-alacritty-cwd")) +hl.bind(mainMod .. " + R", hl.dsp.exec_cmd(menu)) +hl.bind(mainMod .. " + V", hl.dsp.window.float({ action = "toggle" })) + +hl.bind(mainMod .. " + h", hl.dsp.focus({ direction = "left" })) +hl.bind(mainMod .. " + j", hl.dsp.focus({ direction = "right" })) +hl.bind(mainMod .. " + k", hl.dsp.focus({ direction = "up" })) +hl.bind(mainMod .. " + l", hl.dsp.focus({ direction = "down" })) + +hl.bind("print", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | wl-copy")) +hl.bind(mainMod .. " + print", hl.dsp.exec_cmd("grim - | wl-copy")) + +for i = 1, 10 do + local key = i % 11 + hl.bind(mainMod .. " + code:" .. key + 9, hl.dsp.focus({ workspace = i })) + hl.bind(mainMod .. " + SHIFT + code:" .. key + 9, hl.dsp.window.move({ workspace = i })) +end + +hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic")) +hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" })) + +hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true }) +hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true }) + +hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true }) +hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true, repeating = true }) +hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true, repeating = true }) +hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true }) +hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"), { locked = true, repeating = true }) +hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"), { locked = true, repeating = true }) +hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true }) +hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) +hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) +hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) diff --git a/nixos/extra/env.lua b/nixos/extra/env.lua new file mode 100644 index 0000000..17dbc96 --- /dev/null +++ b/nixos/extra/env.lua @@ -0,0 +1,8 @@ +hl.env("GDK_BACKEND", "wayland,x11,*") +hl.env("XDG_CURRENT_DESKTOP", "Hyprland") +hl.env("XDG_SESSION_TYPE", "wayland") +hl.env("XDG_SESSION_DESKTOP", "Hyprland") +hl.env("XCURSOR_THEME", "Bibata-Modern-Ice") +hl.env("XCURSOR_SIZE", 24) +hl.env("HYPRCURSOR_THEME", "Bibata-Modern-Ice") +hl.env("HYPRCURSOR_SIZE", 24) diff --git a/nixos/extra/monitor.lua b/nixos/extra/monitor.lua new file mode 100644 index 0000000..df9a972 --- /dev/null +++ b/nixos/extra/monitor.lua @@ -0,0 +1,6 @@ +if false then + hl.monitor({ output = "HDMI-A-1", mode = "2560x1440@100", position = "0x0", scale = "1", }) +else + hl.monitor({ output = "eDP-1", mode = "1920x1080@60", position = "0x0", scale = "1", }) + hl.monitor({ output = "HDMI-A-1", mode = "preferred", position = "auto", scale = "1", mirror = "eDP-1" }) +end diff --git a/nixos/home.nix b/nixos/home.nix index 34fb3a9..5937231 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -107,7 +107,6 @@ extensions.packages = with inputs.firefox-addons.packages.${pkgs.system}; [ ublock-origin ]; - search.default = "ddg"; }; }; @@ -130,7 +129,6 @@ spacing = 8; modules-left = [ "hyprland/workspaces" - "hyprland/window" ]; modules-center = []; modules-right = [ @@ -330,6 +328,7 @@ extraPackages = [ pkgs.nil pkgs.nixd + pkgs.lua-language-server ]; languages = { nix = { @@ -495,6 +494,23 @@ wayland.windowManager.hyprland = { enable = true; + plugins = [ + pkgs.hyprlandPlugins.hypr-dynamic-cursors + ]; + extraLuaFiles = { + "env" = { + content = ./extra/env.lua; + autoLoad = true; + }; + "bindings" = { + content = ./extra/bindings.lua; + autoLoad = true; + }; + "monitor" = { + content = ./extra/monitor.lua; + autoLoad = true; + }; + }; systemd = { enable = true; enableXdgAutostart = true; @@ -572,77 +588,5 @@ ]; mod._var = "SUPER"; }; - extraConfig = '' - if false then - hl.monitor({ output = "HDMI-A-1", mode = "2560x1440@100", position = "0x0", scale = "1", }) - else - hl.monitor({ output = "eDP-1", mode = "1920x1080@60", position = "0x0", scale = "1", }) - hl.monitor({ output = "HDMI-A-1", mode = "preferred", position = "auto", scale = "1", mirror = "eDP-1" }) - end - - - local terminal = "alacritty" - local browser = "firefox" - local menu = "hyprlauncher" - - hl.on("hyprland.start", function() - hl.exec_cmd("dunst") - hl.exec_cmd("sh ~/.local/bin/unblock-pipewire.sh") - end) - - hl.env("GDK_BACKEND", "wayland,x11,*") - hl.env("XDG_CURRENT_DESKTOP", "Hyprland") - hl.env("XDG_SESSION_TYPE", "wayland") - hl.env("XDG_SESSION_DESKTOP", "Hyprland") - hl.env("XCURSOR_THEME", "Bibata-Modern-Ice") - hl.env("XCURSOR_SIZE", 24) - hl.env("HYPRCURSOR_THEME", "Bibata-Modern-Ice") - hl.env("HYPRCURSOR_SIZE", 24) - - local mainMod = "SUPER" - - hl.bind(mainMod .. " + A", hl.dsp.window.fullscreen()) - hl.bind(mainMod .. " + C", hl.dsp.window.close()) - hl.bind(mainMod .. " + D", hl.dsp.exec_cmd("hyprpicker -naq")) - hl.bind(mainMod .. " + F", hl.dsp.exec_cmd(browser)) - hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit")) - hl.bind(mainMod .. " + M", hl.dsp.exec_cmd("command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch 'hl.dsp.exit()'")) - hl.bind(mainMod .. " + P", hl.dsp.window.pseudo()) - hl.bind(mainMod .. " + Q", hl.dsp.exec_cmd(terminal)) - hl.bind(mainMod .. " + return", hl.dsp.exec_cmd("~/.local/bin/spawn-alacritty-cwd")) - hl.bind(mainMod .. " + R", hl.dsp.exec_cmd(menu)) - hl.bind(mainMod .. " + V", hl.dsp.window.float({ action = "toggle" })) - - hl.bind(mainMod .. " + h", hl.dsp.focus({ direction = "left" })) - hl.bind(mainMod .. " + j", hl.dsp.focus({ direction = "right" })) - hl.bind(mainMod .. " + k", hl.dsp.focus({ direction = "up" })) - hl.bind(mainMod .. " + l", hl.dsp.focus({ direction = "down" })) - - hl.bind("print", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | wl-copy")) - hl.bind(mainMod .. " + print", hl.dsp.exec_cmd("grim - | wl-copy")) - - for i = 1, 10 do - local key = i % 11 - hl.bind(mainMod .. " + code:" .. key + 9, hl.dsp.focus({ workspace = i })) - hl.bind(mainMod .. " + SHIFT + code:" .. key + 9, hl.dsp.window.move({ workspace = i })) - end - - hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic")) - hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" })) - - hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true }) - hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true }) - - hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true }) - hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true, repeating = true }) - hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true, repeating = true }) - hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true }) - hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"), { locked = true, repeating = true }) - hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"), { locked = true, repeating = true }) - hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true }) - hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) - hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) - hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) - ''; }; } -- cgit v1.2.3