Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Created November 22, 2018 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rstacruz/1d2c23124061dd06c7177cf2ba0793fe to your computer and use it in GitHub Desktop.
Save rstacruz/1d2c23124061dd06c7177cf2ba0793fe to your computer and use it in GitHub Desktop.
Transparent lock screen
#!/usr/bin/env bash
# Rico's transparent X lock script
# Requires 'scrot' and 'xbacklight' and 'i3lock'
_xbacklight () {
if which xbacklight &>/dev/null; then
xbacklight $*
fi
}
# Config
BACKLIGHT_LEVEL=2
temp_image=$(mktemp --suffix='.jpg')
light_level=$(xbacklight -get)
if which scrot &>/dev/null; then
# Take a screenshot
scrot "$temp_image"
# Dim the screen
_xbacklight -set $BACKLIGHT_LEVEL
# Open i3lock with the screenshot image
i3lock \
--nofork \
--ignore-empty-password \
--show-failed-attempts \
-i "$temp_image"
# After unlocking, remove the image
rm "$temp_image"
else
# If scrot is not installed, use a flat color
_xbacklight -set $BACKLIGHT_LEVEL
i3lock -c 112233
fi
# Restore old light color
_xbacklight -set $light_level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment