dotfiles/bin/rice-lock
Sarthak 7f41cf7a82 replace the old dotfiles with the sakura line rice
The bare $HOME repo is gone. This is now the rice: install.sh, rice-*
scripts in bin/, configs in home/ linked into $HOME, theme templates, st
and the particle wallpaper. Clone to ~/rice and run install.sh.
2026-09-14 19:44:44 +05:30

29 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# rice-lock - lock the screen with xsecurelock, in the rice's colours, with a
# random xscreensaver hack behind the password prompt. Notifications are held
# back while locked and shown once you unlock.
set -uo pipefail
pgrep -u "$UID" -x xsecurelock >/dev/null && exit 0
theme="${XDG_STATE_HOME:-$HOME/.local/state}/rice/theme"
[[ -f $theme/xsecurelock.env ]] && . "$theme/xsecurelock.env"
# xsecurelock's screensaver picks a random hack from a folder. Give it one that
# holds only the hacks from ~/.config/rice/screensavers (or rice's defaults).
hacks="${XDG_RUNTIME_DIR:-/tmp}/rice/hacks"
rm -rf "$hacks" && mkdir -p "$hacks"
for h in $(rice-screensaver list); do ln -s "/usr/lib/xscreensaver/$h" "$hacks/$h"; done
export XSECURELOCK_XSCREENSAVER_PATH="$hacks"
rice-screensaver stop >/dev/null 2>&1
rice-panel close >/dev/null 2>&1
level=$(dunstctl get-pause-level 2>/dev/null || echo 0)
dunstctl set-pause-level 100 >/dev/null 2>&1
xsecurelock
status=$?
dunstctl set-pause-level "$level" >/dev/null 2>&1
exit "$status"