Created
June 4, 2020 13:33
-
-
Save TBog/f22e15cc25055d51e629ed8310704262 to your computer and use it in GitHub Desktop.
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 | |
##### | |
# Generate a PNG file to use in i3lock | |
# we have 2 monitors | |
# 1. resolution 1440x2560 at offset +0+0 | |
# 2. resolution 1920x1200 at offset +1440+1100 | |
##### | |
# get 2 random files from this folder | |
DIRECTORY=~/.config/variety/Favorites/ | |
# name of the output image | |
OUTPUT=~/Pictures/Wallpaper/lock.png | |
PIC1=$DIRECTORY$(ls $DIRECTORY | shuf -n 1) | |
PIC2=$DIRECTORY$(ls $DIRECTORY | shuf -n 1) | |
INFO1=$(printf %q "$(identify $PIC1 | awk '{print $1,$3}')") | |
INFO2=$(printf %q "$(identify $PIC2 | awk '{print $1,$3}')") | |
# monitor info can be taken by calling | |
# xrandr | awk '$2=="connected"{print $3}' | |
# MONITOR_1_SIZE='1440x2560' | |
# MONITOR_1_OFFS='+0+0' | |
# | |
# MONITOR_2_SIZE='1920x1200' | |
# MONITOR_2_OFFS='+1440+1100' | |
# or we can auto-generate variables HEAD_#_SIZE and HEAD_#_OFFS from the xrandr output | |
source <(\ | |
xrandr | awk -F' |x|+' 'BEGIN{cnt=1} $2=="connected"{ | |
print "HEAD_" cnt "_SIZE=\"" $3 "x" $4 "\"" | |
print "HEAD_" cnt "_OFFS=\"+" $5 "+" $6 "\"" | |
++cnt | |
}' | |
) | |
# TODO: change the label position | |
convert \ | |
\( $PIC1 -resize $HEAD_1_SIZE^ -gravity Center -extent $HEAD_1_SIZE -repage $HEAD_1_OFFS \) \ | |
\( $PIC2 -resize $HEAD_2_SIZE^ -gravity Center -extent $HEAD_2_SIZE -repage $HEAD_2_OFFS \) \ | |
\( -background black -fill lime -size 1920x100 label:"$INFO1" -repage +1440+0 \) \ | |
\( -background black -fill lime -size 1920x100 label:"$INFO2" -repage +1440+1000 \) \ | |
-background None -layers merge $OUTPUT | |
identify $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment