aboutsummaryrefslogtreecommitdiff
path: root/modules/desktop/hjem/wm
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-12-19 15:22:53 -0600
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-12-19 15:22:53 -0600
commit7fc4bb05905697e6a43fa3805da45768ea9a9858 (patch)
tree8d2857bb18ea5808f254e663f6da654313ab94b1 /modules/desktop/hjem/wm
parent5a5b183373c3732d96bb834b3ba0fcf2e88e590f (diff)
parentcdad26dfda64e94d19db576e93793ded9434bd09 (diff)
merge from main
Diffstat (limited to 'modules/desktop/hjem/wm')
-rw-r--r--modules/desktop/hjem/wm/default.nix147
-rw-r--r--modules/desktop/hjem/wm/dunst.nix27
-rw-r--r--modules/desktop/hjem/wm/fuzzel.nix28
-rw-r--r--modules/desktop/hjem/wm/niri.nix119
-rw-r--r--modules/desktop/hjem/wm/sway.nix10
5 files changed, 300 insertions, 31 deletions
diff --git a/modules/desktop/hjem/wm/default.nix b/modules/desktop/hjem/wm/default.nix
new file mode 100644
index 0000000..a5575ad
--- /dev/null
+++ b/modules/desktop/hjem/wm/default.nix
@@ -0,0 +1,147 @@
+{pkgs, ...}: {
+ files.".config/util.lua" = {
+ text = let
+ lua = pkgs.lua.withPackages (p: [p.lua-subprocess]);
+ in
+ # lua
+ ''
+ #!${lua}/bin/lua
+ local subprocess = require("subprocess")
+
+ local function get_volume()
+ local proc, err = subprocess.popen({
+ "wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@",
+ stdout = subprocess.PIPE,
+ stderr = subprocess.PIPE
+ })
+ if not proc then
+ error("Failed to run wpctl get-volume: " .. tostring(err))
+ end
+
+ local out = proc.stdout:read("*a") or ""
+ local _, _, code = proc:wait()
+ if (code or 0) ~= 0 then
+ local errout = proc.stderr and proc.stderr:read("*a") or ""
+ error(("wpctl get-volume failed (code %d): %s"):format(code, errout))
+ end
+
+ local num = out:match("^Volume:%s*([%d%.]+)")
+ if not num then
+ error("Unexpected wpctl output: " .. out)
+ end
+
+ return tonumber(num) * 100
+ end
+
+ local function notify_volume()
+ local ok, reason, code = subprocess.call({
+ "dunstify", "-t", "300",
+ "-h", "string:x-canonical-private-synchronous:audio",
+ "Volume:", "-h", "int:value:"..get_volume()
+ })
+ if not ok then
+ io.stderr:write(("dunstify failed (%s, code %s)\n"):format(reason or "?", code or "?"))
+ end
+ end
+
+ local function set_volume(vol)
+ local ok, reason, code = subprocess.call({
+ "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", vol
+ })
+ if not ok then
+ io.stderr:write(("wpctl set-volume failed (%s, code %s)\n"):format(reason or "?", code or "?"))
+ end
+ end
+
+ local function get_brightness()
+ local proc = subprocess.popen({
+ "${pkgs.brightnessctl}/bin/brightnessctl", "-e", "get",
+ stdout = subprocess.PIPE
+ })
+ if not proc then error("Failed to run brightnessctl get") end
+ local cur = tonumber(proc.stdout:read("*a"))
+ proc:wait()
+ if not cur then error("Failed to parse brightnessctl get output") end
+
+ local proc2 = subprocess.popen({
+ "${pkgs.brightnessctl}/bin/brightnessctl", "-e", "max",
+ stdout = subprocess.PIPE
+ })
+ if not proc2 then error("Failed to run brightnessctl max") end
+ local max = tonumber(proc2.stdout:read("*a"))
+ proc2:wait()
+ if not max or max == 0 then error("Failed to parse brightnessctl max output") end
+
+ return (cur / max) * 100
+ end
+
+ local function notify_brightness()
+ local ok, reason, code = subprocess.call({
+ "dunstify", "-t", "300",
+ "-h", "string:x-canonical-private-synchronous:brightness",
+ "Brightness", "-h", "int:value:"..get_brightness()
+ })
+ if not ok then
+ io.stderr:write(("dunstify failed (%s, code %s)\n"):format(reason or "?", code or "?"))
+ end
+ end
+
+ local function set_brightness(brightness)
+ local ok, reason, code = subprocess.call({
+ "${pkgs.brightnessctl}/bin/brightnessctl", "-e", "set", brightness
+ })
+ if not ok then
+ io.stderr:write(("brightnessctl set failed (%s, code %s)\n"):format(reason or "?", code or "?"))
+ end
+ end
+
+ local function list_music_players()
+ local proc = subprocess.popen({
+ "${pkgs.playerctl}/bin/playerctl", "-l",
+ stdout = subprocess.PIPE
+ })
+ if not proc then error("Failed to run playerctl -l") end
+
+ local cur = proc.stdout:lines()
+
+ local out = {}
+ for i in cur do
+ table.insert(out, i)
+ end
+
+ return out
+ end
+
+ local function toggle_music()
+ local ok, reason, code = subprocess.call({
+ "${pkgs.playerctl}/bin/playerctl", "play-pause",
+ })
+ if not ok then
+ io.stderr:write(("playerctl play-pause failed (%s, code %s)\n"):format(reason or "?", code or "?"))
+ end
+ end
+
+ -- main logic
+ if arg[2] and arg[2]:match("^(%d+)%%([%+%-])$") then
+ if arg[1] == "vol" then
+ set_volume(arg[2])
+ notify_volume()
+ elseif arg[1] == "brightness" then
+ set_brightness(arg[2])
+ notify_brightness()
+ else
+ error(("arg[2] '%s' incorrect format. Should look like 5%%+ or 10%%-"):format(tostring(arg[2])))
+ end
+ elseif arg[1] and arg[1] == "music" then
+ if arg[2] == "play" then
+ toggle_music()
+ else
+ error(("Invalid arg[2]: '%s'. should be `play`"):format(arg[3]))
+ end
+ else
+ error("Unknown command: " .. tostring(arg[1]))
+ end
+ '';
+ executable = true;
+ };
+}
diff --git a/modules/desktop/hjem/wm/dunst.nix b/modules/desktop/hjem/wm/dunst.nix
index 38a8240..9366975 100644
--- a/modules/desktop/hjem/wm/dunst.nix
+++ b/modules/desktop/hjem/wm/dunst.nix
@@ -4,30 +4,31 @@
pkgs,
...
}: let
- cfg = config.collinux.desktop.sway.components.dunst;
+ cfg = config.collinux.desktop.wm.components.dunst;
- settings = ''
+ settings = with config.collinux.palette; ''
[global]
- frame_color = "#89b4fa"
+ frame_color = "#ffffff00"
separator_color = frame
- highlight = "#89b4fa"
+
+ highlight = "#${base13}"
+
+ font = "Iosevka Nerd Font"
offset = "(8,8)"
origin = "top-right"
- transparency = 10
- font = "Iosevka Nerd Font"
[urgency_low]
- background = "#1e1e2e"
- foreground = "#cdd6f4"
+ background = "#${base00}99"
+ foreground = "#${base05}ff"
[urgency_normal]
- background = "#1e1e2e"
- foreground = "#cdd6f4"
+ background = "#${base00}99"
+ foreground = "#${base05}ff"
[urgency_critical]
- background = "#1e1e2e"
- foreground = "#cdd6f4"
- frame_color = "#fab387"
+ background = "#${base00}99"
+ foreground = "#${base05}ff"
+ frame_color = "#${base08}"
'';
in
lib.mkIf cfg.enable {
diff --git a/modules/desktop/hjem/wm/fuzzel.nix b/modules/desktop/hjem/wm/fuzzel.nix
index 7b9d075..ab11d6b 100644
--- a/modules/desktop/hjem/wm/fuzzel.nix
+++ b/modules/desktop/hjem/wm/fuzzel.nix
@@ -4,7 +4,7 @@
pkgs,
...
}: let
- cfg = config.collinux.desktop.sway.components.fuzzel;
+ cfg = config.collinux.desktop.wm.components.fuzzel;
settings = {
main = {
@@ -21,21 +21,21 @@
};
border = {
radius = 0;
- width = 2;
+ width = 3;
};
- colors = {
- background = "1e1e2edd";
- text = "cdd6f4ff";
- prompt = "bac2deff";
- placeholder = "7f849cff";
- input = "cdd6f4ff";
- match = "89b4faff";
- selection = "585b70ff";
- selection-text = "cdd6f4ff";
- selection-match = "89b4faff";
- counter = "7f849cff";
- border = "89b4faff";
+ colors = with config.collinux.palette; {
+ background = "${base00}99";
+ border = "ffffff00";
+ input = base05;
+ match = base13;
+ placeholder = base03;
+ text = base04;
+ prompt = base04;
+
+ selection = "${base01}5a";
+ selection-match = base13;
+ selection-text = base05;
};
};
in
diff --git a/modules/desktop/hjem/wm/niri.nix b/modules/desktop/hjem/wm/niri.nix
new file mode 100644
index 0000000..4449f82
--- /dev/null
+++ b/modules/desktop/hjem/wm/niri.nix
@@ -0,0 +1,119 @@
+{
+ pkgs,
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.collinux.desktop.wm.niri;
+in
+ lib.mkIf cfg.enable {
+ files.".config/niri/config.kdl".text = ''
+ spawn-sh-at-startup "${config.collinux.desktop.wallpaper_cmd}"
+ spawn-at-startup "${pkgs.playerctl}/bin/playerctld daemon"
+ spawn-at-startup "dunst"
+
+ prefer-no-csd
+ environment {
+ GTK_CSD "1"
+ }
+
+ output "eDP-1" {
+ scale 1.0
+ }
+
+ input {
+ focus-follows-mouse
+ }
+
+ hotkey-overlay {
+ skip-at-startup
+ hide-not-bound
+ }
+
+ binds {
+ Mod+Q { close-window; }
+
+ Mod+Space { spawn "fuzzel"; }
+ Mod+Return { spawn "foot"; }
+ Mod+B { spawn "firefox"; }
+
+ Mod+m { maximize-column; }
+
+ XF86MonBrightnessUp { spawn "~/.config/util.lua" "brightness" "5%+"; }
+ XF86MonBrightnessDown { spawn "~/.config/util.lua" "brightness" "5%-"; }
+ XF86AudioRaiseVolume { spawn "~/.config/util.lua" "vol" "5%+"; }
+ XF86AudioLowerVolume { spawn "~/.config/util.lua" "vol" "5%-"; }
+ }
+
+ gestures {
+ hot-corners {
+ off
+ }
+ }
+
+ overview {
+ zoom 0.66
+ workspace-shadow {
+ off
+ }
+ }
+
+ layout {
+ gaps 12
+
+ focus-ring {
+ off
+ }
+
+ border {
+ width 3
+ active-color "#ffffff00"
+ inactive-color "#ffffff00"
+ urgent-color "#ffffff00"
+ }
+
+ struts {
+ left 16
+ right 16
+ top 16
+ bottom 16
+ }
+
+ background-color "transparent"
+ }
+
+ layer-rule {
+ match namespace="^wallpaper$"
+ place-within-backdrop true
+ }
+
+ layer-rule {
+ match namespace="^launcher$"
+ shadow {
+ on
+ }
+ }
+
+ layer-rule {
+ match namespace="^notifications$"
+ shadow {
+ on
+ }
+ }
+
+ window-rule {
+ match app-id="firefox"
+ open-maximized true
+ }
+
+ window-rule {
+ match is-focused=true
+ shadow {
+ on
+ }
+ }
+
+ '';
+
+ packages = [pkgs.niri pkgs.xwayland-satellite];
+ }
diff --git a/modules/desktop/hjem/wm/sway.nix b/modules/desktop/hjem/wm/sway.nix
index 1cd7750..367cd0d 100644
--- a/modules/desktop/hjem/wm/sway.nix
+++ b/modules/desktop/hjem/wm/sway.nix
@@ -4,7 +4,7 @@
lib,
...
}: let
- cfg = config.collinux.desktop.sway;
+ cfg = config.collinux.desktop.wm.sway;
colors = ''
set $rosewater #f5e0dc
@@ -36,7 +36,6 @@
'';
settings = ''
- exec ${pkgs.foot}/bin/foot --server
exec ${pkgs.swaybg}/bin/swaybg -i ${config.collinux.desktop.wallpaper}
exec ${pkgs.dunst}/bin/dunst
@@ -74,13 +73,15 @@
bindsym Mod4+Shift+8 move container to workspace number 8
bindsym Mod4+Shift+9 move container to workspace number 9
- bindsym Mod4+Return exec ${pkgs.foot}/bin/footclient
- bindsym Mod4+Shift+Return exec ${pkgs.foot}/bin/foot
+ bindsym Mod4+Return exec ${pkgs.foot}/bin/foot
bindsym Mod4+Space exec ${pkgs.fuzzel}/bin/fuzzel
bindsym Mod4+b exec ${pkgs.firefox}/bin/firefox
bindsym Mod4+Shift+b exec ${pkgs.qutebrowser}/bin/qutebrowser
bindsym Mod4+q kill
+ bindsym Mod4+Shift+s exec '${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" ~/Pictures/$(date +"%s_grim.png")'
+ bindsym Mod4+Alt+s exec '${pkgs.hyprpicker}/bin/hyprpicker'
+
bindsym XF86AudioRaiseVolume exec 'wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+; dunstify -t 300 -h string:x-canonical-private-synchronous:audio "Volume: " -h "int:value:$(dec=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d\" \" -f2);echo "$dec * 100" | ${pkgs.bc}/bin/bc)"'
bindsym XF86AudioLowerVolume exec 'wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-; dunstify -t 300 -h string:x-canonical-private-synchronous:audio "Volume: " -h "int:value:$(dec=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d\" \" -f2);echo "$dec * 100" | ${pkgs.bc}/bin/bc)"'
@@ -106,5 +107,6 @@ in
sway
brightnessctl
playerctl
+ wl-clipboard
];
}