Skip to content

Instantly share code, notes, and snippets.

@JJRcop
Last active May 8, 2025 00:33
Show Gist options
  • Select an option

  • Save JJRcop/bf9ad4ff304e1ec81218bf8dbced9e4e to your computer and use it in GitHub Desktop.

Select an option

Save JJRcop/bf9ad4ff304e1ec81218bf8dbced9e4e to your computer and use it in GitHub Desktop.
#!/bin/sh
# Executes gtklock with pcmanfm-qt's configured wallpaper, as well as
# setting the lock theme to a dark or light variant depending on overall
# brightness of background.
# Requires GraphicsMagick or ImageMagick to detect wallpaper
# brightness.
# Configure your LXQt Session Settings to use this as your custom
# screen lock command.
WALLPAPER=$(awk -F = '$1 == "Wallpaper" {print $2; exit}' < $XDG_CONFIG_HOME/pcmanfm-qt/lxqt/settings.conf)
if [ -x /usr/bin/gm ]; then
CONVERT="gm convert"
elif [ -x /usr/bin/convert ]; then
CONVERT=convert
fi
# Lock theme if wallpaper is bright.
LOCK_THEME=Breeze
if [ -n "$CONVERT" ] && ($CONVERT $WALLPAPER -gravity Center -resize 1x1 txt:- | awk -F[\(\)] '{FS = "[ ,]+"; $0 = $2; exit (($1 + $2 + $3) / 765 > 0.5)}'); then
# Lock theme if wallpaper is dark.
LOCK_THEME=Breeze-Dark
fi
exec gtklock --gtk-theme $LOCK_THEME --background $WALLPAPER
@JJRcop
Copy link
Author

JJRcop commented May 7, 2025

gtklock-auto-background

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment