From 8c337079007ece349f9be1e485aaa6c864b5e422 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Thu, 31 Jul 2025 23:23:33 +0200 Subject: [PATCH] feat: add lock handling --- .config/hypr/hypridle.conf | 36 +++++++++++++++ .config/hypr/hyprland.conf | 3 +- .config/hypr/hyprlock.conf | 92 +++++++++++++++++++++++++++++++++++++ .config/waybar/config.jsonc | 6 +++ setup.sh | 1 + 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 .config/hypr/hypridle.conf create mode 100644 .config/hypr/hyprlock.conf diff --git a/.config/hypr/hypridle.conf b/.config/hypr/hypridle.conf new file mode 100644 index 0000000..75fab89 --- /dev/null +++ b/.config/hypr/hypridle.conf @@ -0,0 +1,36 @@ +# for more configuration options, refer https://wiki.hyprland.org/Hypr-Ecosystem/hypridle + +general { + lock_cmd = pidof hyprlock || uwsm app -- hyprlock # avoid starting multiple hyprlock instances. + before_sleep_cmd = loginctl lock-session # lock before suspend. + after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display. +} + +# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight. +listener { + timeout = 150 # 2.5min. + on-timeout = brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight. + on-resume = brightnessctl -rd rgb:kbd_backlight # turn on keyboard backlight. +} + +listener { + timeout = 1500 # 25min. + on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor. + on-resume = brightnessctl -r # monitor backlight restore. +} + +listener { + timeout = 1800 # 30min. + on-timeout = loginctl lock-session # lock screen when timeout has passed. +} + +listener { + timeout = 2100 # 35min. + on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed. + on-resume = hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired. +} + +# listener { +# timeout = 1800 # 30min. +# on-timeout = systemctl suspend # suspend pc. +# } diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index 56d9b04..f82730f 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -25,7 +25,8 @@ monitor=,preferred,auto,1.0 # Autostart necessary processes (like notifications daemons, status bars, etc.) # Or execute your favorite apps at launch like this: -exec-once = systemctl --user start hyprpolkitagent +exec-once = systemctl --user start hypridle.service +exec-once = systemctl --user start hyprpolkitagent.service exec-once = uwsm app -- swaync exec-once = uwsm app -- waybar exec-once = uwsm app -- pasystray diff --git a/.config/hypr/hyprlock.conf b/.config/hypr/hyprlock.conf new file mode 100644 index 0000000..35d40d0 --- /dev/null +++ b/.config/hypr/hyprlock.conf @@ -0,0 +1,92 @@ +# for more configuration options, refer https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock +# +# rendered text in all widgets supports pango markup (e.g. or tags) +# ref. https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/#general-remarks +# +# shortcuts to clear password buffer: ESC, Ctrl+U, Ctrl+Backspace +# + +$font = Monospace + +general { + hide_cursor = true +} + +# uncomment to enable fingerprint authentication +# auth { +# fingerprint { +# enabled = true +# ready_message = Scan fingerprint to unlock +# present_message = Scanning... +# retry_delay = 250 # in milliseconds +# } +# } + +animations { + enabled = true + bezier = linear, 1, 1, 0, 0 + animation = fadeIn, 1, 5, linear + animation = fadeOut, 1, 5, linear + animation = inputFieldDots, 1, 2, linear +} + +background { + monitor = + path = screenshot + blur_passes = 3 +} + +input-field { + monitor = + size = 20%, 5% + outline_thickness = 3 + inner_color = rgba(0, 0, 0, 0.0) # no fill + + outer_color = rgba(33ccffee) rgba(00ff99ee) 45deg + check_color = rgba(00ff99ee) rgba(ff6633ee) 120deg + fail_color = rgba(ff6633ee) rgba(ff0066ee) 40deg + + font_color = rgb(143, 143, 143) + fade_on_empty = false + rounding = 15 + + font_family = $font + placeholder_text = Input password... + fail_text = $PAMFAIL + + # uncomment to use a letter instead of a dot to indicate the typed password + # dots_text_format = * + # dots_size = 0.4 + dots_spacing = 0.3 + + # uncomment to use an input indicator that does not show the password length (similar to swaylock's input indicator) + # hide_input = true + + position = 0, -20 + halign = center + valign = center +} + +# TIME +label { + monitor = + text = $TIME # ref. https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/#variable-substitution + font_size = 90 + font_family = $font + + position = -30, 0 + halign = right + valign = top +} + +# DATE +label { + monitor = + text = cmd[update:60000] date +"%A, %d %B %Y" # update every 60 seconds + font_size = 25 + font_family = $font + + position = -30, -150 + halign = right + valign = top +} diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index e647bea..d53d4f9 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -13,6 +13,7 @@ "network", "battery", "tray", + "custom/lock" ], "clock": { "format": "{:%H:%M}", @@ -76,5 +77,10 @@ "format-plugged": "{capacity}% ", "format-alt": "{time} {icon}", "format-icons": ["", "", "", "", ""] + }, + "custom/lock": { + "format": "", + "tooltip-format": "", + "on-click": "pidof hyprlock || uwsm app -- hyprlock" } } diff --git a/setup.sh b/setup.sh index f6124df..fccae04 100755 --- a/setup.sh +++ b/setup.sh @@ -32,6 +32,7 @@ PKGS=( "qt5-wayland" "qt6-wayland" "hyprlock" + "hypridle" "xdg-desktop-portal-hyprland" "xdg-desktop-portal-gtk" "hyprland-qt-support"