summaryrefslogtreecommitdiff
path: root/bin/set-grub-theme.sh
blob: f3f52fee299d68ea5ed0660bfb3fd3d2d76aa8ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

readonly THEME_PKG_OR_DIR=$1
readonly GRUB_DIR=/boot/grub
readonly THEMES_DIR=$GRUB_DIR/themes
readonly THEME_FILENAME='theme.txt'
readonly SYMLINK_NAME='parabola-laf'
readonly GRUB_DEF_FILE=/etc/default/grub
readonly GRUB_CONFIG_FILE=$GRUB_DIR/grub.cfg
readonly THEME_KVP="GRUB_THEME=$THEMES_DIR/$SYMLINK_NAME/$THEME_FILENAME"


SwtichTheme() # (theme_dirname)
{
  local theme_dirname=$1
  local theme_file=$THEMES_DIR/$theme_dirname/$THEME_FILENAME

  [ -f "$theme_file" ] || return

  ln -fs $THEMES_DIR/$theme_dirname $THEMES_DIR/$SYMLINK_NAME
  [ "$(grep '^GRUB_THEME=' $GRUB_DEF_FILE | tail -n 1)" != "$THEME_KVP" ] || return

#   sed 's|\s*#*\s*GRUB_THEME\s*=.*|'$THEME_KVP'|g' /etc/default/grub
  echo $THEME_KVP >> $GRUB_DEF_FILE
  grub-mkconfig -o $GRUB_CONFIG_FILE
}

case $THEME_PKG_OR_DIR in
  'breeze-grub'         ) SwtichTheme 'breeze'          ;;
  'deepin-grub2-themes' ) SwtichTheme 'deepin'          ;;
  'grub2-theme-gnuaxiom') SwtichTheme 'GNUAxiom'        ;;
  'parabola-laf'        ) SwtichTheme 'GNUAxiom'        ;;
  *                     ) SwtichTheme $THEME_PKG_OR_DIR ;;
esac