| 1 | #! /bin/sh |
| 2 | set -e |
| 3 | |
| 4 | THEMES="buster ceratopsian emerald homeworld softwaves spacefun" |
| 5 | |
| 6 | basename="$(basename "$0")" |
| 7 | edutheme="${basename}" |
| 8 | edutheme="${edutheme#update-debian-edu-artwork-}" |
| 9 | |
| 10 | if [ "${edutheme}" = "${basename}" ]; then |
| 11 | echo "${basename} script called directly, please call ${basename}-<theme> scripts (symlinks) instead." |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | set_active_theme() { |
| 16 | update-alternatives --install \ |
| 17 | /usr/share/desktop-base/active-theme \ |
| 18 | desktop-theme \ |
| 19 | /usr/share/desktop-base/debian-edu-${edutheme}-theme 60 |
| 20 | } |
| 21 | |
| 22 | restore_active_theme() { |
| 23 | update-alternatives --remove \ |
| 24 | desktop-theme \ |
| 25 | /usr/share/desktop-base/debian-edu-${edutheme}-theme |
| 26 | } |
| 27 | |
| 28 | ## GRUB and PXE boot background |
| 29 | change_grub_background() { |
| 30 | update-alternatives --install /usr/share/images/desktop-base/desktop-grub.png \ |
| 31 | desktop-grub \ |
| 32 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub-4x3.png 40 \ |
| 33 | --slave /usr/share/desktop-base/grub_background.sh \ |
| 34 | desktop-grub.sh \ |
| 35 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub_background.sh |
| 36 | update-alternatives --install /usr/share/images/desktop-base/desktop-grub.png \ |
| 37 | desktop-grub \ |
| 38 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub-16x9.png 40 \ |
| 39 | --slave /usr/share/desktop-base/grub_background.sh \ |
| 40 | desktop-grub.sh \ |
| 41 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub_background.sh |
| 42 | if command -v update-grub > /dev/null ; then |
| 43 | # We have seen situations where grub is installed at the end of an |
| 44 | # installation, but /boot/grub has not been created, yet, when running |
| 45 | # this postinst's script function code. |
| 46 | # |
| 47 | # This e.g. can be observed when installing debian-edu-router using FAI. |
| 48 | mkdir -p /boot/grub |
| 49 | |
| 50 | sync |
| 51 | update-grub || true |
| 52 | fi |
| 53 | } |
| 54 | |
| 55 | restore_grub_background() { |
| 56 | update-alternatives --remove desktop-grub \ |
| 57 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub-4x3.png |
| 58 | update-alternatives --remove desktop-grub \ |
| 59 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/grub/grub-16x9.png |
| 60 | if command -v update-grub > /dev/null ; then |
| 61 | update-grub || true |
| 62 | fi |
| 63 | } |
| 64 | |
| 65 | ## Wallpaper |
| 66 | change_desktop_background() { |
| 67 | update-alternatives --install \ |
| 68 | /usr/share/images/desktop-base/desktop-background \ |
| 69 | desktop-background \ |
| 70 | /usr/share/desktop-base/active-theme/wallpaper/contents/images/1920x1080.svg 70 |
| 71 | update-alternatives --install \ |
| 72 | /usr/share/images/desktop-base/desktop-background.xml \ |
| 73 | desktop-background.xml \ |
| 74 | /usr/share/desktop-base/active-theme/wallpaper/gnome-background.xml 50 |
| 75 | update-alternatives --install \ |
| 76 | /usr/share/images/desktop-base/desktop-background.xml \ |
| 77 | desktop-background.xml \ |
| 78 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/wallpaper/gnome-background.xml 50 |
| 79 | |
| 80 | for wallpaper in \ |
| 81 | "/usr/share/desktop-base/debian-edu-${edutheme}-theme/wallpaper/contents/images/"[0-9]*x*.svg; |
| 82 | do |
| 83 | update-alternatives --install \ |
| 84 | /usr/share/images/desktop-base/desktop-background \ |
| 85 | desktop-background \ |
| 86 | "${wallpaper}" 50 |
| 87 | done |
| 88 | } |
| 89 | |
| 90 | restore_desktop_background() { |
| 91 | update-alternatives --remove \ |
| 92 | desktop-background \ |
| 93 | /usr/share/desktop-base/active-theme/wallpaper/contents/images/1920x1080.svg |
| 94 | update-alternatives --remove \ |
| 95 | desktop-background.xml \ |
| 96 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/wallpaper/gnome-background.xml |
| 97 | |
| 98 | for wallpaper in \ |
| 99 | "/usr/share/desktop-base/debian-edu-${edutheme}-theme/wallpaper/contents/images/"[0-9]*x*.svg; |
| 100 | do |
| 101 | update-alternatives --remove \ |
| 102 | desktop-background \ |
| 103 | "${wallpaper}" |
| 104 | done |
| 105 | } |
| 106 | |
| 107 | ## Plymouth |
| 108 | set_plymouth_theme() { |
| 109 | # The check whether we are on a Debian Edu system is vital for this part of |
| 110 | # the script being compliant with Debian policy. Never remove that check! |
| 111 | # See: #1057815 and #856789. |
| 112 | if [ -f /etc/plymouth/plymouthd.conf ] && [ -f /etc/debian-edu/config ] && command -v plymouth-set-default-theme > /dev/null ; then |
| 113 | plymouth-set-default-theme -R debian-edu-${edutheme} || true |
| 114 | fi |
| 115 | } |
| 116 | |
| 117 | restore_plymouth_theme() { |
| 118 | if [ -f /etc/plymouth/plymouthd.conf ] && command -v plymouth-set-default-theme > /dev/null ; then |
| 119 | plymouth-set-default-theme -R -r || true |
| 120 | fi |
| 121 | } |
| 122 | |
| 123 | ## Lockscreen |
| 124 | set_lockscreen() { |
| 125 | update-alternatives --install \ |
| 126 | /usr/share/images/desktop-base/desktop-lockscreen.xml \ |
| 127 | desktop-lockscreen.xml \ |
| 128 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/lockscreen/gnome-background.xml 50 |
| 129 | } |
| 130 | |
| 131 | restore_lockscreen() { |
| 132 | update-alternatives --remove \ |
| 133 | desktop-lockscreen.xml \ |
| 134 | /usr/share/desktop-base/debian-edu-${edutheme}-theme/lockscreen/gnome-background.xml |
| 135 | } |
| 136 | |
| 137 | is_valid=false |
| 138 | for theme in $THEMES; do |
| 139 | if [ "${edutheme}" = "${theme}" ]; then |
| 140 | is_valid=true |
| 141 | fi |
| 142 | done |
| 143 | $is_valid || exit 1 |
| 144 | |
| 145 | case "$1" in |
| 146 | configure) |
| 147 | for theme in $THEMES; do |
| 148 | [ "${theme}" = "${edutheme}" ] && continue |
| 149 | if [ -x "/usr/sbin/update-debian-edu-artwork-${theme}" ]; then |
| 150 | "/usr/sbin/update-debian-edu-artwork-${theme}" remove |
| 151 | fi |
| 152 | done |
| 153 | set_active_theme |
| 154 | change_grub_background |
| 155 | change_desktop_background |
| 156 | set_plymouth_theme |
| 157 | set_lockscreen |
| 158 | ;; |
| 159 | remove) |
| 160 | restore_active_theme |
| 161 | restore_grub_background |
| 162 | restore_desktop_background |
| 163 | restore_plymouth_theme |
| 164 | restore_lockscreen |
| 165 | ;; |
| 166 | esac |