Extract binaries used in Niri & NWG Bar into variables

This commit is contained in:
Rei Meliesie 2026-09-15 15:40:21 +02:00
commit c9863fe93d

View file

@ -33,14 +33,34 @@
]; ];
}; };
etc = { etc = let
bluetoothctl = "${pkgs.bluez}/bin/bluetoothctl";
brightnessctl = "${pkgs.brightnessctl}/bin/brightnessctl";
busctl = "${pkgs.systemd}/bin/busctl";
emote = "${pkgs.emote}/bin/emote";
firefox = "${pkgs.firefox}/bin/firefox";
gnome-terminal = "${pkgs.gnome-terminal}/bin/gnome-terminal";
hyprlock = "${pkgs.hyprlock}/bin/hyprlock";
ironbar = "${pkgs.ironbar}/bin/ironbar";
loginctl = "${pkgs.systemd}/bin/loginctl";
nautilus = "${pkgs.nautilus}/bin/nautilus";
nmcli = "${pkgs.networkmanager}/bin/nmcli";
nwg-bar = "${pkgs.nwg-bar}/bin/nwg-bar";
pactl = "${pkgs.pulseaudio}/bin/pactl";
playerctl = "${pkgs.playerctl}/bin/playerctl";
rofi = "${pkgs.rofi}/bin/rofi";
swaybg = "${pkgs.swaybg}/bin/swaybg";
swayidle = "${pkgs.swayidle}/bin/swayidle";
systemctl = "${pkgs.systemd}/bin/systemctl";
wl-gammarelay-rs = "${pkgs.wl-gammarelay-rs}/bin/wl-gammarelay-rs";
wlr-randr = "${pkgs.wlr-randr}/bin/wlr-randr";
in {
"niri/config.kdl".text = '' "niri/config.kdl".text = ''
spawn-at-startup "${pkgs.swaybg}/bin/swaybg" "--image" \ spawn-at-startup "${swaybg}" "--image" \
"/home/rei/projects/infrastructure/nixos/assets/wallpaper-macos-swirlies" "/home/rei/projects/infrastructure/nixos/assets/wallpaper-macos-swirlies"
spawn-at-startup "${pkgs.ironbar}/bin/ironbar" spawn-at-startup "${ironbar}"
spawn-at-startup "${pkgs.wl-gammarelay-rs}/bin/wl-gammarelay-rs" spawn-at-startup "${wl-gammarelay-rs}"
spawn-at-startup "${pkgs.swayidle}/bin/swayidle" "timeout" "600" \ spawn-at-startup "${swayidle}" "timeout" "600" "${hyprlock}"
"${pkgs.hyprlock}/bin/hyprlock"
@ -97,71 +117,67 @@
binds { binds {
Super+Q { close-window; } Super+Q { close-window; }
Super+W { spawn "${pkgs.rofi}/bin/rofi" "-show" "drun"; } Super+W { spawn "${rofi}" "-show" "drun"; }
Super+E { spawn "${pkgs.gnome-terminal}/bin/gnome-terminal"; } Super+E { spawn "${gnome-terminal}"; }
Super+R { spawn "${pkgs.nautilus}/bin/nautilus"; } Super+R { spawn "${nautilus}"; }
Super+T { spawn "${pkgs.firefox}/bin/firefox"; } Super+T { spawn "${firefox}"; }
Super+Shift+T { spawn "${pkgs.firefox}/bin/firefox" "--private-window"; } Super+Shift+T { spawn "${firefox}" "--private-window"; }
Super+A { center-column; } Super+A { center-column; }
Super+S { switch-preset-column-width; } Super+S { switch-preset-column-width; }
Super+D { toggle-window-floating; } Super+D { toggle-window-floating; }
Super+U allow-when-locked=true { Super+U allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-volume" "@DEFAULT_SINK@" "-2%" spawn "${pactl}" "set-sink-volume" "@DEFAULT_SINK@" "-2%"
} }
Super+I allow-when-locked=true { Super+I allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-volume" "@DEFAULT_SINK@" "+2%" spawn "${pactl}" "set-sink-volume" "@DEFAULT_SINK@" "+2%"
} }
Super+Shift+I allow-when-locked=true { Super+Shift+I allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-volume" "@DEFAULT_SINK@" "100%" spawn "${pactl}" "set-sink-volume" "@DEFAULT_SINK@" "100%"
} }
Super+O allow-when-locked=true { Super+O allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle" spawn "${pactl}" "set-sink-mute" "@DEFAULT_SINK@" "toggle"
} }
Super+P allow-when-locked=true { Super+P allow-when-locked=true { spawn "${wlr-randr}" "--output" "eDP-1" "--toggle"; }
spawn "${pkgs.wlr-randr}/bin/wlr-randr" "--output" "eDP-1" "--toggle"
}
// TODO: Replace with toggle script. // TODO: Replace with toggle script.
Super+H { spawn "${pkgs.networkmanager}/bin/nmcli" "connection" "up" "airvpn-serbia"; } Super+H { spawn "${nmcli}" "connection" "up" "airvpn-serbia"; }
Super+Shift+H { Super+Shift+H { spawn "${nmcli}" "connection" "down" "airvpn-serbia"; }
spawn "${pkgs.networkmanager}/bin/nmcli" "connection" "down" "airvpn-serbia"
}
Super+J { spawn "${pkgs.emote}/bin/emote"; } Super+J { spawn "${emote}"; }
// TODO: Put this in linux-utils as Nix package. // TODO: Put this in linux-utils as Nix package.
// Super+K allow-when-locked=true { spawn "wl-gammarelay-toggle-temperature"; } // Super+K allow-when-locked=true { spawn "wl-gammarelay-toggle-temperature"; }
Super+K allow-when-locked=true { Super+K allow-when-locked=true {
spawn "${pkgs.systemd}/bin/busctl" "--user" "set-property" "rs.wl-gammarelay" "/" \ spawn "${busctl}" "--user" "set-property" "rs.wl-gammarelay" "/" "rs.wl.gammarelay" \
"rs.wl.gammarelay" "Temperature" "q" "4500" "Temperature" "q" "4500"
} }
Super+Shift+K allow-when-locked=true { Super+Shift+K allow-when-locked=true {
spawn "${pkgs.systemd}/bin/busctl" "--user" "set-property" "rs.wl-gammarelay" "/" \ spawn "${busctl}" "--user" "set-property" "rs.wl-gammarelay" "/" "rs.wl.gammarelay" \
"rs.wl.gammarelay" "Temperature" "q" "6500" "Temperature" "q" "6500"
} }
// TODO: Set up session-based locking like on Arch. // TODO: Set up session-based locking like on Arch.
// Super+L { spawn "${pkgs.systemd}/bin/loginctl" "lock-session"; } // Super+L { spawn "${loginctl}" "lock-session"; }
Super+L { spawn "${pkgs.hyprlock}/bin/hyprlock"; } Super+L { spawn "${hyprlock}"; }
// I.e. the Non-Screeching Earwarmers. // I.e. the Non-Screeching Earwarmers.
Super+B { spawn "${pkgs.bluez}/bin/bluetoothctl" "connect" "58:18:62:1F:E3:33"; } Super+B { spawn "${bluetoothctl}" "connect" "58:18:62:1F:E3:33"; }
Super+Shift+B { spawn "${pkgs.bluez}/bin/bluetoothctl" "disconnect" "58:18:62:1F:E3:33"; } Super+Shift+B { spawn "${bluetoothctl}" "disconnect" "58:18:62:1F:E3:33"; }
Super+M { spawn "${pkgs.playerctl}/bin/playerctl" "play-pause"; } Super+M { spawn "${playerctl}" "play-pause"; }
Super+Comma { spawn "${pkgs.playerctl}/bin/playerctl" "previous"; } Super+Comma { spawn "${playerctl}" "previous"; }
Super+Period { spawn "${pkgs.playerctl}/bin/playerctl" "next"; } Super+Period { spawn "${playerctl}" "next"; }
// TODO: Turn in to Nix package. // TODO: Turn into Nix package.
// Super+BracketLeft allow-when-locked=true { spawn "ddc-brightness" "down"; } // Super+BracketLeft allow-when-locked=true { spawn "ddc-brightness" "down"; }
// Super+BracketRight allow-when-locked=true { spawn "ddc-brightness" "up"; } // Super+BracketRight allow-when-locked=true { spawn "ddc-brightness" "up"; }
// Super+Shift+BracketRight allow-when-locked=true { spawn "ddc-brightness" "max"; } // Super+Shift+BracketRight allow-when-locked=true { spawn "ddc-brightness" "max"; }
Super+Tab { toggle-overview; } Super+Tab { toggle-overview; }
Super+Space { switch-layout "next"; } Super+Space { switch-layout "next"; }
Super+Escape { spawn "${pkgs.nwg-bar}/bin/nwg-bar"; } Super+Escape { spawn "${nwg-bar}"; }
Super+F11 { fullscreen-window; } Super+F11 { fullscreen-window; }
Super+Left { focus-column-left; } Super+Left { focus-column-left; }
@ -192,30 +208,24 @@
// TODO: Add back rectangle screenshot selection. // TODO: Add back rectangle screenshot selection.
Print { screenshot; } Print { screenshot; }
Super+Print { screenshot-window; } Super+Print { screenshot-window; }
// Special function keys.
XF86MonBrightnessDown allow-when-locked=true { XF86MonBrightnessDown allow-when-locked=true { spawn "${brightnessctl}" "set" "10%-"; }
spawn "${pkgs.brightnessctl}/bin/brightnessctl" "set" "10%-" XF86MonBrightnessUp allow-when-locked=true { spawn "${brightnessctl}" "set" "+10%"; }
}
XF86MonBrightnessUp allow-when-locked=true {
spawn "${pkgs.brightnessctl}/bin/brightnessctl" "set" "+10%"
}
XF86AudioLowerVolume allow-when-locked=true { XF86AudioLowerVolume allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-volume" "@DEFAULT_SINK@" "-2%" spawn "${pactl}" "set-sink-volume" "@DEFAULT_SINK@" "-2%"
} }
XF86AudioRaiseVolume allow-when-locked=true { XF86AudioRaiseVolume allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-volume" "@DEFAULT_SINK@" "+2%" spawn "${pactl}" "set-sink-volume" "@DEFAULT_SINK@" "+2%"
} }
XF86AudioMute allow-when-locked=true { XF86AudioMute allow-when-locked=true {
spawn "${pkgs.pulseaudio}/bin/pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle" spawn "${pactl}" "set-sink-mute" "@DEFAULT_SINK@" "toggle"
} }
XF86AudioPlay allow-when-locked=true { XF86AudioPlay allow-when-locked=true { spawn "${playerctl}" "play-pause"; }
spawn "${pkgs.playerctl}/bin/playerctl" "play-pause" XF86AudioPause allow-when-locked=true { spawn "${playerctl}" "play-pause"; }
}
XF86AudioPause allow-when-locked=true {
spawn "${pkgs.playerctl}/bin/playerctl" "play-pause"
}
} }
@ -240,7 +250,7 @@
"nwg-bar/bar.json".text = '' "nwg-bar/bar.json".text = ''
[ { [ {
"label": "_Lock", "label": "_Lock",
"exec": "${pkgs.systemd}/bin/loginctl lock-session", "exec": "${loginctl} lock-session",
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-lock-screen-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-lock-screen-symbolic.svg"
}, { }, {
"label": "Log out", "label": "Log out",
@ -248,19 +258,19 @@
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-log-out-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-log-out-symbolic.svg"
}, { }, {
"label": "_Suspend", "label": "_Suspend",
"exec": "${pkgs.systemd}/bin/systemctl suspend", "exec": "${systemctl} suspend",
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-suspend-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-suspend-symbolic.svg"
}, { }, {
"label": "_Hibernate", "label": "_Hibernate",
"exec": "${pkgs.systemd}/bin/systemctl hibernate", "exec": "${systemctl} hibernate",
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-suspend-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-suspend-symbolic.svg"
}, { }, {
"label": "Shut down", "label": "Shut down",
"exec": "${pkgs.systemd}/bin/systemctl poweroff", "exec": "${systemctl} poweroff",
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-shutdown-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-shutdown-symbolic.svg"
}, { }, {
"label": "Reboot", "label": "Reboot",
"exec": "${pkgs.systemd}/bin/systemctl reboot", "exec": "${systemctl} reboot",
"icon": "/usr/local/share/icons/kernelmaft/scalable/system-restart-symbolic.svg" "icon": "/usr/local/share/icons/kernelmaft/scalable/system-restart-symbolic.svg"
} ] } ]
''; '';