Skip to content

Instantly share code, notes, and snippets.

@aragaer
Created October 5, 2019 21:35
Show Gist options
  • Save aragaer/ed46ba7abb790072190686221f28fdf5 to your computer and use it in GitHub Desktop.
Save aragaer/ed46ba7abb790072190686221f28fdf5 to your computer and use it in GitHub Desktop.
obs status for xmobar
#!/bin/bash
LOGS=/home/aragaer/.config/obs-studio/logs/
get_status() {
result='---'
OBSPID=`ps ax | awk '\$5=="obs"{print \$1}'`
for pid in $OBSPID; do
file=`readlink -f /proc/$pid/fd/6`
if grep '==== Streaming St' "$file" | tail -1 | grep -q 'Streaming Start' ; then
result='LIVE'
break
fi
if grep '==== Recording St' "$file" | tail -1 | grep -q 'Recording Start' ; then
result='REC'
break
fi
done
echo $result
}
if [ "$1" = '--once' ] ; then
get_status
exit
fi
while :; do
get_status
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment