diff --git a/packages/quick-zeal/package.nix b/packages/quick-zeal/package.nix index 7efb1bd..3321e86 100644 --- a/packages/quick-zeal/package.nix +++ b/packages/quick-zeal/package.nix @@ -1,5 +1,6 @@ {pkgs, ...}: pkgs.writeShellApplication { name = "quick-zeal"; + runtimeInputs = [pkgs.harbor.active-window pkgs.jq]; text = builtins.readFile ./quick-zeal; } diff --git a/packages/quick-zeal/quick-zeal b/packages/quick-zeal/quick-zeal index aa76705..7cf2f8d 100755 --- a/packages/quick-zeal/quick-zeal +++ b/packages/quick-zeal/quick-zeal @@ -6,13 +6,14 @@ extract_major_version() { } # Detects the focused window and checks if it's Kitty -ACTIVE_WINDOW=$(hyprctl activewindow -j | jq -r '.class') +WINDOW=$(active-window) +ACTIVE_WINDOW=$(printf '%s' "$WINDOW" | jq -r '.class // empty') +PID=$(printf '%s' "$WINDOW" | jq -r '.pid // empty') # Check if the focused window is a Kitty terminal and if it's in a Git repository. # If so, determine the project type and open Zeal with the appropriate argument zeal_argument="" if [[ $ACTIVE_WINDOW == "kitty" ]]; then - PID=$(hyprctl activewindow -j | jq -r '.pid') CHILD_PID=$(pgrep -P "$PID" | tail -1) SHELL_CWD=$(readlink -f "/proc/${CHILD_PID}/cwd") diff --git a/packages/spawn-term/package.nix b/packages/spawn-term/package.nix index 49ee537..8b2edd3 100644 --- a/packages/spawn-term/package.nix +++ b/packages/spawn-term/package.nix @@ -1,25 +1,13 @@ {pkgs, ...}: pkgs.writeNushellApplication { name = "spawn-term"; - runtimeInputs = with pkgs; [kdotool]; + runtimeInputs = [pkgs.harbor.active-window]; text = '' - let compositor = $env.XDG_CURRENT_DESKTOP? | default "" - - let window_info = if ($compositor | str contains "niri") { - let focused_window = (niri msg --json focused-window | from json | get id?) - if ($focused_window | is-empty) { - { is_kitty: false, pid: null } - } else { - let info = (niri msg --json windows | from json | where id == $focused_window | first) - { is_kitty: ($info.app_id? == "kitty"), pid: $info.pid? } - } - } else { - let focused_window = (kdotool getactivewindow) - { - is_kitty: ((kdotool getwindowclassname $focused_window) == "kitty"), - pid: (kdotool getwindowpid $focused_window | into int) - } + let window = (active-window | from json) + let window_info = { + is_kitty: ($window.class? == "kitty"), + pid: $window.pid? } if $window_info.is_kitty {