Added stuff for closing lid and locking screen

This commit is contained in:
2026-02-22 18:10:46 +01:00
parent c06f8a92f5
commit 56591b2c53
5 changed files with 37 additions and 30 deletions
+1 -1
View File
@@ -2653,7 +2653,7 @@ Now starts the main emacs configuration.
* Machines * Machines
Only a few more things left. Specifically the machine level extra settings. 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. The configuration for the laptop does not change much. Most changes are because the hardware is different.
*** System Level *** System Level
Nothing specific for the laptop. Nothing specific for the laptop.
@@ -24,7 +24,6 @@
$mainMod = SUPER $mainMod = SUPER
# use walker to show exec menu # use walker to show exec menu
bind = $mainMod, Space , exec, walker bind = $mainMod, Space , exec, walker
bind = $mainMod, P, pseudo bind = $mainMod, P, pseudo
@@ -151,6 +150,13 @@ bind = , XF86KbdBrightnessDown, exec, brightnessctl -d '*kbd_backlight*' set 10%
bind = , XF86Sleep, exec, systemctl suspend bind = , XF86Sleep, exec, systemctl suspend
bind = , XF86PowerOff, exec, systemctl poweroff bind = , XF86PowerOff, exec, systemctl poweroff
bind = , XF86WakeUp, exec, systemctl suspend 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 # 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, S, exec, spotify
bind = CTRL ALT, z, exec, flatpak run app.zen_browser.zen --filesystem=home bind = CTRL ALT, z, exec, flatpak run app.zen_browser.zen --filesystem=home
bind = CTRL ALT, k, exec, kate bind = CTRL ALT, k, exec, kate
@@ -1,19 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
# If ANY external monitor exists, do NOT lock on lid close (clamshell use-case). INTERNAL="eDP1"
# Your internal panel is eDP-1.
# Anything not starting with eDP is treated as external.
if hyprctl monitors -j | grep -q '"name":"[^"]\+"' ; then has_external() {
if hyprctl monitors -j | grep -q '"name":"DP-1"' ; then # Any monitor name that is not INTERNAL counts as external
exit 0 hyprctl monitors -j | grep -q '"name"' && ! hyprctl monitors -j | grep -q "\"name\":\"$INTERNAL\"\""
fi }
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 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
@@ -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"
-14
View File
@@ -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