Autolock option for screen lock. Requires xprintidle to work.

This commit is contained in:
Storm Dragon committed 2026-05-14 16:10:03 -04:00
1 parent 695e046d75
commit 45eb3ae4fc
4 files changed
+187 -1

No files matched your search

+68 -1
View File
@@ -220,6 +220,27 @@ select_personal_mode_key() {
normalize_ratpoison_key "$selectedKey"
}
select_screenlock_autolock_seconds() {
local selectedAutolock
if ! selectedAutolock="$(dialog --title "I38" \
--backtitle "Use the arrow keys to choose how long I38 should wait before locking the screen automatically." \
--clear \
--default-item "0" \
--menu "Autolock screen after:" 0 0 0 \
"0" "Never" \
"180" "3 minutes" \
"300" "5 minutes" \
"600" "10 minutes" \
"1800" "30 minutes" \
"3600" "1 hour" \
--stdout)"; then
selectedAutolock="0"
fi
echo "$selectedAutolock"
}
update_personal_customizations() {
local customizationsPath="${i3Path}/customizations"
local startMarker="# I38 Personal mode start"
@@ -322,6 +343,7 @@ sounds="$sounds"
# Screen lock
screenlockPinHash="$screenlockPinHash"
screenlockAutolockSeconds="${screenlockAutolockSeconds:-0}"
# Personal mode
personalModeEnabled="${personalModeEnabled:-0}"
@@ -799,6 +821,18 @@ if [[ -z "$screenlockPinHash" ]]; then
done
fi
fi
if [[ -n "$screenlockPinHash" ]]; then
if command -v xprintidle &> /dev/null; then
if [[ -z "${screenlockAutolockSeconds+x}" ]] || [[ ! "$screenlockAutolockSeconds" =~ ^[0-9]+$ ]]; then
configChanged=1
screenlockAutolockSeconds="$(select_screenlock_autolock_seconds)"
fi
elif [[ -z "${screenlockAutolockSeconds+x}" ]] || [[ ! "$screenlockAutolockSeconds" =~ ^[0-9]+$ ]]; then
screenlockAutolockSeconds=0
fi
else
screenlockAutolockSeconds=0
fi
# Personal mode
personalModeExists=1
if personal_mode_exists; then
@@ -1257,6 +1291,9 @@ fi
if [[ $batteryAlert -eq 0 ]]; then
echo "exec_always --no-startup-id ${i3Path}/scripts/battery_alert.sh"
fi
if [[ $usingSway -ne 0 ]] && [[ -n "$screenlockPinHash" ]] && [[ "${screenlockAutolockSeconds:-0}" -gt 0 ]] && command -v xprintidle &> /dev/null; then
echo "exec_always --no-startup-id ${i3Path}/scripts/screenlock_autolock.sh ${screenlockAutolockSeconds}"
fi
# WayTray system tray daemon
if command -v waytray-daemon &> /dev/null ; then
echo 'exec_always --no-startup-id bash -c "pgrep -x waytray-daemon > /dev/null || waytray-daemon"'
@@ -1379,7 +1416,37 @@ while IFS= read -r line; do
lastComment=""
fi
done < <(sed -n '/^mode "/,/^}$/!p' "${i3Path}/config" | grep -E '^#|^bindsym')
done < <(
awk '
/^mode "/ {
inMode = 1
previousComment = ""
next
}
inMode && /^}$/ {
inMode = 0
next
}
inMode {
next
}
/^#/ {
previousComment = $0
next
}
/^bindsym/ {
if (previousComment != "") {
print previousComment
previousComment = ""
}
print
next
}
{
previousComment = ""
}
' "${i3Path}/config"
)
# Build HTML tables
{