We set up a systemd service and a watcher to reload it whenever the reminder file changes.
In ~/.config/user/systemd/reminder.service
:
[Unit]
Description=Reminder Server
[Service]
User=laurent
Type=simple
WorkingDirectory=/home/laurent/repos/reminder-server
ExecStart=/home/laurent/repos/reminder-server/run.sh
ExecReload=/bin/kill -HUP $MAINPID
EnvironmentFile=/home/laurent/.config/pushover.conf
[Service]
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
RestartSec=30
[Install]
WantedBy=default.target
A watch and watcher service
in reminder-watcher.service
:
[Unit]
Description=reminder restarter
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart reminder.service
[Install]
WantedBy=multi-user.target
and in reminder-watcher.path
:
[Path]
PathModified=/home/laurent/Documents/reminders.json
[Install]
WantedBy=multi-user.target
And the env file at ~/.config/pushover.conf
:
pushover_tok=xxx
pushover_key=xxx
reminders_file=xxx
Load everything
sudo systemctl enable ~/.config/systemd/user/reminder-watcher.path
sudo systemctl enable ~/.config/systemd/user/reminder.service
sudo systemctl start reminder.service
sudo systemctl start reminder-watcher.path
For example:
(package! pushreminders :recipe
(:fetcher github :repo "charignon/pushreminders" :files ("resources/pushreminders.el")))
(push "/home/laurent/.emacs.d/private/laurent" load-path)
(defun sync-reminders ()
(when (string= buffer-file-name "/home/laurent/reminders.org")
(laurent/do-sync-reminders)))
(add-hook 'after-save-hook #'sync-reminders)