fix awatch, make it run as a service to avoid being killed by systemd
authorIan Kelling <ian@iankelling.org>
Fri, 3 Jan 2025 10:45:53 +0000 (05:45 -0500)
committerIan Kelling <ian@iankelling.org>
Fri, 3 Jan 2025 10:45:53 +0000 (05:45 -0500)
filesystem/usr/local/bin/awatch
primary-setup
subdir_files/.config/systemd/user/awatch.service [moved from subdir_files/.config/systemd/user/arbtt.service with 72% similarity]

index 5250c2027f6466bf3560f1fd79d3931a787bee39..a483b0b482b33bc1b4237e443f7888d4f72a533e 100755 (executable)
@@ -25,4 +25,4 @@ if [[ $EUID != 1000 ]]; then
   exit 1
 fi
 echo "awatch: $(date "+%F %T") starting" >>/home/iank/aw.log
-DISPLAY=:0 /a/opt/activity-watch/aw-qt &>>/home/iank/aw.log &
+DISPLAY=:0 /a/opt/activity-watch/aw-qt &>>/home/iank/aw.log
index b7b0585137300927382f251e9cfab448e2833ea6..5df41490623b6d124417adaebb5dc6766b598f78 100755 (executable)
@@ -99,12 +99,9 @@ if dpkg -s rss2email &>/dev/null; then
 fi
 
 if [[ $HOSTNAME == "$HOST2" ]]; then
-  if pgrep '^Xorg$'; then
-    m sudo -u iank /usr/local/bin/awatch
-  fi
+  m sudo -u iank XDG_RUNTIME_DIR=/run/user/1000 systemctl --no-block --user enable --now awatch.service ||:
 else
-  pkill -f '^/a/opt/activity-watch/aw-qt$' ||:
-  pkill -f '^/a/opt/activity-watch/aw-server/aw-server$' ||:
+  m sudo -u iank XDG_RUNTIME_DIR=/run/user/1000 systemctl --no-block --user disable --now awatch.service ||:
 fi
 
 
similarity index 72%
rename from subdir_files/.config/systemd/user/arbtt.service
rename to subdir_files/.config/systemd/user/awatch.service
index 26154dd904208dc6a2848ba05b1f4f4199c6cb11..7161b341b5404f8d7280f4e901d9875e7314d430 100644 (file)
@@ -1,15 +1,15 @@
 [Unit]
-Description=arbtt
+Description=awatch
 # StartLimitIntervalSec in recent systemd versions
 StartLimitInterval=0
 
 [Service]
 Type=simple
-ExecStart=/usr/bin/arbtt-capture --sample-rate=15
+ExecStart=/usr/local/bin/awatch
 Environment="DISPLAY=:0"
 Restart=always
 # time to sleep before restarting a service
-RestartSec=10
+RestartSec=120
 
 [Install]
 WantedBy=default.target