wok-6.x view slitaz-fbsplash/stuff/tazfbsplash @ rev 12752

Up erlang (R15B01)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 11 13:17:29 2012 +0200 (2012-05-11)
parents
children
line source
1 #!/bin/sh
2 #
3 # Tazfbsplash - Tool to manage and configure Busybox fbsplash on SliTaz
4 # (C) 2011 SliTaz - GNU General Public License.
5 #
6 # TODO:
7 # box - on/off with curent status
8 # box - change/install/remove themes
9 # check GRUB settings: quiet vga=*
10 #
12 . /etc/rcS.conf
14 # Functions
16 . /usr/lib/slitaz/libtaz
17 source_lib commons
19 usage() {
20 echo -e "\nSliTaz graphical boot configuration tool\n
21 \033[1mUsage:\033[0m `basename $0` [command] [theme]
22 \033[1mCommands: \033[0m
23 on Enable graphical boot.
24 off Disable graphical boot.
25 list-themes List all installed themes.
26 change-theme Change current theme.
27 pack-theme Pack a system theme in a tar archive.
28 install-theme Install a fbsplash-theme-* archive.
29 test Test a theme configuration (Must be run in text mode).
30 box Graphical configuration box.\n"
31 }
33 separator() {
34 echo "================================================================================"
35 }
37 change_theme()
38 {
39 sed -i s~FBSPLASH_THEME=.*~FBSPLASH_THEME=\"$new_theme\"~ /etc/rcS.conf
40 }
42 # GUI box (not yet ready :-)
43 box() {
44 export MAIN_DIALOG='
45 <window title="Tazfbsplash Box" icon-name="preferences-desktop-wallpaper">
46 <vbox>
47 <text use-markup="true">
48 <label>"
49 <b>SliTaz Fbsplash Box</b>"</label>
50 </text>
51 <text wrap="true" width-chars="50" use-markup="true">
52 <label>"SliTaz graphical boot manager
53 "</label>
54 </text>
55 <hbox>
56 <text use-markup="true">
57 <label>"<b>Theme:</b>"</label>
58 </text>
59 <entry>
60 <default>'$FBSPLASH_THEME'</default>
61 <variable>NEW_THEME</variable>
62 </entry>
63 <button>
64 <input file icon="text-editor"></input>
65 <action>editor /etc/fbsplash/$NEW_THEME/fbsplash.cfg</action>
66 </button>
67 <button>
68 <input file icon="forward"></input>
69 <action>tazfbsplash -ct $NEW_THEME</action>
70 </button>
71 </hbox>
72 <tree>
73 <width>320</width><height>120</height>
74 <variable>EDIT_THEME</variable>
75 <label>Themes list (double-click to edit config)</label>
76 <input>tazfbsplash -lt --box</input>
77 <action>editor /etc/fbsplash/$EDIT_THEME/fbsplash.cfg</action>
78 </tree>
79 <hbox>
80 <button>
81 <input file icon="exit"></input>
82 <action type="exit">exit</action>
83 </button>
84 </hbox>
85 </vbox>
86 </window>'
87 gtkdialog --center --program=MAIN_DIALOG
88 }
90 # Commands
92 case "$1" in
93 on)
94 # Enable graphical boot.
95 echo -en "\nEnabling SliTaz graphical boot..."
96 if [ ! `grep "rcS > /dev/null" /etc/inittab` ]; then
97 sed -i s'/rcS/rcS > \/dev\/null/' /etc/inittab
98 fi
99 sed -i s'/FBSPLASH="no"/FBSPLASH="yes"/' /etc/rcS.conf
100 status && echo "" ;;
101 off)
102 # Disable graphical boot.
103 echo -en "\nDisabling SliTaz graphical boot..."
104 sed -i s'/rcS > \/dev\/null/rcS/' /etc/inittab
105 sed -i s'/FBSPLASH="yes"/FBSPLASH="no"/' /etc/rcS.conf
106 status && echo "" ;;
107 list-themes|-lt)
108 # List all themes
109 if [ "$2" != "--box" ]; then
110 echo -en "\n\033[1mBoot splash themes\033[0m"
111 separator
112 fi
113 cd /etc/fbsplash
114 for i in *
115 do
116 [ -f "/etc/fbsplash/$i/fbsplash.cfg" ] && echo $i
117 done
118 [ "$2" != "--box" ] && echo "" ;;
119 change-theme|-ct)
120 new_theme="$2"
121 [ -z "$new_theme" ] && exit 0
122 [ ! -d "/etc/fbsplash/$new_theme" ] && exit 0
123 echo -n "Activing fbsplash theme: $new_theme"
124 change_theme && status ;;
125 pack-theme|-pt)
126 # Pack a theme into .tar.gz
127 theme="$2"
128 tmp=slitaz-fbsplash-$theme
129 if [ ! -d "/etc/fbsplash/$theme" ]; then
130 echo -e "\nNo theme found in: /etc/fbsplash/$theme\n"
131 exit 0
132 fi
133 echo -n "Creating fbsplash theme archive for: $theme"
134 mkdir -p $tmp
135 cp -r /etc/fbsplash/$theme $tmp
136 cat > $tmp/README << EOT
137 SliTaz graphical boot theme
138 ================================================================================
140 This is a Busybox fbsplash theme created on and for SliTaz GNU/Linux. To use it
141 you can copy files manually to /etc/fbsplash or use 'tazfbsplash install-theme'
142 EOT
143 busybox tar czf slitaz-fbsplash-$theme.tar.gz $tmp
144 rm -rf $tmp && status ;;
145 install-theme|-it)
146 check_root
147 file=$2
148 if [ ! -f "$file" ]; then
149 echo -e "\nNo theme archive: $file\n"
150 exit 0
151 fi
152 echo -n "Installing fbsplash theme..."
153 tar xzf $file -C /tmp
154 rm /tmp/slitaz-fbsplash-*/README
155 cp -r /tmp/slitaz-fbsplash-*/* /etc/fbsplash
156 status ;;
157 test|-t)
158 # Test suite for fbsplash on SliTaz (must be run in text mode).
159 fbsplash -c \
160 -s /etc/fbsplash/$FBSPLASH_THEME/fbsplash.ppm \
161 -i /etc/fbsplash/$FBSPLASH_THEME/fbsplash.cfg \
162 -f /etc/fbsplash/fifo &
163 for p in 0 10 20 30 40 50 60 70 80 90 100
164 do
165 echo "$p" > /etc/fbsplash/fifo && sleep 1
166 done > /dev/null
167 echo "exit" > /etc/fbsplash/fifo ;;
168 box|-b)
169 box ;;
170 *)
171 usage ;;
172 esac
173 exit 0