Initial low vision features added. xzoom needs to be installed for magnification. This first implementation is probably terrible, feedback welcome for improvement. Screen lock can now happen when I38 starts. As a reminder, it's not as secure as one of the system lockers, but it is screen reader accessible and should keep casual snoopers thwarted.
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Move the mouse pointer to the center of the focused window.
|
||||
|
||||
if ! command -v xdotool &> /dev/null; then
|
||||
if command -v notify-send &> /dev/null; then
|
||||
notify-send "I38" "xdotool is required to move the mouse pointer."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
activeWindow="$(xdotool getactivewindow 2> /dev/null || true)"
|
||||
if [[ "$activeWindow" =~ ^[0-9]+$ ]]; then
|
||||
while IFS='=' read -r key value; do
|
||||
case "$key" in
|
||||
X|Y|WIDTH|HEIGHT)
|
||||
if [[ "$value" =~ ^-?[0-9]+$ ]]; then
|
||||
printf -v "$key" '%s' "$value"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < <(xdotool getwindowgeometry --shell "$activeWindow" 2> /dev/null || true)
|
||||
fi
|
||||
|
||||
if [[ "${X:-}" =~ ^-?[0-9]+$ ]] &&
|
||||
[[ "${Y:-}" =~ ^-?[0-9]+$ ]] &&
|
||||
[[ "${WIDTH:-}" =~ ^[0-9]+$ ]] &&
|
||||
[[ "${HEIGHT:-}" =~ ^[0-9]+$ ]] &&
|
||||
[[ "$WIDTH" -gt 0 ]] &&
|
||||
[[ "$HEIGHT" -gt 0 ]]; then
|
||||
pointerX=$((X + WIDTH / 2))
|
||||
pointerY=$((Y + HEIGHT / 2))
|
||||
else
|
||||
read -r displayWidth displayHeight < <(xdotool getdisplaygeometry)
|
||||
pointerX=$((displayWidth / 2))
|
||||
pointerY=$((displayHeight / 2))
|
||||
fi
|
||||
|
||||
xdotool mousemove "$pointerX" "$pointerY"
|
||||
@@ -15,6 +15,24 @@ scriptPath="$(readlink -f "$0")"
|
||||
scriptDir="${scriptPath%/*}"
|
||||
i3Path="${scriptDir%/scripts}"
|
||||
pinFile="${i3Path}/.screenpin"
|
||||
runtimeDir="${XDG_RUNTIME_DIR:-/tmp}"
|
||||
lockDir="${runtimeDir}/i38-screenlock"
|
||||
|
||||
if [[ -d "$lockDir" ]]; then
|
||||
if [[ -f "${lockDir}/pid" ]]; then
|
||||
read -r existingPid < "${lockDir}/pid"
|
||||
if [[ "$existingPid" =~ ^[0-9]+$ ]] && kill -0 "$existingPid" 2> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
rm -rf "$lockDir"
|
||||
fi
|
||||
|
||||
if ! mkdir "$lockDir" 2> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
printf "%s\n" "$$" > "${lockDir}/pid"
|
||||
trap 'rm -rf "$lockDir"' EXIT
|
||||
|
||||
if [[ -f "$pinFile" ]]; then
|
||||
read -r screenlockPinHash < "$pinFile"
|
||||
|
||||
Reference in New Issue
Block a user