From e4a1ec237959ed7431261537c2ddd73ab3702363 Mon Sep 17 00:00:00 2001 From: Toni Nowak Date: Sat, 13 Jun 2026 12:59:21 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Add=20screensaver=20&=20idle=20settings=20T?= =?UTF-8?q?UI=20under=20Setup=20=E2=86=92=20Config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/omarchy-config-screensaver | 195 +++++++++++++++++++++++++++++++++ bin/omarchy-menu | 3 +- 2 files changed, 197 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-config-screensaver diff --git a/bin/omarchy-config-screensaver b/bin/omarchy-config-screensaver new file mode 100755 index 000000000000..7ea6710b70e9 --- /dev/null +++ b/bin/omarchy-config-screensaver @@ -0,0 +1,195 @@ +#!/bin/bash + +# omarchy:summary=Configure idle behavior: screensaver, display blanking, and idle lock +# omarchy:group=config +# omarchy:name=screensaver + +# Interactive editor for ~/.config/hypr/hypridle.conf. Lets you choose what happens +# when the session goes idle (animated screensaver, blank the displays, or nothing), +# how long to wait, and whether the session locks. Changes are written to the user +# config with a timestamped backup and applied by restarting hypridle. "Restore +# Omarchy defaults" reverts to the shipped config via omarchy-refresh-config. + +HYPRIDLE_CONF="$HOME/.config/hypr/hypridle.conf" + +read_settings() { + action=screensaver + idle=150 + lock=on + lockdelay=2 + + [[ -f $HYPRIDLE_CONF ]] || return + + mapfile -t timeouts < <(grep -oP 'timeout\s*=\s*\K[0-9]+' "$HYPRIDLE_CONF") + + if grep -q "omarchy-launch-screensaver" "$HYPRIDLE_CONF"; then + action=screensaver + elif grep -q "dpms off" "$HYPRIDLE_CONF"; then + action=dpms + else + action=none + fi + + if grep -qE "on-timeout = omarchy-system-lock$" "$HYPRIDLE_CONF"; then + lock=on + else + lock=off + fi + + if [[ $action != none ]]; then + [[ -n ${timeouts[0]:-} ]] && idle=${timeouts[0]} + if [[ $lock == on && -n ${timeouts[1]:-} ]]; then + ((lockdelay = timeouts[1] - idle)) + ((lockdelay < 0)) && lockdelay=2 + fi + elif [[ $lock == on && -n ${timeouts[0]:-} ]]; then + idle=${timeouts[0]} + lockdelay=0 + fi +} + +write_settings() { + mkdir -p "$(dirname "$HYPRIDLE_CONF")" + [[ -f $HYPRIDLE_CONF ]] && cp -f "$HYPRIDLE_CONF" "$HYPRIDLE_CONF.bak.$(date +%s)" + + { + cat <<'GENERAL' +general { + lock_cmd = omarchy-system-lock # lock screen and 1password + before_sleep_cmd = OMARCHY_LOCK_ONLY=true omarchy-system-lock # lock before suspend without scheduling display off. + after_sleep_cmd = sleep 1 && omarchy-system-wake # delay for PAM readiness, then turn on display. + inhibit_sleep = 3 # wait until screen is locked +} +GENERAL + + case $action in + screensaver) + printf '\n# Start screensaver after %s seconds of inactivity\nlistener {\n timeout = %s\n on-timeout = pidof hyprlock || omarchy-launch-screensaver\n}\n' "$idle" "$idle" + ;; + dpms) + printf '\n# Turn off displays after %s seconds of inactivity\nlistener {\n timeout = %s\n on-timeout = hyprctl dispatch dpms off\n on-resume = hyprctl dispatch dpms on\n}\n' "$idle" "$idle" + ;; + esac + + if [[ $lock == on ]]; then + printf '\n# Lock the session after inactivity\nlistener {\n timeout = %s\n on-timeout = omarchy-system-lock\n on-resume = omarchy-system-wake\n}\n' "$((idle + lockdelay))" + fi + } >"$HYPRIDLE_CONF" + + omarchy-restart-hypridle +} + +fmt_action() { + case $1 in + screensaver) echo "Show screensaver" ;; + dpms) echo "Turn off displays" ;; + none) echo "Do nothing" ;; + esac +} + +fmt_mins() { awk "BEGIN { printf \"%g\", $1 / 60 }"; } + +choose_action() { + local choice + choice=$(gum choose --header "When the session goes idle:" \ + "Show screensaver" "Turn off displays" "Do nothing") || return + case $choice in + "Show screensaver") action=screensaver ;; + "Turn off displays") action=dpms ;; + "Do nothing") action=none ;; + esac + dirty=1 +} + +choose_timeout() { + if [[ $action == none ]]; then + echo "Pick a screen action first (screensaver or turn off displays)." + sleep 1.5 + return + fi + local choice secs + choice=$(gum choose --header "Idle timeout:" \ + "1 minute" "2.5 minutes" "5 minutes" "10 minutes" "30 minutes" "Custom…") || return + case $choice in + "1 minute") idle=60 ;; + "2.5 minutes") idle=150 ;; + "5 minutes") idle=300 ;; + "10 minutes") idle=600 ;; + "30 minutes") idle=1800 ;; + "Custom…") + secs=$(gum input --header "Idle timeout in seconds (min 5):" --value "$idle") || return + if [[ $secs =~ ^[0-9]+$ ]] && ((secs >= 5)); then + idle=$secs + else + echo "Invalid value." + sleep 1.5 + return + fi + ;; + esac + dirty=1 +} + +choose_lock() { + local choice + choice=$(gum choose --header "Lock the session when idle?" "Yes" "No") || return + [[ $choice == "Yes" ]] && lock=on || lock=off + dirty=1 +} + +apply_settings() { + write_settings + dirty=0 + notify-send -u low "Idle settings applied" \ + "$(fmt_action "$action") • timeout ${idle}s • lock: $lock" 2>/dev/null + echo "Applied." + sleep 1 +} + +command -v gum &>/dev/null || { + echo "gum is required" >&2 + exit 1 +} + +read_settings +dirty=0 + +while true; do + clear + echo "Screensaver & idle settings" + echo + echo " When idle : $(fmt_action "$action")" + [[ $action != none ]] && echo " Idle timeout : ${idle}s ($(fmt_mins "$idle") min)" + if [[ $lock == on ]]; then + echo " Idle lock : on (locks after $((idle + lockdelay))s)" + else + echo " Idle lock : off" + fi + ((dirty)) && echo -e "\n * unapplied changes" + echo + + choice=$(gum choose --header "Edit:" \ + "When idle" "Idle timeout" "Idle lock" "Apply" "Restore Omarchy defaults" "Quit") || exit 0 + + case $choice in + "When idle") choose_action ;; + "Idle timeout") choose_timeout ;; + "Idle lock") choose_lock ;; + "Apply") apply_settings ;; + "Restore Omarchy defaults") + if gum confirm "Restore the default Omarchy idle configuration?"; then + omarchy-refresh-config hypr/hypridle.conf >/dev/null + omarchy-restart-hypridle + read_settings + dirty=0 + notify-send -u low "Restored default Omarchy idle settings" 2>/dev/null + fi + ;; + "Quit") + if ((dirty)) && gum confirm "Apply changes before quitting?"; then + apply_settings + fi + exit 0 + ;; + esac +done diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 8627ab132c35..3082d98db876 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -489,7 +489,8 @@ show_setup_default_editor_menu() { } show_setup_config_menu() { - case $(menu "Setup" " Hyprland\n Hypridle\n Hyprlock\n Hyprsunset\n Swayosd\n󰌧 Walker\n󰍜 Waybar\n󰞅 XCompose") in + case $(menu "Setup" "󱄄 Screensaver\n Hyprland\n Hypridle\n Hyprlock\n Hyprsunset\n Swayosd\n󰌧 Walker\n󰍜 Waybar\n󰞅 XCompose") in + *Screensaver*) present_terminal omarchy-config-screensaver ;; *Hyprland*) open_in_editor "$(hypr_config_file hyprland)" ;; *Hypridle*) open_in_editor ~/.config/hypr/hypridle.conf && omarchy-restart-hypridle ;; *Hyprlock*) open_in_editor ~/.config/hypr/hyprlock.conf ;; From faf8b4b3f6db13c79298751336743dabf1f3939a Mon Sep 17 00:00:00 2001 From: Toni Nowak Date: Sat, 13 Jun 2026 16:56:42 +0200 Subject: [PATCH 2/2] fix: keep idle timeout editable when only idle lock is enabled When the screen action is 'Do nothing' but idle lock stays on, the idle timeout is the only value still driving the lock listener. The previous guard blocked editing it and hid it from the summary, leaving a fixed lock timeout (idle + stale lockdelay) with no way to change it. - choose_timeout: only block when no screen action AND lock is off - show the idle timeout whenever an action or the lock is active - add lock_timeout(): without a screen action the lock fires at idle itself (lockdelay only applies when an action precedes the lock), so the displayed/written lock time matches the editable timeout --- bin/omarchy-config-screensaver | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/omarchy-config-screensaver b/bin/omarchy-config-screensaver index 7ea6710b70e9..6a25d8954a28 100755 --- a/bin/omarchy-config-screensaver +++ b/bin/omarchy-config-screensaver @@ -48,6 +48,16 @@ read_settings() { fi } +# Seconds after which the lock fires. With a screen action the lock trails it by +# lockdelay; with no screen action the idle timeout itself drives the lock. +lock_timeout() { + if [[ $action == none ]]; then + echo "$idle" + else + echo "$((idle + lockdelay))" + fi +} + write_settings() { mkdir -p "$(dirname "$HYPRIDLE_CONF")" [[ -f $HYPRIDLE_CONF ]] && cp -f "$HYPRIDLE_CONF" "$HYPRIDLE_CONF.bak.$(date +%s)" @@ -72,7 +82,7 @@ GENERAL esac if [[ $lock == on ]]; then - printf '\n# Lock the session after inactivity\nlistener {\n timeout = %s\n on-timeout = omarchy-system-lock\n on-resume = omarchy-system-wake\n}\n' "$((idle + lockdelay))" + printf '\n# Lock the session after inactivity\nlistener {\n timeout = %s\n on-timeout = omarchy-system-lock\n on-resume = omarchy-system-wake\n}\n' "$(lock_timeout)" fi } >"$HYPRIDLE_CONF" @@ -102,8 +112,8 @@ choose_action() { } choose_timeout() { - if [[ $action == none ]]; then - echo "Pick a screen action first (screensaver or turn off displays)." + if [[ $action == none && $lock == off ]]; then + echo "Enable a screen action or idle lock first." sleep 1.5 return fi @@ -159,9 +169,11 @@ while true; do echo "Screensaver & idle settings" echo echo " When idle : $(fmt_action "$action")" - [[ $action != none ]] && echo " Idle timeout : ${idle}s ($(fmt_mins "$idle") min)" + if [[ $action != none || $lock == on ]]; then + echo " Idle timeout : ${idle}s ($(fmt_mins "$idle") min)" + fi if [[ $lock == on ]]; then - echo " Idle lock : on (locks after $((idle + lockdelay))s)" + echo " Idle lock : on (locks after $(lock_timeout)s)" else echo " Idle lock : off" fi