Add caffeine

This commit is contained in:
Hadi 2024-03-14 00:10:13 +01:00
parent 8bda501d16
commit 13ae5ad530
3 changed files with 35 additions and 2 deletions

View File

@ -57,6 +57,13 @@ Themes and colors are managed by the `home/variable/theme` folder.
- `sound-output` - `sound-output`
- `sound-change <up/down/mute> <increment>` - `sound-change <up/down/mute> <increment>`
## Caffeine
Caffeine is a simple script that toggles the hypridle (disable suspend & screenlock).
- `caffeine` # Toggle caffeine
- `caffeine-status` # Return active/inactive
# Installation # Installation
```sh ```sh

20
home/scripts/caffeine.nix Normal file
View File

@ -0,0 +1,20 @@
{ 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 ]; }

View File

@ -1,4 +1,10 @@
{ {
imports = imports = [
[ ./scripts.nix ./nerdfetch.nix ./nixy.nix ./sounds.nix ./brightness.nix ]; ./scripts.nix
./nerdfetch.nix
./nixy.nix
./sounds.nix
./brightness.nix
./caffeine.nix
];
} }