From 56591b2c5321e130760815ae902f25c985555b47 Mon Sep 17 00:00:00 2001 From: Henro Veijer Date: Sun, 22 Feb 2026 18:10:46 +0100 Subject: [PATCH] Added stuff for closing lid and locking screen --- system-master/README.org | 2 +- .../assets/conf/desktop/hypr/bindings.conf | 10 +++++- .../conf/desktop/hypr/scripts/lid-lock.sh | 34 +++++++++++-------- .../conf/desktop/hypr/scripts/lid-restore.sh | 7 ++++ system-master/no block | 14 -------- 5 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 system-master/assets/conf/desktop/hypr/scripts/lid-restore.sh delete mode 100644 system-master/no block diff --git a/system-master/README.org b/system-master/README.org index 91fb892..63baef3 100755 --- a/system-master/README.org +++ b/system-master/README.org @@ -2653,7 +2653,7 @@ Now starts the main emacs configuration. * Machines Only a few more things left. Specifically the machine level extra settings. -** Smallbox +** Traveldroid The configuration for the laptop does not change much. Most changes are because the hardware is different. *** System Level Nothing specific for the laptop. diff --git a/system-master/assets/conf/desktop/hypr/bindings.conf b/system-master/assets/conf/desktop/hypr/bindings.conf index 4750bde..0004b6d 100644 --- a/system-master/assets/conf/desktop/hypr/bindings.conf +++ b/system-master/assets/conf/desktop/hypr/bindings.conf @@ -24,7 +24,6 @@ $mainMod = SUPER - # use walker to show exec menu bind = $mainMod, Space , exec, walker bind = $mainMod, P, pseudo @@ -151,6 +150,13 @@ bind = , XF86KbdBrightnessDown, exec, brightnessctl -d '*kbd_backlight*' set 10% bind = , XF86Sleep, exec, systemctl suspend bind = , XF86PowerOff, exec, systemctl poweroff bind = , XF86WakeUp, exec, systemctl suspend +bind = $mainMod, L, exec, loginctl lock-session + +######################### +# Laptop lid settings +######################### +bindl = , switch:on:Lid Switch, exec, ~/.config/hypr/scripts/lid-action.sh +bindl = , switch:off:Lid Switch, exec, ~/.config/hypr/scripts/lid-restore.sh ######################### # Start apps @@ -159,3 +165,5 @@ bind = CTRL ALT, B, exec, flatpak run eu.betterbird.Betterbird bind = CTRL ALT, S, exec, spotify bind = CTRL ALT, z, exec, flatpak run app.zen_browser.zen --filesystem=home bind = CTRL ALT, k, exec, kate + + diff --git a/system-master/assets/conf/desktop/hypr/scripts/lid-lock.sh b/system-master/assets/conf/desktop/hypr/scripts/lid-lock.sh index b84cf42..55e0e92 100644 --- a/system-master/assets/conf/desktop/hypr/scripts/lid-lock.sh +++ b/system-master/assets/conf/desktop/hypr/scripts/lid-lock.sh @@ -1,19 +1,25 @@ #!/usr/bin/env bash set -euo pipefail -# If ANY external monitor exists, do NOT lock on lid close (clamshell use-case). -# Your internal panel is eDP-1. -# Anything not starting with eDP is treated as external. +INTERNAL="eDP1" -if hyprctl monitors -j | grep -q '"name":"[^"]\+"' ; then - if hyprctl monitors -j | grep -q '"name":"DP-1"' ; then - exit 0 - fi +has_external() { + # Any monitor name that is not INTERNAL counts as external + hyprctl monitors -j | grep -q '"name"' && ! hyprctl monitors -j | grep -q "\"name\":\"$INTERNAL\"\"" +} + +has_external_robust() { + # robust without jq: count monitor names; if there's >1 OR there's a name not INTERNAL + local names + names="$(hyprctl monitors -j | sed -n 's/.*"name":"\([^"]*\)".*/\1/p')" + # if any name != INTERNAL then external + echo "$names" | grep -vx "$INTERNAL" >/dev/null 2>&1 +} + +if has_external_robust; then + # Clamshell: disable laptop panel, no lock + hyprctl keyword monitor "${INTERNAL},disable" +else + # Laptop only: suspend + systemctl suspend fi - -# Generic: if any monitor is not eDP-1, assume external exists. -if hyprctl monitors -j | grep -q '"name":"[^"]\+"' && hyprctl monitors -j | grep -vq '"name":"eDP-1"'; then - exit 0 -fi - -exec hyprlock diff --git a/system-master/assets/conf/desktop/hypr/scripts/lid-restore.sh b/system-master/assets/conf/desktop/hypr/scripts/lid-restore.sh new file mode 100644 index 0000000..5767d35 --- /dev/null +++ b/system-master/assets/conf/desktop/hypr/scripts/lid-restore.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail + +INTERNAL="eDP1" + +# Restore panel using preferred mode, auto position, scale 1 +hyprctl keyword monitor "${INTERNAL},preferred,auto,1" diff --git a/system-master/no block b/system-master/no block deleted file mode 100644 index a747395..0000000 --- a/system-master/no block +++ /dev/null @@ -1,14 +0,0 @@ -# Check if NetworkManager service is running -systemctl status NetworkManager -# If not running, start it temporarily -sudo systemctl start NetworkManager -# Enable Wi-Fi radio (in case it is disabled) -nmcli radio wifi on -# List available Wi-Fi networks -nmcli device wifi list -# Connect to a Wi-Fi network (replace SSID and PASSWORD) -nmcli device wifi connect "SSID_NAME" password "YOUR_PASSWORD" -# Verify that the connection is active -nmcli connection show --active -# Optional: show device status -nmcli device status