Skip to content

Instantly share code, notes, and snippets.

@Dregu
Created November 20, 2025 22:35
Show Gist options
  • Select an option

  • Save Dregu/e0704557866fc233dd10a9c14423c5c5 to your computer and use it in GitHub Desktop.

Select an option

Save Dregu/e0704557866fc233dd10a9c14423c5c5 to your computer and use it in GitHub Desktop.
hyprland socket2 bash example template thing
#!/bin/sh
function handle {
EVENT=${1%%\>\>*}
DATA=${1#*\>\>}
case $EVENT in
activewindow)
IFS=, read -r CLASS TITLE <<< "$DATA"
echo "Window focused | Class: $CLASS | Title: $TITLE"
;;
focusedmonv2)
IFS=, read -r MON WS <<< "$DATA"
echo "Monitor focused v2 | Monitor: $MON | Workspace: $WS"
;;
*)
echo "Unhandled event | Name: $EVENT | Data: $DATA"
;;
esac
}
socat -u unix-connect:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock stdout | while read -r line; do handle "$line"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment