Skip to content

Instantly share code, notes, and snippets.

@xzfc
Created November 20, 2019 21:09
Show Gist options
  • Save xzfc/9556fd6a93af0e33a4003eff848a0d68 to your computer and use it in GitHub Desktop.
Save xzfc/9556fd6a93af0e33a4003eff848a0d68 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
# Check requirements
die() {
echo "$*" >&2
exit 1
}
for cmd in i3 xterm feh compton import convert mogrify montage Xephyr; do
command -v $cmd > /dev/null || die "Error: command '$cmd' not found"
done
run() {
local no=$1 win_bg=$2 win_fg=$3 rgba=$4
cat > tmp/i3.conf <<- EOF
font pango:Sans 12
client.focused #4c7899 #$win_bg #$win_fg #2e9ef4 #285577
bindsym 1 workspace number 1
exec --no-startup-id xterm -e 'sleep 0.01; import -w root \$OUT_PNG; i3-msg exit'
for_window [class=".*"] title_format abc🇺🇳😸 l|1│█
EOF
cat > tmp/fontconfig/fonts.conf <<- EOF
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<cachedir>~/.cache/fontconfig</cachedir>
<match target="pattern">
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="autohint" mode="assign"><bool>false</bool></edit>
<edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
<edit name="rgba" mode="assign"><const>$rgba</const></edit>
<edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
</match>
</fontconfig>
EOF
OUT_PNG=tmp/s/$no.png i3 -c tmp/i3.conf
}
rm -rf tmp
mkdir -p tmp/fontconfig tmp/s
unset I3SOCK
Xephyr :100 &
xephyr_pid=$!
sleep 0.1
export DISPLAY=:100
export XDG_CONFIG_HOME=$PWD/tmp
compton &
compton_pid=$!
sleep 0.1
convert -size 50x50 pattern:gray50 -fill '#00ff00' -opaque black -fill '#0000ff' -opaque white tmp/bg.png
feh --no-fehbg --bg-tile ./tmp/bg.png
run 00 285577 ffffff none
run 01 285577 ffffff rgb
run 10 285577 ff0000 none
run 11 285577 ff0000 rgb
run 20 ffffff 000000 none
run 21 ffffff 000000 rgb
run 30 000000 ffffff none
run 31 000000 ffffff rgb
run 40 00000000 000000 none
run 41 00000000 000000 rgb
run 50 00000000 0000007f none
run 51 00000000 0000007f rgb
run 60 00000000 ff00007f none
run 61 00000000 ff00007f rgb
run 70 000000 ff00007f none
run 71 000000 ff00007f rgb
run 80 000000 00000000 none
run 81 000000 00000000 rgb
run 90 000000 ff000000 none
run 91 000000 ff000000 rgb
kill $compton_pid $xephyr_pid
mogrify \
-interpolate Nearest -filter point -crop 90x20+0+0 -resize 300% \
tmp/s/*.png
montage -geometry '1x1+2+2<' -tile 2x tmp/s/*.png result.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment