diff --git a/home/default.nix b/home/default.nix index 2eebce3..4eeabd0 100644 --- a/home/default.nix +++ b/home/default.nix @@ -6,6 +6,7 @@ }: { imports = [ + ./lib ./programs ./tweaks ]; diff --git a/lib/colorScheme/buildColorScheme.nix b/home/lib/colorScheme/buildColorScheme.nix similarity index 100% rename from lib/colorScheme/buildColorScheme.nix rename to home/lib/colorScheme/buildColorScheme.nix diff --git a/lib/colorScheme/default.nix b/home/lib/colorScheme/default.nix similarity index 100% rename from lib/colorScheme/default.nix rename to home/lib/colorScheme/default.nix diff --git a/lib/colorScheme/matu2base16.py b/home/lib/colorScheme/matu2base16.py similarity index 100% rename from lib/colorScheme/matu2base16.py rename to home/lib/colorScheme/matu2base16.py diff --git a/lib/colorScheme/recolor.nix b/home/lib/colorScheme/recolor.nix similarity index 100% rename from lib/colorScheme/recolor.nix rename to home/lib/colorScheme/recolor.nix diff --git a/lib/colorScheme/recolor.py b/home/lib/colorScheme/recolor.py similarity index 100% rename from lib/colorScheme/recolor.py rename to home/lib/colorScheme/recolor.py diff --git a/home/lib/default.nix b/home/lib/default.nix new file mode 100644 index 0000000..3d14b29 --- /dev/null +++ b/home/lib/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./colorScheme + ./wallpaper + ./monitors.nix + ./swhkd.nix + ]; +} diff --git a/lib/monitors.nix b/home/lib/monitors.nix similarity index 100% rename from lib/monitors.nix rename to home/lib/monitors.nix diff --git a/home/lib/swhkd.nix b/home/lib/swhkd.nix new file mode 100644 index 0000000..ad886f6 --- /dev/null +++ b/home/lib/swhkd.nix @@ -0,0 +1,53 @@ +let + mkKeyBinding = + { + key, + command, + onRelease ? false, + swallow ? true, + }: + let + onReleasePrefix = if onRelease then "@" else ""; + swallowPrefix = if swallow then "" else "~"; + in + '' + ${onReleasePrefix}${swallowPrefix}${key} + ${command}''; + mkMode = + { + name, + swallow ? true, + oneoff ? false, + keyBindings, + }: + let + swallowStr = if swallow then "swallow" else ""; + oneoffStr = if oneoff then "oneoff" else ""; + in + '' + mode ${name} ${swallowStr} ${oneoffStr} + '' + + (map mkKeyBinding keyBindings |> builtins.concatStringsSep "\n") + + '' + \nendmode + ''; + mkSwhkdrc = + { + keyBindings, + includes ? [ ], + ignores ? [ ], + modes ? [ ], + extraConfig ? '''', + }: + ( + (map (file: "include ${file}") includes) + ++ (map (key: "ignore ${key}") ignores) + ++ (map mkKeyBinding keyBindings) + ++ (map mkMode modes) + |> builtins.concatStringsSep "\n" + ) + + extraConfig; +in +{ + config.lib.swhkd = { inherit mkSwhkdrc; }; +} diff --git a/lib/wallpaper/buildWallpaper.nix b/home/lib/wallpaper/buildWallpaper.nix similarity index 100% rename from lib/wallpaper/buildWallpaper.nix rename to home/lib/wallpaper/buildWallpaper.nix diff --git a/lib/wallpaper/default.nix b/home/lib/wallpaper/default.nix similarity index 100% rename from lib/wallpaper/default.nix rename to home/lib/wallpaper/default.nix diff --git a/lib/wallpaper/goNord.nix b/home/lib/wallpaper/goNord.nix similarity index 100% rename from lib/wallpaper/goNord.nix rename to home/lib/wallpaper/goNord.nix diff --git a/lib/wallpaper/lutgen.nix b/home/lib/wallpaper/lutgen.nix similarity index 100% rename from lib/wallpaper/lutgen.nix rename to home/lib/wallpaper/lutgen.nix diff --git a/home/programs/desktop/niri/swhkd.nix b/home/programs/desktop/niri/swhkd.nix index c84b612..d76108b 100644 --- a/home/programs/desktop/niri/swhkd.nix +++ b/home/programs/desktop/niri/swhkd.nix @@ -1,88 +1,48 @@ -{ user, ... }: +{ user, config, ... }: { - xdg.configFile."niri/swhkd/niri.swhkdrc".text = '' - include /home/${user}/.config/swhkd/basic.swhkdrc - include /home/${user}/.config/swhkd/tofi.swhkdrc - - super + shift + w - /home/${user}/scripts/change-wal-niri - - super + q - niri msg action close-window - - super + e - niri msg action expand-column-to-available-width - - super + t - niri msg action toggle-column-tabbed-display - - super + {left, down, up, right} - niri msg action focus-column-{left, down, up, right} - - super + {h, l} - niri msg action focus-column-or-monitor-{left, right} - - super + {j, k} - niri msg action focus-window-or-workspace-{down, up} - - super + shift + h - niri msg action move-column-left-or-to-monitor-left - - super + shift + l - niri msg action move-column-right-or-to-monitor-right - - super + shift + j - niri msg action move-window-down-or-to-workspace-down - - super + shift + k - niri msg action move-window-up-or-to-workspace-up - - super + ctrl + {left, down, up, right} - niri msg action focus-monitor-{left, down, up, right} - - super + ctrl + {h, j, k, l} - niri msg action focus-monitor-{left, down, up, right} - - super + shift + ctrl + {left, down, up, right} - niri msg action move-window-to-monitor-{left, down, up, right} - - super + shift + ctrl + {h, j, k, l} - niri msg action move-window-to-monitor-{left, down, up, right} - - super + shift + space - niri msg action toggle-window-floating - - super + space - niri msg action switch-focus-between-floating-and-tiling - - super + {_, shift +} {1-9} - niri msg action {focus\-workspace, move\-window\-to\-workspace} {1-9} - - super + comma - niri msg action consume-window-into-column - - super + period - niri msg action expel-window-from-column - - super + r - niri msg action switch-preset-column-width - - super + f - niri msg action maximize-column - - super + shift + f - niri msg action fullscreen-window - - super + c - niri msg action center-column - - super + {_, shift +} {minus, equal} - niri msg action set-{column\-width, window\-height} "{\-, +}10%" - - {ctrl +, alt +} print - niri msg action screenshot-{screen, window} - - print - niri msg action screenshot - ''; + xdg.configFile."niri/swhkd/niri.swhkdrc".text = config.lib.swhkd.mkSwhkdrc { + includes = [ + "/home/${user}/.config/swhkd/basic.swhkdrc" + "/home/${user}/.config/swhkd/tofi.swhkdrc" + ]; + keyBindings = + let + niriAction = key: action: { + inherit key; + command = "niri msg action ${action}"; + }; + in + [ + { + key = "super + shift + w"; + command = "/home/${user}/scripts/change-wal-niri"; + } + (niriAction "super + q" "close-window") + (niriAction "super + e" "expand-column-to-available-width") + (niriAction "super + t" "toggle-column-tabbed-display") + (niriAction "super + {left, down, up, right}" "focus-column-{left, down, up, right}") + (niriAction "super + {h, l}" "focus-column-or-monitor-{left, right}") + (niriAction "super + {j, k}" "focus-window-or-workspace-{down, up}") + (niriAction "super + shift + h" "move-column-left-or-to-monitor-left") + (niriAction "super + shift + l" "move-column-right-or-to-monitor-right") + (niriAction "super + shift + j" "move-window-down-or-to-workspace-down") + (niriAction "super + shift + k" "move-window-up-or-to-workspace-up") + (niriAction "super + ctrl + {left, down, up, right}" "focus-monitor-{left, down, up, right}") + (niriAction "super + ctrl + {h, j, k, l}" "focus-monitor-{left, down, up, right}") + (niriAction "super + shift + ctrl + {left, down, up, right}" "move-window-to-monitor-{left, down, up, right}") + (niriAction "super + shift + ctrl + {h, j, k, l}" "move-window-to-monitor-{left, down, up, right}") + (niriAction "super + shift + space" "toggle-window-floating") + (niriAction "super + space" "switch-focus-between-floating-and-tiling") + (niriAction "super + {_, shift +} {1-9}" "{focus-workspace, move-window-to-workspace} {1-9}") + (niriAction "super + comma" "consume-window-into-column") + (niriAction "super + period" "expel-window-from-column") + (niriAction "super + r" "switch-preset-column-width") + (niriAction "super + f" "maximize-column") + (niriAction "super + shift + f" "fullscreen-window") + (niriAction "super + c" "center-column") + (niriAction "super + {_, shift +} {minus, equal}" "set-{column-width, window-height} \"{\\-, +}10%\"") + (niriAction "{ctrl +, alt +} print" "screenshot-{screen, window}") + (niriAction "print" "screenshot") + ]; + }; } diff --git a/home/programs/desktop/niri/waybar.nix b/home/programs/desktop/niri/waybar.nix index cfa1595..c12519a 100644 --- a/home/programs/desktop/niri/waybar.nix +++ b/home/programs/desktop/niri/waybar.nix @@ -130,8 +130,6 @@ let }; in { - imports = [ ../../../../lib/monitors.nix ]; - programs.waybar = { enable = true; systemd = { diff --git a/home/programs/desktop/swhkd.nix b/home/programs/desktop/swhkd.nix index 70155a8..4f37035 100644 --- a/home/programs/desktop/swhkd.nix +++ b/home/programs/desktop/swhkd.nix @@ -1,36 +1,51 @@ -{ user, ... }: +{ user, config, ... }: { - - xdg.configFile."swhkd/basic.swhkdrc".text = '' - super + shift + r - pkill -HUP swhkd - - super + alt + c - wl-color-picker - - super + b - pkill -USR1 .waybar-wrapped - - XF86AudioMute - wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle - - XF86AudioMicMute - wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle - - XF86AudioRaiseVolume - wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ - - XF86AudioLowerVolume - wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1- - ''; - xdg.configFile."swhkd/tofi.swhkdrc".text = '' - super + x - /home/${user}/scripts/tofi/powermenu - - super + shift + c - /home/${user}/scripts/tofi/colorscheme - - super + {_, shift +} p - sh -c $(tofi-{run, drun}) - ''; + xdg.configFile."swhkd/basic.swhkdrc".text = config.lib.swhkd.mkSwhkdrc { + keyBindings = [ + { + key = "super + shift + r"; + command = "pkill -HUP swhkd"; + } + { + key = "super + alt + c"; + command = "wl-color-picker"; + } + { + key = "super + b"; + command = "pkill -USR1 .waybar-wrapped"; + } + { + key = "XF86AudioMute"; + command = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + } + { + key = "XF86AudioMicMute"; + command = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; + } + { + key = "XF86AudioRaiseVolume"; + command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+"; + } + { + key = "XF86AudioLowerVolume"; + command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; + } + ]; + }; + xdg.configFile."swhkd/tofi.swhkdrc".text = config.lib.swhkd.mkSwhkdrc { + keyBindings = [ + { + key = "super + x"; + command = "/home/${user}/scripts/tofi/powermenu"; + } + { + key = "super + shift + c"; + command = "/home/${user}/scripts/tofi/colorscheme"; + } + { + key = "super + {_, shift +} p"; + command = "sh -c $(tofi-{run, drun})"; + } + ]; + }; } diff --git a/hosts/default.nix b/hosts/default.nix index 21f3d78..1cce9dc 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -17,8 +17,6 @@ let ../home ../nix/nixpkgs.nix ../sharedConfig.nix - ../lib/colorScheme - ../lib/wallpaper inputs.nur.modules.homeManager.default inputs.stylix.homeManagerModules.stylix inputs.niri.homeModules.niri