31 lines
1.1 KiB
Bash
Executable File
31 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# lock.sh — lock the session with the active shell's own lock command.
|
|
# The mapping lives in modules/lock.lua (reads env.lua), so neither hypridle's
|
|
# lock_cmd nor the SUPER+L bind hardcodes a shell. This is what keeps a
|
|
# manually started hypridle under Caelestia from failing on `noctalia ...`.
|
|
#
|
|
# Usage: lock.sh (no args; safe to call while locked)
|
|
|
|
set -euo pipefail
|
|
|
|
# Resolve from this script's own location so it works through the
|
|
# ~/.config/hypr symlink and does not depend on XDG_CONFIG_HOME.
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
LOCK_LUA="$(cd "$SCRIPT_DIR/.." && pwd)/modules/lock.lua"
|
|
|
|
CMD="$(LOCK_LUA="$LOCK_LUA" lua -e 'print(dofile(os.getenv("LOCK_LUA")).cmd)' 2>/dev/null)" || {
|
|
echo "lock: cannot read modules/lock.lua" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Empty here means env.lua named a shell with no known lock command. Fail loudly
|
|
# instead of exiting 0, or a caller would think the session got locked.
|
|
[[ -n "$CMD" ]] || {
|
|
echo "lock: no lock command for the active shell (check env.lua)" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Word-split on purpose: CMD is a command line, not a single path.
|
|
# shellcheck disable=SC2086
|
|
exec $CMD
|