mirror of
https://github.com/ItsDrike/nixdots
synced 2024-12-25 06:24:35 +00:00
Add toggle-idle script
This commit is contained in:
parent
b3f457340d
commit
083dc759d1
|
@ -36,6 +36,7 @@
|
||||||
# TODO: Requires programs
|
# TODO: Requires programs
|
||||||
"SUPER_SHIFT, L, exec, wlogout -p layer-shell"
|
"SUPER_SHIFT, L, exec, wlogout -p layer-shell"
|
||||||
"SUPER_CTRL, L, exec, loginctl lock-session"
|
"SUPER_CTRL, L, exec, loginctl lock-session"
|
||||||
|
"SUPER_SHIFT, T, exec, toggle-idle"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Screenshots
|
# Screenshots
|
||||||
|
|
|
@ -21,6 +21,7 @@ in {
|
||||||
hyprPkgs.quick-record
|
hyprPkgs.quick-record
|
||||||
hyprPkgs.toggle-fake-fullscreen
|
hyprPkgs.toggle-fake-fullscreen
|
||||||
hyprPkgs.toggle-notifications
|
hyprPkgs.toggle-notifications
|
||||||
|
hyprPkgs.toggle-idle
|
||||||
hyprPkgs.brightness
|
hyprPkgs.brightness
|
||||||
pkgs.brightnessctl
|
pkgs.brightnessctl
|
||||||
pkgs.hyprpicker
|
pkgs.hyprpicker
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
quick-record = pkgs.callPackage ./quick-record {};
|
quick-record = pkgs.callPackage ./quick-record {};
|
||||||
toggle-fake-fullscreen = pkgs.callPackage ./toggle-fake-fullscreen {};
|
toggle-fake-fullscreen = pkgs.callPackage ./toggle-fake-fullscreen {};
|
||||||
toggle-notifications = pkgs.callPackage ./toggle-notifications {};
|
toggle-notifications = pkgs.callPackage ./toggle-notifications {};
|
||||||
|
toggle-idle = pkgs.callPackage ./toggle-idle {};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
packages
|
packages
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
{pkgs, ...}:
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "toggle-idle";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
coreutils
|
||||||
|
gnugrep
|
||||||
|
procps
|
||||||
|
libnotify
|
||||||
|
hypridle
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
${builtins.readFile ./toggle-idle.sh}
|
||||||
|
'';
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
idleprog="hypridle" # or swayidle
|
||||||
|
|
||||||
|
pid="$(pidof "$idleprog" || true)"
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
# is process suspended?
|
||||||
|
if ps -o stat= -p "$pid" | grep T >/dev/null; then
|
||||||
|
kill -CONT "$pid"
|
||||||
|
notify-send "Idle-Toggle" "Idle timeouts enabled"
|
||||||
|
else
|
||||||
|
kill -STOP "$pid"
|
||||||
|
notify-send "Idle-Toggle" "Idle timeouts disabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
notify-send "Idle-Toggle" "$idleprog not running!"
|
||||||
|
fi
|
Loading…
Reference in a new issue