SHARE
TWEET

SteamChatHighlighter

Interknet Nov 8th, 2019 (edited) 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. ## Run script on startup. Set it and forget it.
  3. ## Made by MoistGoat#2305
  4. ## Source: https://pastebin.com/bjyqPgku
  5. ## Only works for old UI sadly. Screw you valve.
  6.  
  7. if command -v wmctrl >/dev/null 2>&1 ; then
  8.     while :;do
  9.         sleep 5s ## Checks if Steam is running every 5 seconds
  10.         ChatGrabbed=0
  11.         SteamPID=$(cat $HOME/.steam/steam.pid)
  12.         Running=$(ps -p $SteamPID | grep -wo $SteamPID)
  13.         if [ "$SteamPID" == "$Running" ]; then ## If Steam is running, check ids and grab 'em.
  14.             while [ "$ChatGrabbed" == "0" ]; do
  15.                 sleep 1s ## Just to prevent high memory usage if chat window isn't grabbed yet
  16.                 listids=$(wmctrl -l | grep N/A | cut -f1 -d' ')
  17.                 readarray -t array < <(printf '%s\n' $listids)
  18.                 for ((i=0; i<${#array[@]}; i++)); do
  19.                     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.
  20.                         WindowID=$(echo ${array[i]})
  21.                         ChatGrabbed=1
  22.                     fi
  23.                 done
  24.             done
  25.         fi
  26.         while [ "$SteamPID" == "$Running" ]; do ## If Steam is actually running, keep an eye on the log file.
  27.             tail -fn0 --pid=$$ "/tmp/dumps/"$USER"_stdout.txt" | egrep -q "WebChat.SetNumChatsWithUnreadPriorityMessage|Shutdown" ## Waits for match
  28.             Date=$(date "+[%Y-%m-%d %H:%M:%S]")
  29.             if [[ $(cat "/tmp/dumps/"$USER"_stdout.txt" | grep "Shutdown" | tail -1) == "$Date Shutdown" ]]; then
  30.                 Running=0 ## If Exiting found, then wait until script sees Steam running to prevent issues
  31.                 ChatGrabbed=0
  32.             else
  33.                 wmctrl -F -ir $WindowID -b add,demands_attention ## Highlights the window :)
  34.             fi
  35.         done
  36.     done
  37. else
  38.     echo "wmctrl not installed. Please install it for this script to work!"
  39.     notify-send -a "Steam Chat Highlighter" "Wmctrl not installed!" -t 0
  40. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top