Skip to content

Instantly share code, notes, and snippets.

@dimitris-k
Created September 3, 2018 07:24
Show Gist options
  • Save dimitris-k/515b1c28edaf5ccacc02a43de74ebfdd to your computer and use it in GitHub Desktop.
Save dimitris-k/515b1c28edaf5ccacc02a43de74ebfdd to your computer and use it in GitHub Desktop.
Custom /usr/bin/xflock4 to use only slock and check for user activity before actually locking the display
#!/bin/sh
PATH=/bin:/usr/bin
export PATH
sleep 1
xset dpms force off
sleep 20
# Check if the monitor is On after these 20 seconds,
# which means that the user acted to cancel locking
(xset q | grep 'Monitor is On' >/dev/null 2>&1) && exit
set -- slock
if command -v -- $1 >/dev/null 2>&1; then
slock >/dev/null 2>&1 &
# turn off display backlight:
xset dpms force off
exit
fi
# else access locking failed
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment