Better time sampling
authorDan White <dan@whiteaudio.com>
Fri, 6 Jun 2014 16:59:37 +0000 (11:59 -0500)
committerDan White <dan@whiteaudio.com>
Fri, 6 Jun 2014 16:59:37 +0000 (11:59 -0500)
cleanup-timesamples
timeSampler

index e8e823b672d295a35a4fafa3b667ed6615e8a9ec..e31b03d665055741cbe09b9df231086ba2dd80c2 100755 (executable)
@@ -3,14 +3,18 @@
 # cleanup data from timeSampler,
 # removes null entries and sorts by time
 
-# -e edits before cleanup
+# no argument edits before cleanup
 # -E edits after cleanup
-if [ "$1" = "-e" ]; then
-    vim $HOME/.timeSampler.$HOSTNAME
+TMPFILE=$(tempfile)
+
+if [ "$1" = "" ]; then
+    orig="$HOME/.timeSampler.$HOSTNAME"
+    sort -u $orig > $TMPFILE
+    cp $TMPFILE $orig
+    vim $orig
     shift
 fi
 
-TMPFILE=$(tempfile)
 for f in $(ls -1 $HOME/.timeSampler.*); do
     grep -v "null$" $f | sort -u > $TMPFILE
     cp $TMPFILE $f
index 4777c4ad200a1ccb3e16c1eb90a520b2a42c95e0..2be7fe344678733572188d9608d8a7eafb4f1e0e 100755 (executable)
@@ -11,7 +11,7 @@
 #BEEP="beep -f707 -n -f500"
 #BEEP="beep -f707 -n -f500 -n -f707"
 #BEEP="dcop knotify default notify notify Me notext KDE_Vox_Ahem.ogg nofile 1 0"
-BEEP="aplay /usr/share/sounds/pop.wav"
+BEEP="aplay /home/dan/tmp/pop.wav"
 MINUTES=6 #to give 10/hour
 #MAXJOBS=$((1*60/$MINUTES))
 #MAXJOBS=8
@@ -19,6 +19,7 @@ MAXJOBS=17
 MAXJOBS=$(($MAXJOBS-1))
 
 LOGFILE="$HOME/.timeSampler.$HOSTNAME"
+BACKUPFILE="$HOME/.timeSampler.all"
 
 #put something in the buffer to start
 for i in $(seq 0 $MAXJOBS); do
@@ -50,6 +51,7 @@ function sampleTask {
     fi
 
     echo "$DATE $ACTIVITY" >> $LOGFILE
+    echo "$HOSTNAME $DATE $ACTIVITY" >> $BACKUPFILE
 }