Created
September 14, 2016 14:29
-
-
Save antonmry/a54b04f6a3536b98924255ae9fbe71d3 to your computer and use it in GitHub Desktop.
Thyme script with detect absent, autoupdate and web refresh
This file contains 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 | |
# Dependencies (Fedora) | |
# xprintidle: https://copr.fedorainfracloud.org/coprs/alonid/xprintidle/ | |
# wmctrl: dnf install wmctrl | |
# Config | |
LOGFILE="/home/antonmry/Documents/thyme/thyme_$(date '+%Y%m%d').log" | |
HTMLFILE="/home/antonmry/Documents/thyme/thyme_$(date '+%Y%m%d').html" | |
HTMLFILETEMP="/home/antonmry/Documents/thyme/thyme.html" | |
LIMITIDLE=5*60*1000 # 5 minutes | |
THYMEPOLLING=10 # 10 seconds | |
# Update thyme | |
GOPATH=~/Workspace/Galiglobal/go go get -u github.com/sourcegraph/thyme/cmd/thyme | |
# Launch thyme | |
echo "1" > ~/.thyme | |
while true | |
do | |
# Generate report | |
thyme track -o $LOGFILE | |
thyme show -i $LOGFILE -w stats > $HTMLFILE | |
sed '2a\ | |
<link rel="icon" href="https://www.rescuetime.com/favicon.ico" type="image/x-icon"/>' $HTMLFILE > $HTMLFILETEMP | |
# Detect absent | |
idle="$(xprintidle)" | |
if [[ "$idle" -gt "$LIMITIDLE" ]]; then | |
if [[ "$(cat ~/.thyme)" -gt "0" ]]; then | |
gnome-terminal -x sh -c 'sleep 1; wmctrl -r :ACTIVE: -N "Absent"; echo "0" > ~/.thyme; top; echo "1" > ~/.thyme' | |
echo "Time idle $idle" | |
fi | |
fi | |
sleep $THYMEPOLLING | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment