2024-10-20 16:34:59 +07:00
|
|
|
{ pkgs, ... }:
|
|
|
|
let
|
|
|
|
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
|
|
|
|
gojq = "${pkgs.gojq}/bin/gojq";
|
|
|
|
in
|
2024-10-21 12:31:30 +07:00
|
|
|
pkgs.writeShellScriptBin "focus-window.sh" # sh
|
|
|
|
''
|
|
|
|
appname="$SWAYNC_APP_NAME"
|
|
|
|
state="$(${hyprctl} -j clients)"
|
|
|
|
window="$(echo "$state" | ${gojq} -r --arg APP "$appname" '.[] | select(.class == $APP) | .address')"
|
2024-10-20 16:34:59 +07:00
|
|
|
|
2024-10-21 12:31:30 +07:00
|
|
|
if [[ "$window" != "" ]]; then
|
|
|
|
${hyprctl} dispatch focuswindow address:"$window"
|
|
|
|
fi
|
|
|
|
''
|