diff options
| author | kj_sh604 | 2025-11-09 18:53:25 -0500 |
|---|---|---|
| committer | kj_sh604 | 2025-11-09 18:53:25 -0500 |
| commit | f5e03894e96a9c652c39314a2575f52f9c47aac2 (patch) | |
| tree | 070c9be188abfa1bf6f1b3bca44f2c7fb86b1b80 /.local/bin/toggle-lid-switch-handling | |
| parent | 0e89adbd440b04e5432eb00614f654c9fed93687 (diff) | |
revert-to: a6675719f73a332f92c30ff5c4948cda26c0e6e3
Diffstat (limited to '.local/bin/toggle-lid-switch-handling')
| -rwxr-xr-x | .local/bin/toggle-lid-switch-handling | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/.local/bin/toggle-lid-switch-handling b/.local/bin/toggle-lid-switch-handling new file mode 100755 index 0000000..00eb45b --- /dev/null +++ b/.local/bin/toggle-lid-switch-handling @@ -0,0 +1,26 @@ +#!/bin/sh + +CONFIG_FILE="/etc/systemd/logind.conf" + +if [ ! -f "$CONFIG_FILE" ]; then + echo "Error: $CONFIG_FILE not found" + exit 1 +fi + +CURRENT_VALUE=$(grep "^HandleLidSwitch=" "$CONFIG_FILE" | cut -d "=" -f 2-) + +if [ -z "$CURRENT_VALUE" ]; then + sudo sed -i "s/#HandleLidSwitch=suspend/HandleLidSwitch=suspend/" "$CONFIG_FILE" + echo "HandleLidSwitch set to suspend" + exit 0 +fi + +if [ "$CURRENT_VALUE" = "suspend" ]; then + NEW_VALUE="ignore" +else + NEW_VALUE="suspend" +fi + +sudo sed -i "s/^HandleLidSwitch=.*/HandleLidSwitch=$NEW_VALUE/" "$CONFIG_FILE" + +sudo systemctl restart systemd-logind && echo "HandleLidSwitch toggled to $NEW_VALUE" |
