Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## Run script on startup. Set it and forget it.
- ## Made by MoistGoat#2305
- ## Source: https://pastebin.com/bjyqPgku
- ## Only works for old UI sadly. Screw you valve.
- if command -v wmctrl >/dev/null 2>&1 ; then
- while :;do
- sleep 5s ## Checks if Steam is running every 5 seconds
- ChatGrabbed=0
- SteamPID=$(cat $HOME/.steam/steam.pid)
- Running=$(ps -p $SteamPID | grep -wo $SteamPID)
- if [ "$SteamPID" == "$Running" ]; then ## If Steam is running, check ids and grab 'em.
- while [ "$ChatGrabbed" == "0" ]; do
- sleep 1s ## Just to prevent high memory usage if chat window isn't grabbed yet
- listids=$(wmctrl -l | grep N/A | cut -f1 -d' ')
- readarray -t array < <(printf '%s\n' $listids)
- for ((i=0; i<${#array[@]}; i++)); do
- if [[ $(xprop -id ${array[i]} | grep -wo "400 by 250") == "400 by 250" ]] && [[ $(xprop -id ${array[i]} | grep -wo "Steam" | head -1) == "Steam" ]]; then ## Finds which one is the chat window.
- WindowID=$(echo ${array[i]})
- ChatGrabbed=1
- fi
- done
- done
- fi
- while [ "$SteamPID" == "$Running" ]; do ## If Steam is actually running, keep an eye on the log file.
- tail -fn0 --pid=$$ "/tmp/dumps/"$USER"_stdout.txt" | egrep -q "WebChat.SetNumChatsWithUnreadPriorityMessage|Shutdown" ## Waits for match
- Date=$(date "+[%Y-%m-%d %H:%M:%S]")
- if [[ $(cat "/tmp/dumps/"$USER"_stdout.txt" | grep "Shutdown" | tail -1) == "$Date Shutdown" ]]; then
- Running=0 ## If Exiting found, then wait until script sees Steam running to prevent issues
- ChatGrabbed=0
- else
- wmctrl -F -ir $WindowID -b add,demands_attention ## Highlights the window :)
- fi
- done
- done
- else
- echo "wmctrl not installed. Please install it for this script to work!"
- notify-send -a "Steam Chat Highlighter" "Wmctrl not installed!" -t 0
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement