From 5d4ce7bfe37bfc7ce45045ede5b66e34e08ac9f1 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 28 Jan 2026 10:30:23 -0600 Subject: [PATCH] fixing some niri issues --- home/modules/niri.nix | 21 ++++++++++++++++++--- scripts/nirilof | 13 ++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/home/modules/niri.nix b/home/modules/niri.nix index f12bbb4..d095749 100644 --- a/home/modules/niri.nix +++ b/home/modules/niri.nix @@ -10,6 +10,21 @@ let systemctl --user restart syncthingtray systemctl --user restart nextcloud-client ''; + + nirilof = pkgs.writeShellScriptBin "nirilof" '' + + app=$1 + command=$2 + id=$(${pkgs.nushell}/bin/nu -c "niri msg --json windows | from json | where app_id == $app | get id | first") + + if [ $id -gt 0 ]; then + niri msg action focus-window --id $id + else + $command & disown + fi + + ''; + cosmic-extra-niri = pkgs.writeShellScriptBin "cosmic-extra-niri" '' set -e @@ -106,9 +121,9 @@ in "XF86MonBrightnessUp".action.spawn = ["brightnessctl" "s" "+10%"]; "XF86MonBrightnessDown".action.spawn = ["brightnessctl" "s" "10%-"]; "XF86AudioMute".action.spawn = ["pamixer" "-t"]; - "Super+E".action = spawn ["${pkgs.nushell}/bin/nu" "/home/chris/bin/niriemacslof"]; + "Super+E".action = spawn ["${nirilof}/bin/nirilof" "emacs" "emacsclient -c"]; "Super+Return".action.spawn = "alacritty"; - "Super+B".action = spawn ["${pkgs.nushell}/bin/nu" "/home/chris/bin/nirilof" "org.qutebrowser.qutebrowser" "qutebrowser"]; + "Super+B".action = spawn ["${nirilof}/bin/nirilof" "org.qutebrowser.qutebrowser" "qutebrowser"]; "Super+Alt+Space".action.spawn = "${pkgs.cosmic-launcher}/bin/cosmic-launcher"; "Super+Space".action.spawn = ["${pkgs.fish}/bin/fish" "-c" "rofi -no-lazy-grab -modi combi -show combi -combi-modi drun,run"]; "Super+Shift+W".action.spawn = ["rofi" "-i" "-show" "window"]; @@ -159,7 +174,7 @@ in { argv = ["swww-daemon"]; } { argv = ["rbw-agent"]; } { argv = ["kdeconnect-indicator"]; } - { argv = ["wl-paste --watch cliphist store"]; } + { argv = ["${pkgs.wl-clipboard}/bin/wl-paste --watch cliphist store"]; } { argv = ["swww img /home/chris/pics/wallpapers/tech.jpg --resize crop -t grow --transition-bezier .14,0,.14,.99"]; } { argv = ["${reset-dbus-systemd-units}/bin/reset-dbus-systemd"]; } ]; diff --git a/scripts/nirilof b/scripts/nirilof index 7ee49ce..e9586c6 100755 --- a/scripts/nirilof +++ b/scripts/nirilof @@ -1,15 +1,10 @@ #/usr/bin/env nu def main [app: string, command: string] { - let open = try { - niri msg --json windows | from json | where app_id == $app | get id | first - } catch { - 0 - } - - if $open > 0 { - niri msg action focus-window --id $open - } else { + let open = niri msg --json windows | from json | where app_id == $app | get id | first; + if open == null { bash -c $"($command) &" + } else { + niri msg action focus-window --id $open } }