Created
November 12, 2020 23:06
-
-
Save ronoaldo/742863fc6627843555a61a3b8d2e7839 to your computer and use it in GitHub Desktop.
Plymouth theme preview tool for Debian/Ubuntu
This file contains hidden or 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 | |
# Check root | |
if [ ! $( id -u ) -eq 0 ]; then | |
echo Must be run as root. Trying sudo $0 $@ | |
exec sudo $0 $@ | |
exit $? | |
fi | |
# Install dependencies | |
function install_pkg() { | |
dpkg -l "$1" 2>/dev/null >/dev/null || apt-get install "$1" -yq | |
} | |
install_pkg x11-apps | |
install_pkg xserver-xephyr | |
install_pkg plymouth-x11 | |
install_pkg imagemagick | |
install_pkg xdotool | |
# Configure duration of display | |
DURATION=100 | |
# Open a window dedicated for preview | |
Xephyr :1 -ac -screen 1920x1080 -fullscreen -name 'plymouth-x11' -title 'plymouth-x11' & | |
WPID=$! | |
export DISPLAY=:1 | |
# Get current theme | |
THEME=$(cat /etc/plymouth/plymouthd.conf | grep ^Theme | cut -f 2 -d=) | |
echo "Previewing theme $THEME" | |
# Launch plymouthd | |
plymouthd | |
# Force a screen update by simulating mouse movement | |
function mouse_move() { | |
xdotool mousemove 100 $RANDOM | |
} | |
# Saves the content window as PNG | |
function screencap() { | |
XWD=/tmp/plymouth-$THEME-preview-$1.xwd | |
PNG=/tmp/plymouth-$THEME-preview-$1.png | |
DISPLAY=:0 xwd -name "plymouth-x11" -out "$XWD" | |
convert -resize 1280x768 "$XWD" "$PNG" | |
rm -rvf "$XWD" | |
} | |
# Simulate boot animation | |
plymouth show-splash | |
for ((I=0; I<$DURATION; I++)); do | |
plymouth --update=test$I | |
plymouth system-update --progress=$I | |
plymouth message --text="Preview of '$THEME' $I/$DURATION" | |
mouse_move | |
if [ $(( I % 25 )) -eq 0 -a $I -gt 0 ]; then | |
screencap $((I+1)) | |
fi | |
sleep 0.1 | |
done | |
# Simulate password request | |
plymouth ask-for-password \ | |
--command='/bin/true' \ | |
--prompt='Inform password to decrypt volume' & | |
xdotool key --repeat 6 --delay 100 a ; sleep 1 | |
mouse_move | |
screencap 100-input | |
xdotool key Return | |
# Exit plymouth and close window | |
plymouth quit | |
kill -9 $WPID | |
echo "Preview screenshots saved at /tmp/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment