Created
October 4, 2015 08:16
-
-
Save brantsch/c4f7c974e2aab74b8d57 to your computer and use it in GitHub Desktop.
Wrap i3lock to randomly select an image from a folder and automatically scale it to fit your monitor resolution.
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
#!/bin/bash | |
random_wallpaper="$(find $1 -maxdepth 1 -name *.png | shuf | head -1)" | |
actual_size="$(identify -format %wx%h $random_wallpaper)" | |
target_size=$(xrandr | head -n 1 | awk -e '{OFS=""; gsub("[ ,]+","",$10); print $8,"x",$10;}') | |
if [[ "$actual_size" != "$target_size" ]]; then | |
convert "$random_wallpaper" -background black -gravity center -scale $target_size -extent $target_size png:- | i3lock -i /proc/self/fd/0 | |
else | |
i3lock -t -i "$random_wallpaper" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment