nixos/home/scripts/caffeine/default.nix
2024-05-04 22:51:33 +02:00

24 lines
775 B
Nix

{ pkgs, config, ... }:
let
homedir = config.home.homeDirectory;
caffeine-status = pkgs.writeShellScriptBin "caffeine-status" ''
[[ -f /tmp/caffeine ]] && echo "active" || echo "inactive"
'';
caffeine = pkgs.writeShellScriptBin "caffeine" ''
if [[ -f /tmp/caffeine ]]; then
rm /tmp/caffeine
${pkgs.hyprland}/bin/hyprctl dispatch exec ${pkgs.hypridle}/bin/hypridle
message="󰾪 Caffeine Deactivated"
else
touch /tmp/caffeine
pkill hypridle
message="󰅶 Caffeine Activated"
fi
${pkgs.libnotify}/bin/notify-send "$message" \
--replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification"
'';
in { home.packages = with pkgs; [ caffeine-status caffeine ]; }