slitaz-tools view tazbox/tazbox @ rev 886

tazbox: fix country flag for "@euro" locales; make pot & make msgmerge.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri May 23 03:36:33 2014 +0300 (2014-05-23)
parents 2ed52c9c747f
children fade59ccdd1f
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 ll_CC=${locale%%@*}
164 echo -e "${ll_CC##*_}\n$locale\n$desc"
165 done | \
166 yad --title="$(_n 'SliTaz locale')" --window-icon=$icon \
167 --width=600 --height=380 --sticky --on-top --center \
168 --image=$icon --image-on-top \
169 --text="<b>$(_n 'Language configuration')</b> \
170 \n\n$(_ 'Tip: manage locales list by installing/removing locale packages.')" \
171 --list --column="$(_n 'Flag'):IMG" --column $(_n 'Name') \
172 --column $(_n 'Description') \
173 --print-column=2 --separator='' \
174 --button="$(_n 'Manage')!stock_properties:2" \
175 --button="gtk-cancel:1" --button="gtk-ok:0"
176 }
178 locale() {
179 locale=$(locale_main)
180 # Deal with --button values
181 case $? in
182 2) tazbox manage_i18n main ;;
183 1) exit 0 ;;
184 *) continue ;;
185 esac
186 # System language configuration.
187 if [ "$locale" ]; then
188 tazlocale $locale
189 tazbox notify "$(_ 'Locale was set to $locale')" \
190 preferences-desktop-locale 3
191 fi
192 }
194 # Keymap functions
195 keymap_main() {
196 #icon=preferences-desktop-keyboard
197 icon=input-keyboard
198 gen_kmap_list
199 for i in $(sort $tmp); do
200 echo "$i" | tr '|' '\n'
201 done | \
202 yad --title="$(_ 'SliTaz keymap')" --window-icon=$icon \
203 --width=500 --height=380 --sticky --on-top --center \
204 --image=$icon --image-on-top \
205 --text="<b>$(_n 'Keyboard configuration')</b>" \
206 --list --column $(_n 'Keymap') --column $(_n 'Type') \
207 --print-column=1 --separator=''
208 rm -f $tmp
209 }
211 keymap() {
212 keymap=$(keymap_main)
213 # Deal with --button values
214 [ x$? == x1 ] && exit 0
215 # System keymap configuration
216 [ "$keymap" ] && tazkeymap $keymap
217 }
219 # Free GeoIP service
220 # Response: "IP","CountryCode","CountryName", ...
221 geoip() {
222 [ ! -e $csv ] && wget -q -T3 -O $csv http://freegeoip.net/csv/ 2&>/dev/null
223 [ -e $csv ] && cut -d'"' -f4 $csv
224 }
226 #
227 # TZ functions
228 #
230 # list of all existing available locations for country
231 tz_list() {
232 find $zi | \
233 grep -E "$(cat $ztab | grep "^$1 " | cut -d' ' -f2 | tr ' ' '|')" | \
234 grep -v -E "posix|right" | \
235 sed 's|.*/||g' | sort
236 }
238 # ask for confirmation only if we have what to choose
239 tz_suggest() {
240 CountryCode=$(geoip)
241 if [ "x$CountryCode" != x ]; then
242 if [ "x$(tz_list $CountryCode)" != x ]; then
243 CountryName=$(cut -d'"' -f6 $csv)
244 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
245 --on-top --center \
246 --image=$CountryCode --image-on-top \
247 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
248 $(_ 'Are you agreed?')" \
249 --button="gtk-yes:0" --button="gtk-no:1"
250 [ $? == 0 ] && echo $CountryCode
251 fi
252 fi
253 }
255 tz_select() {
256 case x$1 in
257 x)
258 # first pass - country
259 tmpcc=$(mktemp)
261 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
262 grep -m1 $(basename $tzfile) $ztab
263 done | cut -d' ' -f1 | sort -u > $tmpcc
265 for CC in $(cat $tmpcc); do
266 cat << EOT
267 $CC
268 $CC
269 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d' ' -f2)
270 EOT
271 done | \
272 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
273 --width=500 --height=380 --on-top --center \
274 --image=$icon --image-on-top \
275 --text="<b>$(_ 'TimeZone Configuration')</b> \
276 \n$(_ 'Select country and press "Forward" or manually select timezone file.') \
277 \n\n$(_ 'Tip: manage timezones list by installing/removing locale packages.')" \
278 --list \
279 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
280 --button="$(_n 'Manage')!stock_properties:4" \
281 --button="$(_n 'Manual')!gtk-index:2" \
282 --button="gtk-go-forward:0" \
283 --button="gtk-cancel:1" --always-print-result \
284 --print-column=2 --separator=''
285 ;;
286 xindex)
287 # manual selection of file with timezone info
288 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
289 --width=500 --on-top --center \
290 --image=$icon --image-on-top \
291 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
292 --form --field=":FL" ${zi}UTC --separator='' | \
293 sed "s|$zi||"
294 ;;
295 *)
296 # second pass - city/place
297 list=$(tz_list $1)
298 icon=$1
299 if [ $(echo "$list" | wc -l) != 1 ]; then
300 echo "$list" | \
301 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
302 --width=500 --height=380 --on-top --center \
303 --image=$icon --image-on-top \
304 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
305 --list --column $(_n 'Location/City') --separator=''
306 else
307 echo $list
308 fi
309 ;;
310 esac
311 }
313 tz() {
314 icon=clock
315 arg=$(tz_suggest)
317 timezone=$(tz_select $arg)
318 case $? in
319 1) exit 0 ;;
320 0) [ x$arg == x ] && timezone=$(tz_select "$timezone")
321 [ x$timezone == x ] && exit 0
322 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
323 sed "s|$zi||") ;;
324 2) timezone=$(tz_select "index") ;;
325 4) tazbox manage_i18n main;;
326 esac
328 [ "x$timezone" == x ] && exit 0
329 echo $timezone > /etc/TZ
330 export TZ=$timezone
331 tazbox notify "$(_ 'TimeZone was set to $timezone')" $icon 3
332 rm -f $tmpcc
333 }
335 #
336 # Manage i18n packages
337 #
339 # if installed
340 if_installed() {
341 [ -d /var/lib/tazpkg/installed/$1 ]
342 }
344 # get package's description, install flag and sizes
345 desc_etc()
346 {
347 INFO="$(grep -m1 -A3 -x -F $1 /var/lib/tazpkg/packages.txt)"
348 DESC=$(echo "$INFO" | sed -n 3p)
349 if if_installed $1; then
350 INST="TRUE"; echo $1 >> $ORIG_LIST
351 else
352 INST="FALSE"
353 fi
354 SIZES=$(echo "$INFO" | sed -n 4p)
355 SIZE1=${SIZES%% *}
356 SIZE2=$(echo $SIZES | cut -d' ' -f2 | tr -d '(')
357 echo -e "$INST\n$1\n$DESC\n${SIZE1//.0}\n${SIZE2//.0}" >> $PKGS_LIST
358 }
360 # remove temp
361 rm_temp() {
362 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
363 }
365 # install/remove locale packages
366 manage_i18n() {
367 tazbox notify "$(_ 'Please wait')" appointment-soon &
369 PKGS_LIST=$(mktemp)
370 ORIG_LIST=$(mktemp)
371 ANSWER=$(mktemp)
372 NEW_LIST=$(mktemp)
373 LIST1=$(mktemp)
374 LIST2=$(mktemp)
375 PLIST=/var/lib/tazpkg/packages.list
377 for i in $(grep -E '^locale' $PLIST | grep -v 'extra' | \
378 sed 's|\(locale-[a-zA-Z_]*\).*|\1|'); do
379 desc_etc $i
380 done
382 if [ "x$1" != xmain ]; then
383 for i in $(grep -E '^locale' $PLIST | grep 'extra' | \
384 sed 's|\(locale-[a-zA-Z_]*-extra\).*|\1|'); do
385 desc_etc $i
386 done
387 if if_installed libQtCore; then
388 for i in $(grep -E '^qt-locale' $PLIST | \
389 sed 's|\(qt-locale-[a-zA-Z_]*\).*|\1|'); do
390 desc_etc $i
391 done
392 fi
393 if if_installed razorqt; then
394 for i in $(grep -E '^razorqt-locale' $PLIST | \
395 sed 's|\(razorqt-locale-[a-zA-Z_]*\).*|\1|'); do
396 desc_etc $i
397 done
398 fi
399 if if_installed firefox; then
400 for i in $(grep -E '^firefox-langpack' $PLIST | \
401 sed 's|\(firefox-langpack-[a-zA-Z_]*\).*|\1|'); do
402 desc_etc $i
403 done
404 fi
405 if if_installed thunderbird; then
406 for i in $(grep -E '^thunderbird-langpack' $PLIST | \
407 sed 's|\(thunderbird-langpack-[a-zA-Z_]*\).*|\1|'); do
408 desc_etc $i
409 done
410 fi
411 if if_installed squirrelmail; then
412 for i in $(grep -E '^squirrelmail' $PLIST | \
413 grep -E '^squirrelmail-[a-z][a-z][_-]' | \
414 sed 's|\(squirrelmail-[a-zA-Z_]*\)-.*|\1|'); do
415 desc_etc $i
416 done
417 fi
418 if if_installed aspell; then
419 for i in $(grep -E '^aspell' $PLIST | \
420 grep -E 'aspell-[a-z][a-z][^a-z]' | \
421 sed 's|\(aspell-[a-zA-Z_]*\)-.*|\1|'); do
422 desc_etc $i
423 done
424 fi
425 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
426 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
427 ufraw|-locales qupzilla|-locales"
428 for i in $OTHER_LOCALE; do
429 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
430 done
431 fi
433 icon=stock_properties
434 cat $PKGS_LIST | \
435 {
436 yad --title="$(_n 'Manage locale packages')" --window-icon=$icon \
437 --width=600 --height=400 --on-top --center \
438 --image=$icon --image-on-top \
439 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
440 --list --multiple --ellipsize=END --expand-column=3 \
441 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
442 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
443 --column="$(_n 'Installed'):TEXT" \
444 --button="$(_n 'Recharge list')!reload:tazbox recharge" \
445 --button="$(_n 'Install/Remove')!system-upgrade:2" \
446 --button="gtk-cancel:1" \
447 --print-all
448 } > $ANSWER
450 if [ "x$?" == "x1" ]; then rm_temp; exit 0; fi
452 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
454 # check difference between ORIG_LIST and NEW_LIST
455 sort -o $LIST1 $ORIG_LIST
456 sort -o $LIST2 $NEW_LIST
457 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
458 if [ "x$DIFF" == "x" ]; then rm_temp; exit 0; fi
460 # output log to gtk window
461 title="$(_n 'TazPkg log')"; icon="tazpkg"; opts="--tail"
462 {
463 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
464 _ 'REMOVE: $pkg'
465 yes | tazpkg -r $pkg --output="raw"
466 done
467 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
468 _ 'INSTALL: $pkg'
469 tazpkg -gi $pkg --output="raw"
470 done
471 echo -e "\n\n$(_n 'Done!')\n"
472 } | output_command
473 rm_temp
474 }
478 # New file functions
479 newfile_main() {
480 icon=gtk-new
481 yad --title="$(_n 'New file')" --window-icon=$icon \
482 --width=460 --height=160 --on-top --center \
483 --image=$icon --image-on-top \
484 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
485 --entry --entry-label="$(_n 'File name')" \
486 --ricon=editclear \
487 --always-print-result \
488 --button="$(_n 'SHell script')!application-x-shellscript:4" \
489 --button="$(_n 'Folder')!stock_folder:3" \
490 --icon="gtk-new" \
491 --button="$(_n 'File')!application-text:2" \
492 --button="gtk-cancel:1"
493 }
495 newfile() {
496 file=$(newfile_main)
497 ret=$?
498 [ "$file" ] || exit 0
499 case $ret in
500 4)
501 cat > $HOME/Desktop/$file << EOT
502 #!/bin/sh
503 #
505 EOT
506 chmod +x $HOME/Desktop/$file ;;
507 3) mkdir -p $HOME/Desktop/$file ;;
508 2) touch $HOME/Desktop/$file ;;
509 1) exit 0 ;;
510 esac
511 }
513 # All applications
514 all_apps() {
515 icon=stock_bookmark
516 yad --title="$(_n 'All Applications')" --window-icon=$icon \
517 --width=400 --height=400 \
518 --icons --compact \
519 --read-dir=/usr/share/applications \
520 --button="gtk-close:0"
521 }
523 # Generate alternatives list: first - current choice, following - existing apps
524 gen_alt() {
525 alts="$@"
526 current=$(echo $alts | cut -d' ' -f1)
527 alts=$(echo $alts | sed "s|$current||g")
528 for alt in $alts; do
529 [ ! $(busybox which $alt) ] && alts=$(echo $alts | sed "s|$alt||")
530 done
531 echo $current $alts | tr ' ' '!'
532 }
534 # Ask root permissions for system settings
535 ask_root() {
536 if [ $(id -u) != 0 ]; then
537 exec tazbox su $0 $@
538 exit 0
539 fi
540 }
542 #
543 # Commands
544 #
545 case "$1" in
546 su)
547 # Don't show dialog if we are root
548 test $(id -u) = 0 && exec ${@:2}
549 SU_CMD="${@:2}"
550 # Check if a password has been saved before launching main dialog
551 if [ -s $HOME/.config/slitaz/subox.conf ]; then
552 PASSWD=$(cat $HOME/.config/slitaz/subox.conf)
553 CHECKED="TRUE"
554 fi
555 # Display the main dialog (ask for password)
556 main=$(su_main $SU_CMD)
557 # Deal with --button values and exit if cancelled to avoid erasing
558 # saved password.
559 [ $? == 1 ] && exit 0
560 # Save or erase Autosaved password
561 if [ $(echo $main | cut -f2 -d"|") == "TRUE" ]; then
562 echo $main | cut -f 1 -d "|" > $HOME/.config/slitaz/subox.conf
563 chmod 0600 $HOME/.config/slitaz/subox.conf
564 else
565 cat /dev/null > $HOME/.config/slitaz/subox.conf
566 fi
567 # Try to login & execute. If password is wrong execute error dialog
568 SU_CMD_QUOTED="$(echo "$SU_CMD" | sed 's|&|\\&|g')"
569 echo $main | cut -f 1 -d "|" | su -c "$SU_CMD_QUOTED &" || su_error ;;
570 logout)
571 # Logout window with actions
572 if [ "$oldstyle" ]; then
573 answer=$(logout_oldstyle)
574 else
575 logout_main; answer=$?
576 fi
577 # Deal with --button values
578 # DE and WM started with a custom -session script should export
579 # XDG_CURRENT_DESKTOP
580 case $answer in
581 4|*exit)
582 case $XDG_CURRENT_DESKTOP in
583 LXDE)
584 [ "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
585 [ "$DESKTOP_SESSION" == "compiz" ] && killall compiz
586 openbox --exit ;;
587 openbox) openbox --exit ;;
588 compiz) killall compiz ;;
589 *)
590 # Try to kill other WM that dont set XDG var.
591 jwm -exit 2>/dev/null ;;
592 esac ;;
593 3|*reboot)
594 reboot || reboot -f ;;
595 2|*halt)
596 poweroff ;;
597 esac ;;
598 out)
599 # Pipe a command into a GTK window
600 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command ;;
601 out-dl)
602 # A tiny GTK window for Busybox wget output
603 url=$2; opts="--tail --button=gtk-cancel:1"
604 icon=folder-downloads; title="$(_ 'Downloading...')"
605 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
606 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
607 cancel_dl ;;
608 locale)
609 ask_root $@ && locale ;;
610 keymap)
611 ask_root $@ && keymap ;;
612 tz)
613 ask_root $@ && tz ;;
614 manage_i18n)
615 ask_root $@ && manage_i18n $2 ;;
616 recharge)
617 ask_root $@; opts="--on-top"; tazpkg recharge | output_command ;;
618 setup)
619 ask_root $@ && setup ;;
620 new-file)
621 newfile ;;
622 all-apps)
623 all_apps ;;
624 notify|-n)
625 # On screen notification box.
626 icon="$3"
627 time="$4"
628 [ "$icon" ] || icon=info
629 [ "$time" ] || time=4
630 yad --width=520 --height=80 --timeout=$time --timeout-indicator=right \
631 --on-top --center --no-buttons --borders=12 --undecorated \
632 --skip-taskbar --image=$icon --image-on-top --text="<b>$2</b>" ;;
633 tazapps)
634 # Default applications configuration script. System wide config file
635 # is /etc/slitaz/applications.conf and each user can have personal
636 # settings. System wide for root and personal config for user.
637 export CONFIG="$HOME/.config/slitaz/applications.conf"
638 if [ ! -f $CONFIG ]; then
639 mkdir -p $HOME/.config/slitaz
640 cp /etc/slitaz/applications.conf $CONFIG
641 fi
642 . $CONFIG
644 FILE_MANAGERS=$(gen_alt $FILE_MANAGER \
645 clex emelfm2 mc pathfinder pcmanfm ranger spacefm thunar xfe ytree)
646 BROWSERS=$(gen_alt $BROWSER \
647 arora chrome cream dillo elinks firefox iron links lynx midori \
648 netsurf opera retawq seamonkey surf tazweb)
649 EDITORS=$(gen_alt $EDITOR \
650 adie beaver emacs geany jed joe le leafpad mousepad mp-5 nano \
651 SciTE vi vim xedit xfw zile)
652 TERMINALS=$(gen_alt $TERMINAL \
653 aterm evilvte lxterminal mrxvt sakura stjerm tilda urxvt vte xterm \
654 yeahconsole)
655 WINDOW_MANAGERS=$(gen_alt $WINDOW_MANAGER \
656 awesome blackbox dwm echinus enlightenment fluxbox icewm jwm \
657 karmen matchbox openbox-session pekwm ratpoison xfwm4)
659 icon=preferences-desktop-default-applications
660 eval $(yad --title="$(_n 'SliTaz default applications')" \
661 --window-icon=$icon --image=$icon --image-on-top \
662 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
663 --form \
664 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
665 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
666 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
667 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
668 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
669 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
670 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
672 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
673 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
674 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
675 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
676 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
677 -i $CONFIG ;;
678 gpl)
679 yad --title="GNU General Public License" --window-icon=text-x-generic \
680 --geometry="650x500" \
681 --image=/usr/share/pixmaps/gpl3.png --image-on-top \
682 --center \
683 --text-info \
684 --fontname=monospace \
685 --button "OK" < /usr/share/licenses/gpl.txt ;;
686 *)
687 usage ;;
688 esac
690 exit 0