# ============================================================================
# hypridle.conf — Idle action configuration for hypridle
#
# hypridle watches for user inactivity and fires timed actions.
# This config handles two tiers of idle behaviour:
#   1. Screen lock (short idle — 2 minutes)
#   2. Suspend-then-hibernate (longer idle — 10 minutes)
#
# The "caffeine" toggle (scripts/caffeine.sh) kills hypridle to prevent
# any of these actions when you want to keep the session awake.
# ============================================================================

#source ~/.config/idle.conf   # Alternate source path (disabled)

# ── general: session-level commands ────────────────────────────────────────
general {
    # lock_cmd: command to run when the session is asked to lock.
    # `pidof hyprlock || hyprlock` prevents a second hyprlock instance if one
    # is already running — important because loginctl can call this repeatedly.
    lock_cmd = pidof hyprlock || hyprlock       # avoid starting multiple hyprlock instances.

    # before_sleep_cmd: runs immediately before the system suspends.
    # loginctl lock-session triggers the PAM lock mechanism, which calls lock_cmd above.
    # This ensures the screen is locked before suspend so wake-up requires auth.
    before_sleep_cmd = loginctl lock-session    # lock before suspend.

    # after_sleep_cmd: runs after the system resumes from suspend.
    # fprintd is the fingerprint authentication daemon — restarting it after
    # resume ensures the fingerprint reader is re-initialised (common driver quirk).
    # `hyprctl dispatch dpms on` forces the display back on without requiring
    # a key press (avoids the "press a key twice" issue).
    after_sleep_cmd = systemctl restart fprintd.service ;; hyprctl dispatch dpms on  # to avoid having to press a key twice to turn on the display.

}

# ── listener 1: lock screen after 2 minutes of inactivity ──────────────────
listener {
    # timeout: seconds of inactivity before the action fires. 120s = 2 minutes.
    # Short timeout to quickly protect the session when stepping away briefly.
    timeout = 120
    # on-timeout: lock the session via loginctl (which invokes lock_cmd above).
    on-timeout = loginctl lock-session # lock screen when timeout has passed
}

# ── listener 2: suspend after 10 minutes of inactivity ─────────────────────
listener {
    # timeout: 600s = 10 minutes. After the screen has been locked for ~8 more
    # minutes with no activity, the system suspends to save power.
    timeout = 600 #10min
    # on-timeout: suspend-then-hibernate writes RAM to disk and suspends.
    # If not woken within the hibernate delay, the system fully hibernates.
    on-timeout = systemctl suspend-then-hibernate # suspend pc
}


# ── Disabled: reboot after 5 hours ─────────────────────────────────────────
# Commented out — a forced reboot after 5 hours is too aggressive for a
# personal workstation. Kept as reference in case needed for kiosk use.
#listener {
#    timeout = 18000 #5h
#    on-timeout = /usr/bin/reboot #reboot
#}
