slitaz-tools view tazbox/tazbox @ rev 880

tazbox: huge update & bug fix
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue May 06 22:55:12 2014 +0300 (2014-05-06)
parents 472492f7eeef
children 2ed52c9c747f
line source
1 #!/bin/sh
2 #
3 # SliTaz tiny GUI boxes for the desktop (su, logout, locale, etc)
4 # and as usual, please: KISS
5 #
6 # Copyright (C) 2011-2014 SliTaz GNU/Linux - GNU GPL v3
7 # - Christophe Lincoln <pankso@slitaz.org>
8 # - Aleksej Bobylev <al.bobylev@gmail.com>
9 #
10 . /lib/libtaz.sh
11 export TEXTDOMAIN='tazbox' # i18n
13 # download dir (may be in a config file)
14 DOWNLOADS=$HOME/Downloads
16 # some constants to be used inside functions
17 tmp=/tmp/keymap.list
18 db=/usr/share/i18n/locales
19 zi=/usr/share/zoneinfo/
20 ztab=${zi}zone-mini.tab
21 csv=/tmp/freegeoip.csv
23 #
24 # Functions
25 #
27 usage() {
28 newline; _ 'SliTaz tiny GUI boxes for the desktop'
30 newline; boldify $(_ 'Usage:')
31 echo " $(basename $0) [$(_n 'command')]"
33 newline; boldify $(_ 'Commands:')
34 optlist "\
35 usage $(_ 'Display this short help usage')
36 su $(_ 'Execute a command as super-user')
37 logout $(_ 'Desktop logout box with actions')
38 out $(_ 'Pipe a command output into a GTK window')
39 out-dl $(_ 'Pipe wget output into a GTK window')
40 locale $(_ 'Configure system language (root)')
41 keymap $(_ 'Configure system keymap (root)')
42 tz $(_ 'Configure system timezone (root)')
43 setup $(_ 'System initial setup (locale, keymap & timezone)')
44 new-file $(_ 'Create a new file or folder on the desktop')
45 all-apps $(_ 'Display icons of all installed applications')
46 notify $(_ 'Notify user with a desktop centered box')
47 tazapps $(_ 'Configure SliTaz default applications')"
48 newline
49 }
51 # try to find icon in .desktop files
52 find_icon() {
53 local desktop
54 desktop=$(find $HOME/.local/share/applications /usr/share/applications \
55 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
56 [ x$desktop != x ] && cat $desktop | sed '/\[Desktop\ Entry\]/,/^\[/!d' | \
57 sed '/^Icon=/!d' | head -n1 | cut -d= -f2
58 }
60 # su frontend GUIs
61 su_main() {
62 CMD1="$1"; shift; CMD2="$(echo $@ | sed 's|&|&amp;|g')"
63 : ${icon=$(find_icon $CMD1)}
64 [ x$icon == x ] && icon=gtk-dialog-authentication
66 yad --title="$(_n 'SliTaz admin password')" --window-icon=$icon \
67 --width=520 --on-top --center \
68 --image=$icon --image-on-top \
69 --text="$(_n 'Please enter root password (default root) to execute:')\n
70 <span foreground=\"red\"><tt><b>$CMD1</b> $CMD2</tt></span>\n" \
71 --form \
72 --field="$(_n 'Password:'):H" $PASSWD \
73 --field="$(_n 'Autosave password'):CHK" $CHECKED
74 }
76 su_error() {
77 icon=gtk-dialog-error
78 yad --title="$(_n 'Error')" --window-icon=$icon \
79 --width=320 --on-top --center \
80 --image=$icon --image-on-top \
81 --text="\n<b>$(_n 'Error: wrong password!')</b>\n" \
82 --button="gtk-close:1"
83 }
85 # user may press cancel on download.
86 cancel_dl() {
87 if [ "$?" == 1 ]; then
88 _ "CANCEL"
89 rm -f $DOWNLOADS/$(basename $url)
90 fi
91 }
93 # output a command in a GTK window
94 output_command() {
95 : ${title=$(_n 'TazBox Output')}
96 : ${icon=gtk-dialog-info}
98 yad --title="$title" --window-icon=$icon \
99 --geometry="600x220+0-24" --fore="#ffffff" --back="#000000" \
100 --text-info --fontname=monospace --wrap $opts \
101 --button="gtk-close:1"
102 }
104 # logout GUI function
105 logout_main() {
106 icon=/usr/share/pixmaps/slitaz-icon.png
107 yad --title="$(_n 'SliTaz Logout')" --window-icon=$icon \
108 --on-top --center --height=130 \
109 --image=$icon --image-on-top \
110 --text="<b>$(_n 'SliTaz Logout - Please choose an action:')</b>" \
111 --always-print-result \
112 --button "$(_n 'Close X session')!system-log-out:4" \
113 --button "$(_n 'Reboot system')!reload:3" \
114 --button "$(_n 'Shutdown system')!system-shutdown:2"
115 }
117 # generate keymap list
118 gen_kmap_list() {
119 echo > $tmp
120 cd /usr/share/kbd/keymaps/i386
121 # we first need a list to sort and then use \n for Yad list.
122 for i in $(find -type f | sed '/include/d; s|./||'); do
123 echo "$(basename $i .map.gz)|$(dirname $i)" >> $tmp
124 done
125 }
127 # Initial Config functions
128 setup_main() {
129 icon=locale
130 gen_kmap_list
131 locale=$(ls -1 $db | grep ^[a-z][a-z]_[A-Z][A-Z] | tr "\n" "!")
132 keymap=$(cat $tmp | sort | tr "\n" "!")
133 timezone=$(find $zi -type f | sed s,$zi,,g | grep -v -F '.tab' | tr "\n" "!")
134 yad --title="$(_n 'SliTaz Initial Setup')" --window-icon=$icon \
135 --width=500 \
136 --image=$icon --image-on-top \
137 --text="<big>$(_n 'Here you can set your preferences \n for <b>locale, keymap and timezone</b>.')</big>" \
138 --form \
139 --field "$(_n 'Locale'):CB" $locale \
140 --field "$(_n 'Keymap'):CB" $keymap \
141 --field "$(_n 'Timezone'):CB" $timezone
142 }
144 setup() {
145 choices=$(setup_main)
146 locale=$(echo $choices | cut -d"|" -f1)
147 keymap=$(echo $choices | cut -d"|" -f2)
148 timezone=$(echo $choices | cut -d"|" -f3)
149 [ $locale ] && tazlocale init $locale
150 [ $keymap ] && tazkeymap init $keymap
151 [ $timezone ] && echo $timezone > /etc/TZ
152 }
155 #
156 # Locale functions
157 #
159 locale_main() {
160 icon=preferences-desktop-locale
161 for locale in $(ls -1 $db | grep '[a-z]_[A-Z]'); do
162 desc=$(fgrep -m1 title $db/$locale | cut -d'"' -f2)
163 echo -e "${locale##*_}\n$locale\n$desc"
164 done | \
165 yad --title="$(_n 'SliTaz locale')" --window-icon=$icon \
166 --width=600 --height=380 --sticky --on-top --center \
167 --image=$icon --image-on-top \
168 --text="<b>$(_n 'Language configuration')</b> \
169 \n\n$(_ 'Tip: manage locale list by installing/removing locale packages.')" \
170 --list --column="$(_n 'Flag'):IMG" --column $(_n 'Name') \
171 --column $(_n 'Description') \
172 --print-column=2 --separator='' \
173 --button="$(_n 'Manage')!stock_properties:2" \
174 --button="gtk-cancel:1" --button="gtk-ok:0"
175 }
177 locale() {
178 locale=$(locale_main)
179 # Deal with --button values
180 case $? in
181 2) tazbox manage_i18n main ;;
182 1) exit 0 ;;
183 *) continue ;;
184 esac
185 # System language configuration.
186 if [ "$locale" ]; then
187 tazlocale $locale
188 tazbox notify "$(_ 'Locale was set to $locale')" \
189 preferences-desktop-locale 3
190 fi
191 }
193 # Keymap functions
194 keymap_main() {
195 #icon=preferences-desktop-keyboard
196 icon=input-keyboard
197 gen_kmap_list
198 for i in $(sort $tmp); do
199 echo "$i" | tr '|' '\n'
200 done | \
201 yad --title="$(_ 'SliTaz keymap')" --window-icon=$icon \
202 --width=500 --height=380 --sticky --on-top --center \
203 --image=$icon --image-on-top \
204 --text="<b>$(_n 'Keyboard configuration')</b>" \
205 --list --column $(_n 'Keymap') --column $(_n 'Type') \
206 --print-column=1 --separator=''
207 rm -f $tmp
208 }
210 keymap() {
211 keymap=$(keymap_main)
212 # Deal with --button values
213 [ x$? == x1 ] && exit 0
214 # System keymap configuration
215 [ "$keymap" ] && tazkeymap $keymap
216 }
218 # Free GeoIP service
219 # Response: "IP","CountryCode","CountryName", ...
220 geoip() {
221 [ ! -e $csv ] && wget -q -T3 -O $csv http://freegeoip.net/csv/ 2&>/dev/null
222 [ -e $csv ] && cut -d'"' -f4 $csv
223 }
225 #
226 # TZ functions
227 #
229 # list of all existing available locations for country
230 tz_list() {
231 find $zi | \
232 grep -E "$(cat $ztab | grep "^$1 " | cut -d' ' -f2 | tr ' ' '|')" | \
233 grep -v -E "posix|right" | \
234 sed 's|.*/||g' | sort
235 }
237 # ask for confirmation only if we have what to choose
238 tz_suggest() {
239 CountryCode=$(geoip)
240 if [ "x$CountryCode" != x ]; then
241 if [ "x$(tz_list $CountryCode)" != x ]; then
242 CountryName=$(cut -d'"' -f6 $csv)
243 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
244 --on-top --center \
245 --image=$CountryCode --image-on-top \
246 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
247 $(_ 'Are you agreed?')" \
248 --button="gtk-yes:0" --button="gtk-no:1"
249 [ $? == 0 ] && echo $CountryCode
250 fi
251 fi
252 }
254 tz_select() {
255 case x$1 in
256 x)
257 # first pass - country
258 tmpcc=$(mktemp)
260 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
261 grep -m1 $(basename $tzfile) $ztab
262 done | cut -d' ' -f1 | sort -u > $tmpcc
264 for CC in $(cat $tmpcc); do
265 cat << EOT
266 $CC
267 $CC
268 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d' ' -f2)
269 EOT
270 done | \
271 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
272 --width=500 --height=380 --on-top --center \
273 --image=$icon --image-on-top \
274 --text="<b>$(_ 'TimeZone Configuration')</b> \
275 \n$(_ 'Select country and press "Forward" or manual select timezone file.') \
276 \n\n$(_ 'Tip: manage timezone list by installing/removing locale packages.')" \
277 --list \
278 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
279 --button="$(_n 'Manage')!stock_properties:4" \
280 --button="$(_n 'Manual')!gtk-index:2" \
281 --button="gtk-go-forward:0" \
282 --button="gtk-cancel:1" --always-print-result \
283 --print-column=2 --separator=''
284 ;;
285 xindex)
286 # manual selection of file with timezone info
287 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
288 --width=500 --on-top --center \
289 --image=$icon --image-on-top \
290 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
291 --form --field=":FL" ${zi}UTC --separator='' | \
292 sed "s|$zi||"
293 ;;
294 *)
295 # second pass - city/place
296 list=$(tz_list $1)
297 icon=$1
298 if [ $(echo "$list" | wc -l) != 1 ]; then
299 echo "$list" | \
300 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
301 --width=500 --height=380 --on-top --center \
302 --image=$icon --image-on-top \
303 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
304 --list --column $(_n 'Location/City') --separator=''
305 else
306 echo $list
307 fi
308 ;;
309 esac
310 }
312 tz() {
313 icon=clock
314 arg=$(tz_suggest)
316 timezone=$(tz_select $arg)
317 case $? in
318 1) exit 0 ;;
319 0) [ x$arg == x ] && timezone=$(tz_select "$timezone")
320 [ x$timezone == x ] && exit 0
321 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
322 sed "s|$zi||") ;;
323 2) timezone=$(tz_select "index") ;;
324 4) tazbox manage_i18n main;;
325 esac
327 [ "x$timezone" == x ] && exit 0
328 echo $timezone > /etc/TZ
329 export TZ=$timezone
330 tazbox notify "$(_ 'TimeZone was set to $timezone')" $icon 3
331 rm -f $tmpcc
332 }
334 #
335 # Manage i18n packages
336 #
338 # if installed
339 if_installed() {
340 [ -d /var/lib/tazpkg/installed/$1 ]
341 }
343 # get package's description, install flag and sizes
344 desc_etc()
345 {
346 INFO="$(grep -m1 -A3 -x -F $1 /var/lib/tazpkg/packages.txt)"
347 DESC=$(echo "$INFO" | sed -n 3p)
348 if if_installed $1; then
349 INST="TRUE"; echo $1 >> $ORIG_LIST
350 else
351 INST="FALSE"
352 fi
353 SIZES=$(echo "$INFO" | sed -n 4p)
354 SIZE1=${SIZES%% *}
355 SIZE2=$(echo $SIZES | cut -d' ' -f2 | tr -d '(')
356 echo -e "$INST\n$1\n$DESC\n${SIZE1//.0}\n${SIZE2//.0}" >> $PKGS_LIST
357 }
359 # remove temp
360 rm_temp() {
361 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
362 }
364 # install/remove locale packages
365 manage_i18n() {
366 tazbox notify "$(_ 'Please wait')" appointment-soon &
368 PKGS_LIST=$(mktemp)
369 ORIG_LIST=$(mktemp)
370 ANSWER=$(mktemp)
371 NEW_LIST=$(mktemp)
372 LIST1=$(mktemp)
373 LIST2=$(mktemp)
374 PLIST=/var/lib/tazpkg/packages.list
376 for i in $(grep -E '^locale' $PLIST | grep -v 'extra' | \
377 sed 's|\(locale-[a-zA-Z_]*\).*|\1|'); do
378 desc_etc $i
379 done
381 if [ "x$1" != xmain ]; then
382 for i in $(grep -E '^locale' $PLIST | grep 'extra' | \
383 sed 's|\(locale-[a-zA-Z_]*-extra\).*|\1|'); do
384 desc_etc $i
385 done
386 if if_installed libQtCore; then
387 for i in $(grep -E '^qt-locale' $PLIST | \
388 sed 's|\(qt-locale-[a-zA-Z_]*\).*|\1|'); do
389 desc_etc $i
390 done
391 fi
392 if if_installed razorqt; then
393 for i in $(grep -E '^razorqt-locale' $PLIST | \
394 sed 's|\(razorqt-locale-[a-zA-Z_]*\).*|\1|'); do
395 desc_etc $i
396 done
397 fi
398 if if_installed firefox; then
399 for i in $(grep -E '^firefox-langpack' $PLIST | \
400 sed 's|\(firefox-langpack-[a-zA-Z_]*\).*|\1|'); do
401 desc_etc $i
402 done
403 fi
404 if if_installed thunderbird; then
405 for i in $(grep -E '^thunderbird-langpack' $PLIST | \
406 sed 's|\(thunderbird-langpack-[a-zA-Z_]*\).*|\1|'); do
407 desc_etc $i
408 done
409 fi
410 if if_installed squirrelmail; then
411 for i in $(grep -E '^squirrelmail' $PLIST | \
412 grep -E '^squirrelmail-[a-z][a-z][_-]' | \
413 sed 's|\(squirrelmail-[a-zA-Z_]*\)-.*|\1|'); do
414 desc_etc $i
415 done
416 fi
417 if if_installed aspell; then
418 for i in $(grep -E '^aspell' $PLIST | \
419 grep -E 'aspell-[a-z][a-z][^a-z]' | \
420 sed 's|\(aspell-[a-zA-Z_]*\)-.*|\1|'); do
421 desc_etc $i
422 done
423 fi
424 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
425 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
426 ufraw|-locales qupzilla|-locales"
427 for i in $OTHER_LOCALE; do
428 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
429 done
430 fi
432 icon=stock_properties
433 cat $PKGS_LIST | \
434 {
435 yad --title="$(_n 'Manage locale packages')" --window-icon=$icon \
436 --width=600 --height=400 --on-top --center \
437 --image=$icon --image-on-top \
438 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
439 --list --multiple --ellipsize=END --expand-column=3 \
440 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
441 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
442 --column="$(_n 'Installed'):TEXT" \
443 --button="$(_n 'Recharge list')!reload:tazbox recharge" \
444 --button="$(_n 'Install/Remove')!system-upgrade:2" \
445 --button="gtk-cancel:1" \
446 --print-all
447 } > $ANSWER
449 if [ "x$?" == "x1" ]; then rm_temp; exit 0; fi
451 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
453 # check difference between ORIG_LIST and NEW_LIST
454 sort -o $LIST1 $ORIG_LIST
455 sort -o $LIST2 $NEW_LIST
456 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
457 if [ "x$DIFF" == "x" ]; then rm_temp; exit 0; fi
459 # output log to gtk window
460 title="$(_n 'TazPkg log')"; icon="tazpkg"; opts="--tail"
461 {
462 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
463 _ 'REMOVE: $pkg'
464 yes | tazpkg -r $pkg --output="raw"
465 done
466 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
467 _ 'INSTALL: $pkg'
468 tazpkg -gi $pkg --output="raw"
469 done
470 echo -e "\n\n$(_n 'Done!')\n"
471 } | output_command
472 rm_temp
473 }
477 # New file functions
478 newfile_main() {
479 icon=gtk-new
480 yad --title="$(_n 'New file')" --window-icon=$icon \
481 --width=460 --height=160 --on-top --center \
482 --image=$icon --image-on-top \
483 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
484 --entry --entry-label="$(_n 'File name')" \
485 --ricon=editclear \
486 --always-print-result \
487 --button="$(_n 'SHell script')!application-x-shellscript:4" \
488 --button="$(_n 'Folder')!stock_folder:3" \
489 --icon="gtk-new" \
490 --button="$(_n 'File')!application-text:2" \
491 --button="gtk-cancel:1"
492 }
494 newfile() {
495 file=$(newfile_main)
496 ret=$?
497 [ "$file" ] || exit 0
498 case $ret in
499 4)
500 cat > $HOME/Desktop/$file << EOT
501 #!/bin/sh
502 #
504 EOT
505 chmod +x $HOME/Desktop/$file ;;
506 3) mkdir -p $HOME/Desktop/$file ;;
507 2) touch $HOME/Desktop/$file ;;
508 1) exit 0 ;;
509 esac
510 }
512 # All applications
513 all_apps() {
514 icon=stock_bookmark
515 yad --title="$(_n 'All Applications')" --window-icon=$icon \
516 --width=400 --height=400 \
517 --icons --compact \
518 --read-dir=/usr/share/applications \
519 --button="gtk-close:0"
520 }
522 # Generate alternatives list: first - current choice, following - existing apps
523 gen_alt() {
524 alts="$@"
525 current=$(echo $alts | cut -d' ' -f1)
526 alts=$(echo $alts | sed "s|$current||g")
527 for alt in $alts; do
528 [ ! $(busybox which $alt) ] && alts=$(echo $alts | sed "s|$alt||")
529 done
530 echo $current $alts | tr ' ' '!'
531 }
533 # Ask root permissions for system settings
534 ask_root() {
535 if [ $(id -u) != 0 ]; then
536 exec tazbox su $0 $@
537 exit 0
538 fi
539 }
541 #
542 # Commands
543 #
544 case "$1" in
545 su)
546 # Don't show dialog if we are root
547 test $(id -u) = 0 && exec ${@:2}
548 SU_CMD="${@:2}"
549 # Check if a password has been saved before launching main dialog
550 if [ -s $HOME/.config/slitaz/subox.conf ]; then
551 PASSWD=$(cat $HOME/.config/slitaz/subox.conf)
552 CHECKED="TRUE"
553 fi
554 # Display the main dialog (ask for password)
555 main=$(su_main $SU_CMD)
556 # Deal with --button values and exit if cancelled to avoid erasing
557 # saved password.
558 [ $? == 1 ] && exit 0
559 # Save or erase Autosaved password
560 if [ $(echo $main | cut -f2 -d"|") == "TRUE" ]; then
561 echo $main | cut -f 1 -d "|" > $HOME/.config/slitaz/subox.conf
562 chmod 0600 $HOME/.config/slitaz/subox.conf
563 else
564 cat /dev/null > $HOME/.config/slitaz/subox.conf
565 fi
566 # Try to login & execute. If password is wrong execute error dialog
567 SU_CMD_QUOTED="$(echo "$SU_CMD" | sed 's|&|\\&|g')"
568 echo $main | cut -f 1 -d "|" | su -c "$SU_CMD_QUOTED &" || su_error ;;
569 logout)
570 # Logout window with actions
571 if [ "$oldstyle" ]; then
572 answer=$(logout_oldstyle)
573 else
574 logout_main; answer=$?
575 fi
576 # Deal with --button values
577 # DE and WM started with a custom -session script should export
578 # XDG_CURRENT_DESKTOP
579 case $answer in
580 4|*exit)
581 case $XDG_CURRENT_DESKTOP in
582 LXDE)
583 [ "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
584 [ "$DESKTOP_SESSION" == "compiz" ] && killall compiz
585 openbox --exit ;;
586 openbox) openbox --exit ;;
587 compiz) killall compiz ;;
588 *)
589 # Try to kill other WM that dont set XDG var.
590 jwm -exit 2>/dev/null ;;
591 esac ;;
592 3|*reboot)
593 reboot || reboot -f ;;
594 2|*halt)
595 poweroff ;;
596 esac ;;
597 out)
598 # Pipe a command into a GTK window
599 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command ;;
600 out-dl)
601 # A tiny GTK window for Busybox wget output
602 url=$2; opts="--tail --button=gtk-cancel:1"
603 icon=folder-downloads; title="$(_ 'Downloading...')"
604 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
605 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
606 cancel_dl ;;
607 locale)
608 ask_root $@ && locale ;;
609 keymap)
610 ask_root $@ && keymap ;;
611 tz)
612 ask_root $@ && tz ;;
613 manage_i18n)
614 ask_root $@ && manage_i18n $2 ;;
615 recharge)
616 ask_root $@; opts="--on-top"; tazpkg recharge | output_command ;;
617 setup)
618 ask_root $@ && setup ;;
619 new-file)
620 newfile ;;
621 all-apps)
622 all_apps ;;
623 notify|-n)
624 # On screen notification box.
625 icon="$3"
626 time="$4"
627 [ "$icon" ] || icon=info
628 [ "$time" ] || time=4
629 yad --width=520 --height=80 --timeout=$time --timeout-indicator=right \
630 --on-top --center --no-buttons --borders=12 --undecorated \
631 --skip-taskbar --image=$icon --image-on-top --text="<b>$2</b>" ;;
632 tazapps)
633 # Default applications configuration script. System wide config file
634 # is /etc/slitaz/applications.conf and each user can have personal
635 # settings. System wide for root and personal config for user.
636 export CONFIG="$HOME/.config/slitaz/applications.conf"
637 if [ ! -f $CONFIG ]; then
638 mkdir -p $HOME/.config/slitaz
639 cp /etc/slitaz/applications.conf $CONFIG
640 fi
641 . $CONFIG
643 FILE_MANAGERS=$(gen_alt $FILE_MANAGER \
644 clex emelfm2 mc pathfinder pcmanfm ranger spacefm thunar xfe ytree)
645 BROWSERS=$(gen_alt $BROWSER \
646 arora chrome cream dillo elinks firefox iron links lynx midori \
647 netsurf opera retawq seamonkey surf tazweb)
648 EDITORS=$(gen_alt $EDITOR \
649 adie beaver emacs geany jed joe le leafpad mousepad mp-5 nano \
650 SciTE vi vim xedit xfw zile)
651 TERMINALS=$(gen_alt $TERMINAL \
652 aterm evilvte lxterminal mrxvt sakura stjerm tilda urxvt vte xterm \
653 yeahconsole)
654 WINDOW_MANAGERS=$(gen_alt $WINDOW_MANAGER \
655 awesome blackbox dwm echinus enlightenment fluxbox icewm jwm \
656 karmen matchbox openbox-session pekwm ratpoison xfwm4)
658 icon=preferences-desktop-default-applications
659 eval $(yad --title="$(_n 'SliTaz default applications')" \
660 --window-icon=$icon --image=$icon --image-on-top \
661 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
662 --form \
663 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
664 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
665 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
666 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
667 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
668 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
669 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
671 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
672 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
673 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
674 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
675 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
676 -i $CONFIG ;;
677 gpl)
678 yad --title="GNU General Public License" --window-icon=text-x-generic \
679 --geometry="650x500" \
680 --image=/usr/share/pixmaps/gpl3.png --image-on-top \
681 --center \
682 --text-info \
683 --fontname=monospace \
684 --button "OK" < /usr/share/licenses/gpl.txt ;;
685 *)
686 usage ;;
687 esac
689 exit 0