diff --git a/debian/control b/debian/control index 6cd5cf6f..370c19cb 100644 --- a/debian/control +++ b/debian/control @@ -23,7 +23,8 @@ Depends: ${shlibs:Depends}, libcairo2 (>= 1.14.0), libgtk-3-0 (>= 3.14), xserver-xorg, - xinit + xinit, + fbi Provides: x-display-manager Description: A OctoPrint touch interface for TFT touch modules based on GTK+3 OOctoScreen OOctoScreen, a touch interface for TFT touch modules diff --git a/debian/local/octoscreen/boot_splash.sh b/debian/local/octoscreen/boot_splash.sh new file mode 100755 index 00000000..06d91730 --- /dev/null +++ b/debian/local/octoscreen/boot_splash.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +OCTOSCREEN_DEFAULT_BOOT_SPLASH="/opt/octoscreen/styles/z-bolt/images/boot-splash/" +FRAME_BUFFER=$1 + +if [[ -z "$FRAME_BUFFER" ]]; then + echo "Unable to detect valid Frame Buffer for OctoScreen Boot Splash" +else + # PARSE THE USER INPUT + if [[ -z "$OCTOSCREEN_BOOT_SPLASH" ]]; then + OCTOSCREEN_BOOT_SPLASH="$OCTOSCREEN_DEFAULT_BOOT_SPLASH" + echo "OCTOSCREEN_BOOT_SPLASH not set, using default ( $OCTOSCREEN_BOOT_SPLASH )" + elif [[ -f "$OCTOSCREEN_BOOT_SPLASH" ]]; then + if [[ ! $OCTOSCREEN_BOOT_SPLASH =~ .*\.png$ ]]; then + OCTOSCREEN_BOOT_SPLASH="$OCTOSCREEN_DEFAULT_BOOT_SPLASH" + echo "OCTOSCREEN_BOOT_SPLASH is not a valid PNG file, using default ( $OCTOSCREEN_BOOT_SPLASH )" + fi + elif [[ -d "$OCTOSCREEN_BOOT_SPLASH" ]]; then + if [[ "$( ls -A ${OCTOSCREEN_BOOT_SPLASH}/*.png )" ]]; then + OCTOSCREEN_BOOT_SPLASH="${OCTOSCREEN_BOOT_SPLASH}/*.png" + else + OCTOSCREEN_BOOT_SPLASH="$OCTOSCREEN_DEFAULT_BOOT_SPLASH" + echo "OCTOSCREEN_BOOT_SPLASH is a directory, but doesn't contain any PNG files, using default ( $OCTOSCREEN_BOOT_SPLASH )" + fi + else + OCTOSCREEN_BOOT_SPLASH="$OCTOSCREEN_DEFAULT_BOOT_SPLASH" + echo "OCTOSCREEN_BOOT_SPLASH neither a file or directory, using default ( $OCTOSCREEN_BOOT_SPLASH )" + fi + + # FINAL VALIDATION OF PATH + if [[ ! $OCTOSCREEN_BOOT_SPLASH =~ .*\.png$ ]]; then + if [[ -d "$OCTOSCREEN_BOOT_SPLASH" ]] && [[ "$( ls -A ${OCTOSCREEN_BOOT_SPLASH}/*.png )" ]]; then + OCTOSCREEN_BOOT_SPLASH="${OCTOSCREEN_BOOT_SPLASH}/*.png" + echo "OCTOSCREEN_BOOT_SPLASH is a directory with PNGs, globbing ( $OCTOSCREEN_BOOT_SPLASH )" + else + echo "OCTOSCREEN_BOOT_SPLASH is neither a PNG file, or directory with PNG files. Exiting" + exit 1 + fi + fi + + if [[ ! "$( ls -A $OCTOSCREEN_BOOT_SPLASH )" ]]; then + echo "Can not resolve any files from supplied path ( $OCTOSCREEN_BOOT_SPLASH ), exiting." + exit 1; + fi + + echo "Using Frame Buffer ( $FRAME_BUFFER ) and image/directory ( $OCTOSCREEN_BOOT_SPLASH )" + /usr/bin/fbi --noverbose --autodown -t 1 -d $FRAME_BUFFER $OCTOSCREEN_BOOT_SPLASH +fi diff --git a/debian/local/octoscreen/config b/debian/local/octoscreen/config index 002dd806..5c2f6fdf 100755 --- a/debian/local/octoscreen/config +++ b/debian/local/octoscreen/config @@ -50,3 +50,8 @@ OCTOSCREEN_LOG_LEVEL=Error OCTOSCREEN_RESOLUTION=800x480 # OCTOSCREEN_RESOLUTION is optional and defaults to 800x480 if missing # (defined in globalVars.go) + +# Path to the OctoScreen Splash Image. +# Must be a *.png file, or a directory containing PNG files +# Default is the directory: +# OCTOSCREEN_BOOT_SPLASH=/opt/octoscreen/styles/z-bolt/images/boot-splash/ \ No newline at end of file diff --git a/debian/octoscreen.postinst b/debian/octoscreen.postinst index 6e130764..8e4d4da9 100755 --- a/debian/octoscreen.postinst +++ b/debian/octoscreen.postinst @@ -45,6 +45,29 @@ if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then fi fi +# Install the octoscreen Splash +if [ "$1" = configure ] && [ -f /lib/systemd/system/octosplash.service ]; then + echo "Configuring OctoSplash Service" + _fb=$(ls -1at /dev/fb* | grep -E "^/dev/fb[0-9]\$" | head -1) + __fb=$(grep -oP "(?<=[[:space:]])(/dev/fb[0-9])(?=[[:space:]]*)\$" /lib/systemd/system/octosplash.service ) + if [ -z "$_fb" ] || [ -z "$__fb" ]; then + echo "Unable to determine Frame Buffer, skipping" + else + if ! grep -qE "^\w*disable_splash=1\w*\$" /boot/config.txt; then + echo "Dissabling default Raspberry Pi boot splash" + echo "disable_splash=1" >> /boot/config.txt + fi + if [ "$_fb" != "$__fb" ]; then + echo "Setting Frame Buffer to '$_fb'" + sed -i "s~$__fb~$_fb~g" /lib/systemd/system/octosplash.service + fi + if grep -q 'tty1' /boot/cmdline.txt ; then + echo "Redirecting boot messages and disabling cursor" + sed -i 's/console=tty1/console=tty3 logo.nologo consoleblank=0 loglevel=1 quiet vt.global_cursor_default=0/g' /boot/cmdline.txt + fi + fi +fi + db_stop || true #DEBHELPER# diff --git a/debian/octoscreen.service b/debian/octoscreen.service index 7cbb15a0..fd175c40 100644 --- a/debian/octoscreen.service +++ b/debian/octoscreen.service @@ -8,6 +8,7 @@ Type=notify NotifyAccess=all EnvironmentFile=/etc/octoscreen/config ExecStart=/usr/bin/xinit /usr/bin/OctoScreen -- :0 -nolisten tcp -nocursor +ExecStartPost=/bin/bash -xc '/usr/bin/systemctl stop --quiet octosplash && exit 0 || exit 0' ExecStartPost=/bin/bash /etc/octoscreen/disablescreenblank.sh 0 StandardOutput=journal Restart=always diff --git a/debian/octosplash.service b/debian/octosplash.service new file mode 100644 index 00000000..743895ca --- /dev/null +++ b/debian/octosplash.service @@ -0,0 +1,14 @@ +[Unit] +Description=OctoScreen Boot Splash Screen +DefaultDependencies=no +After=local-fs.target + +[Service] +EnvironmentFile=/etc/octoscreen/config +ExecStart=/bin/bash /etc/octoscreen/boot_splash.sh /dev/fb0 +StandardOutput=journal+console +StandardInput=tty + +[Install] +WantedBy=sysinit.target +WantedBy=multi-user.target diff --git a/debian/rules b/debian/rules index 55088c60..95aa480e 100755 --- a/debian/rules +++ b/debian/rules @@ -17,6 +17,10 @@ override_dh_auto_build: -X $(DH_GOPKG)/ui.Build=$(BUILD_DATE)\ " +override_dh_installinit: + dh_installinit --name=octosplash + dh_installinit --name=octoscreen + override_dh_golang: # The dh_golang is used to add the Built-using field to the deb. This is only for reference. # https://github.com/git-lfs/git-lfs/pull/2203/files diff --git a/styles/z-bolt/images/boot-splash/loading0.png b/styles/z-bolt/images/boot-splash/loading0.png new file mode 100644 index 00000000..b4b7d6d6 Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading0.png differ diff --git a/styles/z-bolt/images/boot-splash/loading1.png b/styles/z-bolt/images/boot-splash/loading1.png new file mode 100644 index 00000000..b6f62ae3 Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading1.png differ diff --git a/styles/z-bolt/images/boot-splash/loading2.png b/styles/z-bolt/images/boot-splash/loading2.png new file mode 100644 index 00000000..b4a38df1 Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading2.png differ diff --git a/styles/z-bolt/images/boot-splash/loading3.png b/styles/z-bolt/images/boot-splash/loading3.png new file mode 100644 index 00000000..232e425f Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading3.png differ diff --git a/styles/z-bolt/images/boot-splash/loading4.png b/styles/z-bolt/images/boot-splash/loading4.png new file mode 100644 index 00000000..170730cb Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading4.png differ diff --git a/styles/z-bolt/images/boot-splash/loading5.png b/styles/z-bolt/images/boot-splash/loading5.png new file mode 100644 index 00000000..0d8dbfed Binary files /dev/null and b/styles/z-bolt/images/boot-splash/loading5.png differ