Created
November 22, 2018 13:45
-
-
Save rstacruz/1d2c23124061dd06c7177cf2ba0793fe to your computer and use it in GitHub Desktop.
Transparent lock screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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