eww-hypr-active-window-listener 732 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env zsh
  2. function get-titles-for-monitors {
  3. jq -c --null-input \
  4. --argjson 'monitors' "$(hyprctl -j monitors)" \
  5. --argjson 'workspaces' "$(hyprctl -j workspaces)" \
  6. '[$monitors.[].activeWorkspace.id as $active |
  7. $workspaces.[] | select(.id | IN($active))] |
  8. map({(.monitor): (if .lastwindowtitle == "" then "hyprland" else .lastwindowtitle end)}) | add'
  9. }
  10. function handle {
  11. case "${1}" in
  12. activewindow\>\>*|openwindow*|closewindow*)
  13. get-titles-for-monitors
  14. ;;
  15. esac
  16. }
  17. get-titles-for-monitors
  18. socat -U - "unix-connect:/tmp/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock" |
  19. while read line; do
  20. handle "${line}"
  21. done