add hyprlock

This commit is contained in:
Simon Rieger 2025-04-08 14:44:23 +02:00
parent 53e4f9449d
commit 2083112faa
3 changed files with 171 additions and 0 deletions

View file

@ -191,6 +191,7 @@ $mainMod = Alt
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Return, exec, $terminal
bind = $mainMod+Shift, Q, killactive,
bind = $mainMod+Shift, L, exec, ~/.config/hypr/scripts/power.sh lock
bind = $mainMod+Shift, M, exit,
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating,

View file

@ -0,0 +1,93 @@
# sample hyprlock.conf
# for more configuration options, refer https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock
#
# rendered text in all widgets supports pango markup (e.g. <b> or <i> 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
}

View file

@ -0,0 +1,77 @@
#!/bin/bash
# ___
# / _ \___ _ _____ ____
# / ___/ _ \ |/|/ / -_) __/
# /_/ \___/__,__/\__/_/
#
terminate_clients() {
TIMEOUT=5
# Get a list of all client PIDs in the current Hyprland session
client_pids=$(hyprctl clients -j | jq -r '.[] | .pid')
# Send SIGTERM (kill -15) to each client PID and wait for termination
for pid in $client_pids; do
echo ":: Sending SIGTERM to PID $pid"
kill -15 $pid
done
start_time=$(date +%s)
for pid in $client_pids; do
# Wait for the process to terminate
while kill -0 $pid 2>/dev/null; do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -ge $TIMEOUT ]; then
echo ":: Timeout reached."
return 0
fi
echo ":: Waiting for PID $pid to terminate..."
sleep 1
done
echo ":: PID $pid has terminated."
done
}
if [[ "$1" == "exit" ]]; then
echo ":: Exit"
terminate_clients
sleep 0.5
hyprctl dispatch exit
sleep 2
fi
if [[ "$1" == "lock" ]]; then
echo ":: Lock"
sleep 0.5
hyprlock
fi
if [[ "$1" == "reboot" ]]; then
echo ":: Reboot"
terminate_clients
sleep 0.5
systemctl reboot
fi
if [[ "$1" == "shutdown" ]]; then
echo ":: Shutdown"
terminate_clients
sleep 0.5
systemctl poweroff
fi
if [[ "$1" == "suspend" ]]; then
echo ":: Suspend"
sleep 0.5
systemctl suspend
fi
if [[ "$1" == "hibernate" ]]; then
echo ":: Hibernate"
sleep 1
systemctl hibernate
fi