Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Bash script that pops-up notification with a bar graph of where you're spending your time on PC
Tags notification, procrastination, script
Preliminary but works, even though I'm probably doing some stuff wrong/dumbly. Basically, "if input is idle for less than two minutes, then grep the active window, if it's the same active window for two times in three 30-second time-windows, count it as active ; after looping N times, show a rudimentary bar graph of how many times each logged window was used."
It would be nicer to actually transform the counting of each program in a percentage of the total, but it's good enough for now.
No copyrights whatsoever and all that FOSS stuff. It depends at least on xprintidle, xdotool, and notify-send.
It would be nicer to actually transform the counting of each program in a percentage of the total, but it's good enough for now.
No copyrights whatsoever and all that FOSS stuff. It depends at least on xprintidle, xdotool, and notify-send.
Code:
#!/bin/bash log=/dev/shm/timespent.log while true ; do if (( $(xprintidle) < 30000 )) ; then win1=$( xdotool getactivewindow getwindowname | sed 's|.*\ -\ ||' ) sleep 30 win2=$( xdotool getactivewindow getwindowname | sed 's|.*\ -\ ||' ) sleep 30 win3=$( xdotool getactivewindow getwindowname | sed 's|.*\ -\ ||' ) if [[ "$win1" == "$win2" ]] ; then echo $win1 >> $log elif [[ "$win1" == "$win3" ]] ; then echo $win1 >> $log elif [[ "$win2" == "$win3" ]] ; then echo $ $win2 >> $ log fi loop=$((loop+1)) if ((loop==8)) ; then sed -ie 's|.*/|xterm-|g;s|xterm-.*|xterm|g' $log sort -u $log | while read prog ; do progcount=$(grep $prog $log | wc -l) if [[ -z "$parse" ]] ; then bar=$"$(for n in $(seq 1 $progcount) ; do printf "█" ; done)" parse="${prog}\t${bar}" else bar=$"$(for n in $(seq 1 $progcount) ; do printf "█" ; done)" parse="${parse}\n${prog}\t${bar}" fi echo $parse > /dev/shm/parse done notify-send "Time spent" "$(cat /dev/shm/parse)" -t 5000 loop=0 fi fi sleep 30 done
Total Comments 0