Last active
August 30, 2025 09:07
-
-
Save Dregu/97d39bb78cb75db4aa6ee39530d9d02b to your computer and use it in GitHub Desktop.
Tag Hyprland windows with their process name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Allows you to use process names in windowrules when the class and title are useless, e.g. spotify miniplayer | |
# exec-once = ~/.config/scripts/hypr-tagwindows | |
# windowrule = forcergbx, tag:spotify, floating:1 | |
function handle { | |
if [[ "$1" =~ "openwindow>>" ]]; then | |
read -d, ADDR WS CLASS TITLE <<< $(echo "$1" | cut -f3 -d">") | |
PID=$(hyprctl -j clients | jq -r --arg ADDR 0x$ADDR '.[] | select(.address == $ADDR).pid') | |
if [ ! -z $PID ]; then | |
PROC=$(ps -p $PID -o comm=) | |
if [ ! -z $PROC ]; then | |
hyprctl -q dispatch tagwindow $PROC address:0x$ADDR | |
fi | |
fi | |
fi | |
} | |
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