fbs view fbs @ rev 7

Tiny edits
author Paul Issott <paul@slitaz.org>
date Fri May 02 19:32:12 2014 +0100 (2014-05-02)
parents 889bd09f2370
children
line source
1 #!/bin/sh
2 #
3 # Fbs - Graphical framebuffer boot using Busybox fbsplash applet. No use of SliTaz
4 # specific code since it may be used by other distros or emb systems.
5 #
6 # (C) 2014 Christophe Lincoln - BSD License.
7 #
9 sysconf="/etc/fbs.conf"
10 themes="/usr/share/fbs"
11 fifo="/fbs.fifo"
13 [ -f "${sysconf}" ] && . ${sysconf}
14 [ -f "fbs.conf" ] && . fbs.conf
15 [ "$2" ] && FBTHEME="$2"
17 # Functions
19 boldify() {
20 echo -e "\033[1m$@\033[0m"
21 }
23 usage() {
24 cat << EOT
26 Framebuffer Boot Splash utility
28 $(boldify "Usage:") $(basename $0) [command] [theme]
30 $(boldify "Commands:")
31 on Enable graphical boot
32 off Disable graphical boot
33 test Test a splash theme
34 themes List all installed themes
35 set-theme Change current theme
36 pack-theme Pack a system theme
37 add-theme Install a fbs-theme archive
39 EOT
40 }
42 check_root() {
43 if [ $(id -u) != "0" ]; then
44 echo "Only root administrator can run fbs $1" && exit 1
45 fi
46 }
48 separator() {
49 echo "--------------------------------------"
50 }
52 set_theme() {
53 sed -i s'~FBTHEME=.*~FBTHEME=\"$new_theme\"~' /etc/fbs.conf
54 }
56 start_fbsplash() {
57 [ -x "$themes/$FBTHEME/init.sh" ] && \
58 ${themes}/${FBTHEME}/init.sh
59 mkfifo ${fifo}
60 fbsplash -c -f ${fifo} \
61 -s $themes/$FBTHEME/splash.ppm.gz \
62 -i $themes/$FBTHEME/splash.cfg &
63 }
65 # Commands
67 case "$1" in
69 on)
70 # Enable graphical boot
71 check_root
72 echo "Enabling SliTaz graphical boot..."
73 if ! grep -q "rcS > /dev/null 2>/dev/null" /etc/inittab; then
74 sed -i s'#rcS#rcS >/dev/null 2>/dev/null#' /etc/inittab
75 fi
76 sed -i s'/FBSPLASH=.*/FBSPLASH="on"/' /etc/fbs.conf ;;
78 off)
79 # Disable graphical boot
80 check_root
81 echo "Disabling SliTaz graphical boot..."
82 sed -i s'#rcS >/dev/null 2>/dev/null#rcS#' /etc/inittab
83 sed -i s'/FBSPLASH=.*/FBSPLASH="off"/' /etc/fbs.conf ;;
85 'test')
86 # Testsuite for fbs
87 reset && start_fbsplash
88 for p in 0 10 20 30 40 50 60 70 80 90 100
89 do
90 echo "$p" > ${fifo} && sleep 1
91 done #> /dev/null
92 echo "exit" > ${fifo}
93 clear && rm -f ${fifo};;
95 themes)
96 # List all themes
97 echo ""
98 boldify "Fbs themes list"
99 separator
100 cd ${themes}
101 ls -1 && echo "" ;;
103 set-theme)
104 check_root
105 new_theme="$2"
106 [ "$new_theme" ] || exit 0
107 [ -d "$themes/$new_theme" ] || exit 0
108 echo -n "Enabling fbs theme: $new_theme"
109 set_theme; status ;;
111 pack-theme)
112 # Pack a theme into .tar.gz
113 theme="$2"
114 tmp=fbs-theme-$theme
115 if [ ! -d "$themes/$theme" ]; then
116 echo "No theme found in: $themes/$theme"; exit 0
117 fi
118 echo -n "Creating fbs theme archive: $theme"
119 mkdir -p $tmp
120 cp -r $themes/$theme $tmp
121 cat > $tmp/README << EOT
122 Fbs theme - Framebuffer Splash boot artwork
123 $(separator)
126 This is a Busybox fbsplash theme created by $USER. To use it you can copy
127 files manually to $themes or use 'fbs add-theme'
130 $(separator)
131 EOT
132 busybox tar czf fbs-theme-$theme.tar.gz $tmp
133 rm -rf $tmp; status ;;
135 add-theme)
136 check_root
137 file=$2
138 if [ ! -f "$file" ]; then
139 echo "Missing theme archive: $file"; exit 0
140 fi
141 echo -n "Installing fbs theme: ${file%.tar.gz}"
142 tar xzf $file -C /tmp
143 rm /tmp/fbs-theme-*/README
144 cp -r /tmp/fbs-*/* ${themes}
145 status ;;
147 start) start_fbsplash ;;
149 *) usage ;;
151 esac
152 exit 0