Added stuff for closing lid and locking screen
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user