hyprland.kak (1245B)
1 # https://hypr.land 2 provide-module hyprland %{ 3 4 # Ensure we're actually in Hyprland 5 evaluate-commands %sh{ 6 [ -z "${kak_opt_windowing_modules}" ] || 7 [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ] && 8 [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] || 9 echo 'fail hyprland not detected' 10 } 11 12 require-module 'wayland' 13 14 alias global hyprland-terminal-window wayland-terminal-window 15 16 define-command hyprland-focus-pid -hidden %{ 17 evaluate-commands %sh{ 18 pid=$kak_client_pid 19 while [ "$(hyprctl dispatch focuswindow pid:$pid)" != "ok" ]; do 20 pid=$(ps -p $pid -o ppid= | tr -d " ") 21 if [ -z $pid ] || [ $pid -le 1 ]; then 22 echo "fail Can't find PID for Sway window to focus" 23 break 24 fi 25 done 26 } 27 } 28 29 define-command hyprland-focus -params ..1 -docstring ' 30 hyprland-focus [<kakoune_client>]: focus a given client''s window. 31 If no client is passed, then the current client is used' \ 32 %{ 33 evaluate-commands %sh{ 34 if [ $# -eq 1 ]; then 35 printf "evaluate-commands -client '%s' hyprland-focus-pid" "$1" 36 else 37 echo hyprland-focus-pid 38 fi 39 } 40 } 41 complete-command -menu hyprland-focus client 42 43 alias global focus hyprland-focus 44 45 }