From a657dd355c4a997c33f0ab3101b7181a7ae03d13 Mon Sep 17 00:00:00 2001 From: David Runge Date: Mon, 22 Jan 2018 22:31:20 +0100 Subject: bin/xorg_*: Adding scripts to automatically lock X11 using xssstate and i3lock. --- bin/xorg_autolock | 24 ++++++++++++++++++++++++ bin/xorg_lock | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 bin/xorg_autolock create mode 100755 bin/xorg_lock diff --git a/bin/xorg_autolock b/bin/xorg_autolock new file mode 100755 index 0000000..5f7199a --- /dev/null +++ b/bin/xorg_autolock @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo pipefail + +lock=${XDG_RUNTIME_DIR}/xorg_autolock.lock +lock_block=${XDG_RUNTIME_DIR}/xorg_autolock_block +lockafter=600000 + +rm ${lock} ${lock_block} + +while [ 1 ]; do + if [ ! -f ${lock} -a ! -f ${lock_block} ];then + if [ -x "/usr/bin/xssstate" ]; then + if [ $(xssstate -i) -ge $lockafter ]; then + $HOME/bin/xorg_lock + fi + else + echo "xssstate is note installed!" + exit 1 + fi + fi + + sleep 1 +done diff --git a/bin/xorg_lock b/bin/xorg_lock new file mode 100755 index 0000000..d7a5d52 --- /dev/null +++ b/bin/xorg_lock @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euo pipefail + +lock=${XDG_RUNTIME_DIR}/xorg_autolock.lock +lockcmd="i3lock -n -e -c 000000 -f" + +if [ -x "/usr/bin/i3lock" ]; then + touch ${lock} + ${lockcmd} + rm ${lock} +else + echo "i3lock is not installed!" + exit 1 +fi +exit 0 -- cgit v1.2.3-70-g09d2