aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatasha Moongrave <natasha@256phi.eu>2026-04-07 13:20:28 +0200
committerNatasha Moongrave <natasha@256phi.eu>2026-04-07 13:20:28 +0200
commite6911dff476b28485bee31e6b29a71f8cbf81d53 (patch)
tree623f73f4d46f4ff7c04b4f2bedd6bae7adb5c240
parent8dc55a9120a6f12a3ea34d4adddc150f6e40d674 (diff)
Added dunst configuration for notification handling
-rw-r--r--home/rices/nord-blue/dunst.nix101
1 files changed, 101 insertions, 0 deletions
diff --git a/home/rices/nord-blue/dunst.nix b/home/rices/nord-blue/dunst.nix
new file mode 100644
index 0000000..5516f55
--- /dev/null
+++ b/home/rices/nord-blue/dunst.nix
@@ -0,0 +1,101 @@
+{ config, pkgs, lib, ... }:
+
+let
+ vars = import ./variables.nix;
+
+ # Battery notification script
+ batteryNotify = pkgs.writeShellScriptBin "battery-notify" ''
+ #!/bin/sh
+
+ # Get battery status
+ BATTERY_PATH="/sys/class/power_supply/BAT0"
+
+ if [ ! -d "$BATTERY_PATH" ]; then
+ # Try BAT1 if BAT0 doesn't exist
+ BATTERY_PATH="/sys/class/power_supply/BAT1"
+ if [ ! -d "$BATTERY_PATH" ]; then
+ exit 0
+ fi
+ fi
+
+ CAPACITY=$(cat "$BATTERY_PATH/capacity")
+ STATUS=$(cat "$BATTERY_PATH/status")
+
+ # Critical threshold (5%)
+ if [ "$CAPACITY" -le 5 ] && [ "$STATUS" != "Charging" ]; then
+ ${pkgs.libnotify}/bin/notify-send -u critical "Battery Critical" "Battery level: $CAPACITY%\nPlease plug in charger immediately!"
+ # Low threshold (15%)
+ elif [ "$CAPACITY" -le 15 ] && [ "$STATUS" != "Charging" ]; then
+ ${pkgs.libnotify}/bin/notify-send -u normal "Battery Low" "Battery level: $CAPACITY%\nConsider plugging in charger soon."
+ fi
+ '';
+
+in {
+ home.packages = [ batteryNotify ];
+
+ services.dunst = {
+ enable = true;
+
+ settings = {
+ global = {
+ width = "(200,300)";
+ height = "(0,150)";
+ offset = "(30,50)";
+ origin = "bottom-right";
+ transparency = 10;
+ frame_width = 2;
+ font = "JetBrainsMono Nerd Font 10";
+ corner_radius = 8;
+ gap_size = 5;
+ };
+
+ urgency_low = {
+ background = vars.colors.background;
+ foreground = vars.colors.foreground;
+ timeout = 8;
+ };
+
+ urgency_normal = {
+ background = vars.colors.background;
+ foreground = vars.colors.foreground;
+ frame_color = vars.colors.accent;
+ timeout = 10;
+ };
+
+ urgency_critical = {
+ background = vars.colors.background;
+ foreground = vars.colors.foreground;
+ frame_color = vars.colors.alert;
+ timeout = 0; # Don't auto-dismiss critical notifications
+ };
+ };
+ };
+
+ # Systemd service to check battery periodically
+ systemd.user.services.battery-notify = {
+ Unit = {
+ Description = "Battery level notification service";
+ };
+
+ Service = {
+ Type = "oneshot";
+ ExecStart = "${batteryNotify}/bin/battery-notify";
+ };
+ };
+
+ # Timer to run battery check every 2 minutes
+ systemd.user.timers.battery-notify = {
+ Unit = {
+ Description = "Battery level notification timer";
+ };
+
+ Timer = {
+ OnBootSec = "1min";
+ OnUnitActiveSec = "2min";
+ };
+
+ Install = {
+ WantedBy = [ "timers.target" ];
+ };
+ };
+}