Skip to content

Instantly share code, notes, and snippets.

@etandel
Last active January 8, 2020 02:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etandel/fc784d844a9a6822a747 to your computer and use it in GitHub Desktop.
Save etandel/fc784d844a9a6822a747 to your computer and use it in GitHub Desktop.
Random background for i3lock
#!/bin/zsh
newname=$(echo $1 | awk -F'.' '{print $1}').png # i3lock only accepts pngs
resolution=$(xrandr | fgrep '*' | awk '{print $1}')
# if the image is too large, run the folloowing line first and then run the script again on temp.jpg:
# convert $1 -gravity Center -adaptive-resize $resolution -background black temp.jpg
convert $1 -background black -gravity center -extent $resolution -background black $newname
#!/bin/zsh
# map this script on your i3 config.
# change as needed
DEFAULT_IMGS="/home/etandel/Documents/images/pngs"
if [[ -z $1 ]] ; then
img_dir=$DEFAULT_IMGS
else
img_dir=$1
fi;
randfile=$(ls $img_dir | sort -R | head -n1)
i3lock --color=000000 -i $img_dir/$randfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment