Files
i3-dot/i3/scripts/lock-then-suspend
2026-07-29 20:10:58 +07:00

13 lines
453 B
Bash
Executable File

#!/bin/bash
wall_dir="${1:?wallpaper directory required}"
img=$(find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1)
tmp=/tmp/lockscreen.png
res=$(xrandr --current | awk '/ connected/ {getline; print $1; exit}')
: "${res:=1920x1080}"
if [ -n "$img" ] && convert "$img" -resize "${res}^" -gravity Center -extent "$res" "$tmp" 2>/dev/null; then
i3lock -i "$tmp"
else
i3lock -c 000000
fi
systemctl suspend