From 68813f3af767b602c8333933bd411d36301260a8 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Tue, 11 Jun 2024 23:45:00 +0100
Subject: [PATCH] Fix battery notifications

---
 CHANGELOG.md                              | 4 ++++
 bin/{notify-battery.sh => notify-battery} | 1 +
 lib/nixos/configuration.nix               | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
 rename bin/{notify-battery.sh => notify-battery} (98%)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e267612c..79b0aad9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,10 @@ Instead of grouping changes by tag, they are grouped by the date they are releas
 - Updated background colour in the tmux status bar.
 - Switch from NixOS unstable to 24.05.
 
+### Fixed
+
+- Fix battery and charging notifications.
+
 ## 10th June 2024
 
 ### Updated
diff --git a/bin/notify-battery.sh b/bin/notify-battery
similarity index 98%
rename from bin/notify-battery.sh
rename to bin/notify-battery
index e6297f4c..e9e77b4c 100755
--- a/bin/notify-battery.sh
+++ b/bin/notify-battery
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
 
+set -o errexit
 set -o nounset
 set -o pipefail
 
diff --git a/lib/nixos/configuration.nix b/lib/nixos/configuration.nix
index 8c982db1..8b606680 100644
--- a/lib/nixos/configuration.nix
+++ b/lib/nixos/configuration.nix
@@ -329,7 +329,7 @@ in
   services.cron = {
     enable = true;
 
-    systemCronJobs = [ "* * * * * opdavies /home/opdavies/.config/bin/notify-battery.sh" ];
+    systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
   };
 
   services.auto-cpufreq.enable = true;