Tracking Computer Activity with Beeminder: A Linux Automation Story

I just extended this setup to run before Debian goes to sleep.

/etc/systemd/system/pre-sleep.service:

   [Unit]
   Description=Run script before system sleeps
   Before=sleep.target
   StopWhenUnneeded=true

   [Service]
   Type=oneshot
   ExecStart=/home/username/.scripts/pre-sleep-script.sh

   [Install]
   WantedBy=sleep.target

/home/username/.scripts/pre-sleep-script.sh:

#!/bin/bash

source /home/username/.bashrc
/home/username/.scripts/post_active_time_to_beeminder.sh

Setup commands:

chmod +x /home/username/.scripts/pre-sleep-script.sh
sudo systemctl enable pre-sleep.service
1 Like