From fd6a627c11dff3389bd8112caba548aec3d28dee Mon Sep 17 00:00:00 2001 From: JuliaLange Date: Thu, 22 Feb 2024 23:57:21 -0800 Subject: [PATCH] Add timers for notifications in new services dir --- .gitignore | 1 + home.nix | 2 + services/timers/default.nix | 52 ++++++++++++++++++++++++++ services/timers/scripts/notify-time.sh | 5 +++ 4 files changed, 60 insertions(+) create mode 100644 .gitignore create mode 100644 services/timers/default.nix create mode 100755 services/timers/scripts/notify-time.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c22503 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/**/plugins/*.plugin.js diff --git a/home.nix b/home.nix index 93b4ce2..81a4957 100644 --- a/home.nix +++ b/home.nix @@ -23,6 +23,8 @@ ./programs/ssh ./programs/wal ./programs/xdg + + ./services/timers ]; home.packages = with pkgs; [ diff --git a/services/timers/default.nix b/services/timers/default.nix new file mode 100644 index 0000000..e47f3c9 --- /dev/null +++ b/services/timers/default.nix @@ -0,0 +1,52 @@ +{ config, pkgs, ... }: +let rootPath = ./.; in +{ + systemd.user.timers = { + hourly-time = { + Timer = { + OnCalendar = "hourly"; + }; + Install = { + WantedBy = [ + "timers.target" + ]; + }; + }; + quarterly-time = { + Timer = { + OnCalendar = "*-*-* *:15,30,45:00"; + }; + Install = { + WantedBy = [ + "timers.target" + ]; + }; + }; + }; + systemd.user.services = { + hourly-time = { + Unit = { + Description = "Notify the user every hour of time passing"; + }; + Service = { + Type="simple"; + ExecStart="/home/pan/.config/timer_scripts/notify-time.sh 60000"; + }; + }; + quarterly-time = { + Unit = { + Description = "Notify the user every 15 minutes of time passing, \ + skips hours"; + }; + Service = { + Type="simple"; + ExecStart="/home/pan/.config/timer_scripts/notify-time.sh 10000"; + }; + }; + }; + xdg.configFile."timer-scripts" = { + source = rootPath + "/scripts"; + target = "timer_scripts/"; + executable = true; + }; +} diff --git a/services/timers/scripts/notify-time.sh b/services/timers/scripts/notify-time.sh new file mode 100755 index 0000000..48df2fb --- /dev/null +++ b/services/timers/scripts/notify-time.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +export DISPLAY=":0" +export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" +/home/pan/.nix-profile/bin/notify-send "$(/run/current-system/sw/bin/date +%H:%M)" -t $1