nixos/home/scripts/caffeine.nix
2024-03-14 00:10:13 +01:00

21 lines
617 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.hypridle}/bin/hypridle &
${pkgs.libnotify}/bin/notify-send "󰾪 Caffeine Deactivated"
else
touch /tmp/caffeine
pkill hypridle && ${pkgs.libnotify}/bin/notify-send "󰅶 Caffeine Activated"
fi
'';
in { home.packages = with pkgs; [ caffeine-status caffeine ]; }