diff options
author | Frankie B. <git@diskfloppy.me> | 2024-03-10 22:20:12 +0000 |
---|---|---|
committer | Frankie B. <git@diskfloppy.me> | 2024-03-10 22:20:12 +0000 |
commit | 3f341d9f5d03807e69ea20eb89bda6ad72e5a3d3 (patch) | |
tree | e9a404504e51b050bdf4125fec6be0ad9f59c5f1 | |
parent | 28933a66d279ca421bd5baee133c1b8caecdebaa (diff) |
Lid open/close binds
-rw-r--r-- | homes/floppydisk/hyprland.nix | 4 | ||||
-rwxr-xr-x | misc/scripts/lidclose.sh | 15 | ||||
-rwxr-xr-x | misc/scripts/lidopen.sh | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/homes/floppydisk/hyprland.nix b/homes/floppydisk/hyprland.nix index 0d39b50..89fede5 100644 --- a/homes/floppydisk/hyprland.nix +++ b/homes/floppydisk/hyprland.nix @@ -79,8 +79,8 @@ }; bindl = [ - ",switch:on:Lid Switch,exec,hyprctl keyword monitor LVDS-1, disable" - ",switch:off:Lid Switch,exec,hyprctl keyword monitor LVDS-1, 1600x900, 0x0, 1" + ",switch:on:Lid Switch,exec,${/. + ../../misc/scripts/lidclose.sh}" + ",switch:off:Lid Switch,exec,${/. + ../../misc/scripts/lidopen.sh}" ]; bindm = [ diff --git a/misc/scripts/lidclose.sh b/misc/scripts/lidclose.sh new file mode 100755 index 0000000..c3c2673 --- /dev/null +++ b/misc/scripts/lidclose.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Count the number of connected monitors +connected_monitors=$(xrandr | grep " connected " | wc -l) +# Check if more than one monitor is connected +if [ $connected_monitors -gt 1 ]; then + # Disable LVDS-1 + hyprctl keyword monitor LVDS-1, disable +else + # Send computer to sleep + swayidle -w \ + timeout 1800 'hyprctl dispatch dpms off' \ + resume 'hyprctl dispatch dpms on' \ + timeout 3600 'systemctl suspend' +fi diff --git a/misc/scripts/lidopen.sh b/misc/scripts/lidopen.sh new file mode 100755 index 0000000..0269352 --- /dev/null +++ b/misc/scripts/lidopen.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +hyprctl keyword monitor LVDS-1, preferred, auto, 1 |