You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/bin/focus_class

23 lines
555 B
Plaintext

#!/usr/bin/env bash
WM_DESKTOP=$(xdotool getwindowfocus)
if [[ $WM_DESKTOP == "4194404" ]] ; then
echo ""
else
WM_CLASS=$(xprop -id "$WM_DESKTOP" WM_CLASS | awk 'NF {print $NF}' | sed 's/"//g')
WM_NAME=$(xprop -id "$WM_DESKTOP" WM_NAME | cut -d '=' -f 2 | awk -F '"' '{print $2}')
# filtering
if [ "$WM_NAME" == "tmux" ] ; then
echo "tmux"
elif [ "$WM_CLASS" == "st-256color" ] ; then
echo "st"
elif [ "$WM_CLASS" == "Brave-browser" ] ; then
echo "Brave"
else
echo "$WM_NAME"
fi
fi