slitaz-tools view tazbox/tazbox @ rev 949

tazbox: fix manage_i18n (thanks kubepc)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Aug 05 02:34:39 2015 +0300 (2015-08-05)
parents 3be081525506
children bffe37afb546
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-2015 SliTaz GNU/Linux - GNU GPL v3
7 # - Christophe Lincoln <pankso@slitaz.org>
8 # - Aleksej Bobylev <al.bobylev@gmail.com>
9 #
11 . /lib/libtaz.sh
12 export TEXTDOMAIN='tazbox' # i18n
15 # Get SliTaz settings
17 . /etc/slitaz/slitaz.conf
20 # download dir (may be in a config file)
22 DOWNLOADS="$HOME/Downloads"
25 # some constants to be used inside functions
27 tmp='/tmp/keymap.list'
28 db='/usr/share/i18n/locales'
29 zi='/usr/share/zoneinfo/'
30 ztab="${zi}zone-mini.tab"
31 csv='/tmp/freegeoip.csv'
34 #
35 # Functions
36 #
38 usage() {
39 newline; _ 'SliTaz tiny GUI boxes for the desktop'
41 newline; boldify $(_ 'Usage:')
42 echo " $(basename $0) [$(_n 'command')]"
44 newline; boldify $(_ 'Commands:')
45 optlist "\
46 usage $(_ 'Display this short help usage')
47 su $(_ 'Execute a command as super-user')
48 logout $(_ 'Desktop logout box with actions')
49 out $(_ 'Pipe a command output into a GTK window')
50 out-dl $(_ 'Pipe wget output into a GTK window')
51 locale $(_ 'Configure system language (root)')
52 keymap $(_ 'Configure system keymap (root)')
53 tz $(_ 'Configure system timezone (root)')
54 setup $(_ 'System initial setup (locale, keymap & timezone)')
55 new-file $(_ 'Create a new file or folder on the desktop')
56 all-apps $(_ 'Display icons of all installed applications')
57 notify $(_ 'Notify user with a desktop centered box')
58 tazapps $(_ 'Configure SliTaz default applications')"
59 newline
60 }
63 # try to find icon in .desktop files
65 find_icon() {
66 local_desktop=$(find $HOME/.local/share/applications \
67 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
68 system_desktop=$(find /usr/share/applications \
69 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
70 desktop="${local_desktop:-$system_desktop}"
71 [ -n "$desktop" ] && cat $desktop | sed '/\[Desktop\ Entry\]/,/^\[/!d' | \
72 sed '/^Icon=/!d' | head -n1 | cut -d= -f2
73 }
76 # su frontend GUIs
78 su_main() {
79 CMD1="${1%% *}"; CMD2="$(echo "${1#* }" | sed 's|&|&amp;|g')"
80 : ${icon=$(find_icon $CMD1)}
81 icon="${icon:-dialog-password}"
83 yad --title="$(_n 'SliTaz admin password')" --window-icon=$icon \
84 --width=520 --on-top --center \
85 --image=$icon --image-on-top \
86 --text="$(_n 'Please enter root password (default root) to execute:')\n
87 <span foreground=\"red\"><tt><b>$CMD1</b> $CMD2</tt></span>\n" \
88 --form \
89 --field="$(_n 'Password:'):H" $PASSWD \
90 --field="$(_n 'Autosave password'):CHK" $CHECKED
91 }
94 su_error() {
95 icon='dialog-error'
96 yad --title="$(_n 'Error')" --window-icon=$icon \
97 --width=320 --on-top --center \
98 --image=$icon --image-on-top \
99 --text="\n<b>$(_n 'Error: wrong password!')</b>\n" \
100 --button="gtk-close:1"
101 }
104 # user may press cancel on download.
106 cancel_dl() {
107 if [ "$?" -eq 1 ]; then
108 _ "CANCEL"
109 rm -f $DOWNLOADS/$(basename $url)
110 fi
111 }
114 # output a command in a GTK window
116 output_command() {
117 : ${title=$(_n 'TazBox Output')}
118 : ${icon=dialog-information}
120 yad --title="$title" --window-icon="$icon" \
121 --geometry='600x220+0-24' --fore='#ffffff' --back='#000000' \
122 --text-info --fontname=monospace --wrap $opts \
123 --button='gtk-close:1'
124 }
127 # logout GUI function
129 logout_main() {
130 icon='/usr/share/pixmaps/slitaz-icon.png'
131 yad --title="$(_n 'SliTaz Logout')" --window-icon="$icon" \
132 --on-top --center --height='130' \
133 --image="$icon" --image-on-top \
134 --text="<b>$(_n 'SliTaz Logout - Please choose an action:')</b>" \
135 --always-print-result \
136 --button "$(_n 'Close X session')!system-log-out:4" \
137 --button "$(_n 'Reboot system')!system-reboot:3" \
138 --button "$(_n 'Shutdown system')!system-shutdown:2"
139 }
142 # generate keymap list
144 gen_kmap_list() {
145 echo > $tmp
146 cd /usr/share/kbd/keymaps/i386
147 # we first need a list to sort and then use \n for Yad list.
148 for i in $(find -type f | sed '/include/d; s|./||'); do
149 echo "$(basename $i .map.gz)|$(dirname $i)" >> $tmp
150 done
151 }
154 # Initial Config functions
156 setup_main() {
157 icon='locale'
158 gen_kmap_list
159 locale=$(ls -1 $db | grep ^[a-z][a-z]_[A-Z][A-Z] | tr "\n" "!")
160 keymap=$(cat $tmp | sort | tr "\n" "!")
161 timezone=$(find $zi -type f | sed s,$zi,,g | grep -v -F '.tab' | tr "\n" "!")
162 yad --title="$(_n 'SliTaz Initial Setup')" --window-icon=$icon \
163 --width='500' \
164 --image="$icon" --image-on-top \
165 --text="<big>$(_n 'Here you can set your preferences \n for <b>locale, keymap and timezone</b>.')</big>" \
166 --form \
167 --field "$(_n 'Locale'):CB" $locale \
168 --field "$(_n 'Keymap'):CB" $keymap \
169 --field "$(_n 'Timezone'):CB" $timezone
170 }
173 setup() {
174 choices=$(setup_main)
175 locale=$( echo $choices | cut -d'|' -f1)
176 keymap=$( echo $choices | cut -d'|' -f2)
177 timezone=$(echo $choices | cut -d'|' -f3)
178 [ -n "$locale" ] && tazlocale init $locale
179 [ -n "$keymap" ] && tazkeymap init $keymap
180 [ -n "$timezone" ] && echo $timezone > /etc/TZ
181 }
184 #
185 # Locale functions
186 #
188 locale_main() {
189 icon='preferences-desktop-locale'
190 for locale in $(ls -1 $db | grep '[a-z]_[A-Z]'); do
191 desc=$(fgrep -m1 title $db/$locale | cut -d'"' -f2)
192 ll_CC=${locale%%@*}
193 echo -e "${ll_CC##*_}\n$locale\n$desc"
194 done | \
195 yad --title="$(_n 'SliTaz locale')" --window-icon="$icon" \
196 --width='600' --height='380' --sticky --on-top --center \
197 --image="$icon" --image-on-top \
198 --text="<b>$(_n 'Language configuration')</b> \
199 \n\n$(_ 'Tip: manage locales list by installing/removing locale packages.')" \
200 --list --column="$(_n 'Flag'):IMG" --column $(_n 'Name') \
201 --column $(_n 'Description') \
202 --print-column='2' --separator='' \
203 --button="$(_n 'Manage')!stock_properties:2" \
204 --button="gtk-cancel:1" --button="gtk-ok:0"
205 }
208 locale() {
209 locale=$(locale_main)
210 # Deal with --button values
211 case $? in
212 2) tazbox manage_i18n main ;;
213 1) exit 0 ;;
214 *) continue ;;
215 esac
216 # System language configuration.
217 if [ "$locale" ]; then
218 tazlocale $locale
219 tazbox notify "$(_ 'Locale was set to %s' "$locale")" \
220 preferences-desktop-locale 3
221 fi
222 }
225 # Keymap functions
227 keymap_main() {
228 icon='preferences-desktop-keyboard'
229 gen_kmap_list
230 for i in $(sort $tmp); do
231 echo "$i" | tr '|' '\n'
232 done | \
233 yad --title="$(_ 'SliTaz keymap')" --window-icon=$icon \
234 --width=500 --height=380 --sticky --on-top --center \
235 --image=$icon --image-on-top \
236 --text="<b>$(_n 'Keyboard configuration')</b>" \
237 --list --column $(_n 'Keymap') --column $(_n 'Type') \
238 --print-column=1 --separator=''
239 rm -f $tmp
240 }
243 keymap() {
244 keymap=$(keymap_main)
245 # Deal with --button values
246 [ "$?" -eq 1 ] && exit 0
247 # System keymap configuration
248 [ -n "$keymap" ] && tazkeymap $keymap
249 }
252 # Free GeoIP service
253 # Response: IP,CountryCode,CountryName, ...
255 geoip() {
256 [ ! -e $csv ] && wget -q -T3 -O $csv http://freegeoip.net/csv/ 2&>/dev/null
257 [ -e $csv ] && cut -d, -f2 $csv
258 }
261 #
262 # TZ functions
263 #
266 # list of all existing available locations for country
268 tz_list() {
269 find $zi | \
270 grep -E "$(cat $ztab | grep "^$1 " | cut -d' ' -f2 | tr ' ' '|')" | \
271 grep -v -E "posix|right" | \
272 sed 's|.*/||g' | sort
273 }
276 # ask for confirmation only if we have what to choose
278 tz_suggest() {
279 CountryCode=$(geoip)
280 if [ -n "$CountryCode" ]; then
281 if [ -n "$(tz_list $CountryCode)" ]; then
282 CountryName=$(cut -d, -f3 $csv)
283 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
284 --on-top --center \
285 --image="$CountryCode" --image-on-top \
286 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
287 $(_ 'Are you agreed?')" \
288 --button='gtk-yes:0' --button='gtk-no:1'
289 [ "$?" -eq 0 ] && echo $CountryCode
290 fi
291 fi
292 }
295 tz_select() {
296 case x$1 in
297 x)
298 # first pass - country
299 tmpcc=$(mktemp)
301 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
302 grep -m1 $(basename $tzfile) $ztab
303 done | cut -d$'\t' -f1 | sort -u > $tmpcc
305 for CC in $(cat $tmpcc); do
306 cat << EOT
307 $CC
308 $CC
309 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d$'\t' -f2)
310 EOT
311 done | \
312 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
313 --width='500' --height='380' --on-top --center \
314 --image="$icon" --image-on-top \
315 --text="<b>$(_ 'TimeZone Configuration')</b> \
316 \n$(_ 'Select country and press "Forward" or manually select timezone file.') \
317 \n\n$(_ 'Tip: manage timezones list by installing/removing locale packages.')" \
318 --list \
319 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
320 --button="$(_n 'Manage')!stock_properties:4" \
321 --button="$(_n 'Manual')!gtk-index:2" \
322 --button="gtk-go-forward:0" \
323 --button="gtk-cancel:1" --always-print-result \
324 --print-column='2' --separator=''
325 ;;
326 xindex)
327 # manual selection of file with timezone info
328 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
329 --width='500' --on-top --center \
330 --image="$icon" --image-on-top \
331 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
332 --form --field=":FL" ${zi}UTC --separator='' | \
333 sed "s|$zi||"
334 ;;
335 *)
336 # second pass - city/place
337 list=$(tz_list $1)
338 icon="$1"
339 if [ $(echo "$list" | wc -l) != 1 ]; then
340 echo "$list" | \
341 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
342 --width='500' --height='380' --on-top --center \
343 --image="$icon" --image-on-top \
344 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
345 --list --column $(_n 'Location/City') --separator=''
346 else
347 echo $list
348 fi
349 ;;
350 esac
351 }
354 tz() {
355 icon='clock'
356 arg=$(tz_suggest)
358 timezone=$(tz_select $arg)
359 case $? in
360 1) exit 0 ;;
361 0) [ -n "$arg" ] && timezone=$(tz_select "$timezone")
362 [ -z "$timezone" ] && exit 0
363 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
364 sed "s|$zi||") ;;
365 2) timezone=$(tz_select "index") ;;
366 4) tazbox manage_i18n main;;
367 esac
369 [ -z "$timezone" ] && exit 0
370 echo $timezone > /etc/TZ
371 export TZ=$timezone
372 tazbox notify "$(_ 'TimeZone was set to %s' "$timezone")" $icon 3
373 rm -f $tmpcc
374 }
377 #
378 # Manage i18n packages
379 #
382 # if installed
384 if_installed() {
385 [ -d "$INSTALLED/$1" ]
386 }
389 # get package's description, install flag and sizes
391 desc_etc() {
392 if grep -q "^$1"$'\t' "$PKGS_DB/installed.info"; then
393 echo 'TRUE' >> $PKGS_LIST; echo $1 >> $ORIG_LIST
394 else
395 echo 'FALSE' >> $PKGS_LIST
396 fi
397 awk -F$'\t' -vp="$1" '
398 ($1==p){
399 split($7, s, " ");
400 printf "%s\n%s\n%s\n%s\n", $1, $4, s[1], s[2];
401 }' "$PKGS_DB/packages.info" >> $PKGS_LIST
402 }
405 # remove temp
407 rm_temp() {
408 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
409 }
412 # install/remove locale packages
414 manage_i18n() {
415 PKGS_LIST=$(mktemp)
416 ORIG_LIST=$(mktemp)
417 ANSWER=$(mktemp)
418 NEW_LIST=$(mktemp)
419 LIST1=$(mktemp)
420 LIST2=$(mktemp)
421 PINFO="$PKGS_DB/packages.info"
423 if [ ! -e "$PINFO" ]; then
424 icon='dialog-warning'
425 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
426 --width='400' --on-top --center \
427 --image="$icon" --image-on-top \
428 --text="$(_n 'Please, recharge packages database.')" \
429 --button="$(_n 'Recharge list')!reload:2" \
430 --button="gtk-cancel:1"
432 case "$?" in
433 1) rm_tmp; return;;
434 2) tazbox recharge;;
435 esac
436 fi
438 tazbox notify "$(_ 'Please wait')" appointment-soon &
440 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+$/{print $1}' $PINFO); do
441 desc_etc $i
442 done
444 if [ "$1" != 'main' ]; then
445 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+-extra$/{print $1}' $PINFO); do
446 desc_etc $i
447 done
449 if if_installed libQtCore; then
450 for i in $(awk -F$'\t' '$1~/^qt-locale/{print $1}' $PINFO); do
451 desc_etc $i
452 done
453 fi
455 if if_installed razorqt; then
456 for i in $(awk -F$'\t' '$1~/^razorqt-locale/{print $1}' $PINFO); do
457 desc_etc $i
458 done
459 fi
461 if if_installed firefox; then
462 for i in $(awk -F$'\t' '$1~/^firefox-langpack/{print $1}' $PINFO); do
463 desc_etc $i
464 done
465 fi
467 if if_installed thunderbird; then
468 for i in $(awk -F$'\t' '$1~/^thunderbird-langpack/{print $1}' $PINFO); do
469 desc_etc $i
470 done
471 fi
473 if if_installed squirrelmail; then
474 for i in $(awk -F$'\t' '$1~/^squirrelmail-[a-z][a-z][_-]/{print $1}' $PINFO); do
475 desc_etc $i
476 done
477 fi
479 if if_installed aspell; then
480 for i in $(awk -F$'\t' '$1~/^aspell-[a-z][a-z]_?[A-Z]?[A-Z]?$/{print $1}' $PINFO); do
481 desc_etc $i
482 done
483 fi
485 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
486 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
487 ufraw|-locales qupzilla|-locales"
488 for i in $OTHER_LOCALE; do
489 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
490 done
491 fi
493 icon='stock_properties'
494 cat $PKGS_LIST | \
495 {
496 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
497 --width='600' --height='400' --on-top --center \
498 --image="$icon" --image-on-top \
499 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
500 --list --multiple --ellipsize='END' --expand-column='3' \
501 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
502 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
503 --column="$(_n 'Installed'):TEXT" \
504 --button="$(_n 'Recharge list')!reload:4" \
505 --button="$(_n 'Install/Remove')!system-upgrade:2" \
506 --button="gtk-cancel:1" \
507 --print-all
508 } > $ANSWER
510 case "$?" in
511 1) rm_temp; exit 0;;
512 4) tazbox recharge; rm_tmp; tazbox manage_i18n; exit 0;;
513 esac
515 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
517 # check difference between ORIG_LIST and NEW_LIST
518 sort -o $LIST1 $ORIG_LIST
519 sort -o $LIST2 $NEW_LIST
520 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
521 if [ -z "$DIFF" ]; then rm_temp; exit 0; fi
523 # output log to gtk window
524 title="$(_n 'TazPkg log')"; icon='tazpkg'; opts='--tail'
525 {
526 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
527 _ 'REMOVE: %s' "$pkg"
528 yes | tazpkg -r $pkg --output='raw'
529 done
530 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
531 _ 'INSTALL: %s' "$pkg"
532 tazpkg -gi $pkg --output='raw'
533 done
534 echo -e "\n\n$(_n 'Done!')\n"
535 } | output_command
536 rm_temp
537 }
541 # New file functions
543 newfile_main() {
544 icon='gtk-new'
545 yad --title="$(_n 'New file')" --window-icon="$icon" \
546 --width='460' --height='160' --on-top --center \
547 --image="$icon" --image-on-top \
548 --icon="$icon" \
549 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
550 --entry --entry-label="$(_n 'File name')" \
551 --ricon='editclear' \
552 --always-print-result \
553 --button="$(_n 'SHell script')!application-x-shellscript:4" \
554 --button="$(_n 'Folder')!folder:3" \
555 --button="$(_n 'File')!empty:2" \
556 --button='gtk-cancel:1'
557 }
560 newfile() {
561 file=$(newfile_main)
562 ret=$?
563 [ -z "$file" ] && exit 0
564 case $ret in
565 4)
566 cat > "$HOME/Desktop/$file" << EOT
567 #!/bin/sh
568 #
570 EOT
571 chmod +x "$HOME/Desktop/$file" ;;
572 3) mkdir -p "$HOME/Desktop/$file" ;;
573 2) touch "$HOME/Desktop/$file" ;;
574 1) exit 0 ;;
575 esac
576 }
579 # All applications
581 all_apps() {
582 icon='stock_bookmark'
583 yad --title="$(_n 'All Applications')" --window-icon="$icon" \
584 --width='400' --height='400' \
585 --icons --compact \
586 --read-dir='/usr/share/applications' \
587 --button='gtk-close:0'
588 }
591 # Ask root permissions for system settings
593 ask_root() {
594 if [ "$(id -u)" -ne 0 ]; then
595 exec tazbox su $0 $@
596 exit 0
597 fi
598 }
601 #
602 # Commands
603 #
605 case "$1" in
606 su)
607 shift
608 # Don't show dialog if we are root
609 [ "$(id -u)" -eq 0 ] && exec "$@"
610 SU_CMD="$@"
611 SUBOX_CONF="$HOME/.config/slitaz/subox.conf"
613 # Check if a password has been saved before launching main dialog
614 if [ -s "$SUBOX_CONF" ]; then
615 PASSWD="$(cat $SUBOX_CONF)"
616 CHECKED='TRUE'
617 fi
619 # Display the main dialog (ask for password)
620 main="$(su_main "$SU_CMD")"
622 # Deal with --button values and exit if cancelled to avoid erasing
623 # saved password.
624 [ "$?" -eq 1 ] && exit 0
626 # Save or erase Autosaved password
627 if [ $(echo "$main" | cut -d"|" -f2) == 'TRUE' ]; then
628 echo "$main" | cut -d"|" -f1 > $SUBOX_CONF
629 chmod 0600 $SUBOX_CONF
630 else
631 cat /dev/null > $SUBOX_CONF
632 fi
634 # Try to login & execute. If password is wrong execute error dialog
635 SU_CMD_QUOTED="$(echo "dbus-launch --exit-with-session $SU_CMD" | sed 's|&|\\&|g')"
636 echo $main | cut -d"|" -f1 | su -c "$SU_CMD_QUOTED &" || su_error
637 ;;
639 logout)
640 # Logout window with actions
641 if [ -n "$oldstyle" ]; then
642 answer=$(logout_oldstyle)
643 else
644 logout_main; answer=$?
645 fi
647 # Deal with --button values
648 # DE and WM started with a custom -session script should export
649 # XDG_CURRENT_DESKTOP
650 case $answer in
651 4|*exit)
652 case $XDG_CURRENT_DESKTOP in
653 LXDE)
654 [ -n "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
655 [ "$DESKTOP_SESSION" == 'compiz' ] && killall compiz
656 openbox --exit ;;
657 openbox) openbox --exit ;;
658 compiz) killall compiz ;;
659 *)
660 # Try to kill other WM that dont set XDG var.
661 jwm -exit 2>/dev/null ;;
662 esac ;;
663 3|*reboot)
664 reboot || reboot -f ;;
665 2|*halt)
666 poweroff ;;
667 esac
668 ;;
670 out)
671 # Pipe a command into a GTK window
672 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command
673 ;;
675 out-dl)
676 # A tiny GTK window for Busybox wget output
677 url="$2"; opts='--tail --button=gtk-cancel:1'
678 icon='folder-downloads'; title="$(_ 'Downloading...')"
679 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
680 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
681 cancel_dl
682 ;;
684 locale)
685 ask_root $@ && locale
686 ;;
688 keymap)
689 ask_root $@ && keymap
690 ;;
692 tz)
693 ask_root $@ && tz
694 ;;
696 manage_i18n)
697 ask_root $@ && manage_i18n $2
698 ;;
700 recharge)
701 ask_root $@; opts='--on-top'; output=raw tazpkg recharge | output_command
702 ;;
704 setup)
705 ask_root $@ && setup
706 ;;
708 new-file)
709 newfile
710 ;;
712 all-apps)
713 all_apps
714 ;;
716 notify|-n)
717 # On screen notification box.
718 icon="$3"
719 time="$4"
720 [ -z "$icon" ] && icon='info'
721 [ -z "$time" ] && time='4'
722 yad --width='520' --height='80' --timeout="$time" --timeout-indicator='right' \
723 --on-top --center --no-buttons --borders='12' --undecorated \
724 --skip-taskbar --image="$icon" --image-on-top --text="<b>$2</b>"
725 ;;
727 tazapps)
728 # Default applications configuration script. System wide config file
729 # is /etc/slitaz/applications.conf and each user can have personal
730 # settings. System wide for root and personal config for user.
731 export CONFIG="$HOME/.config/slitaz/applications.conf"
732 if [ "$(id -u)" -eq 0 ]; then
733 [ ! -f $CONFIG ] || mv -f $CONFIG /etc/slitaz/applications.conf
734 export CONFIG='/etc/slitaz/applications.conf'
735 fi
737 for a in FILE_MANAGERS BROWSERS EDITORS TERMINALS WINDOW_MANAGERS; do
738 eval $(expr $a=$(echo $(LC_ALL=C tazx get-applist ${a%%S} \
739 only-installed yad) | sed 's/ /!/g ; s/!!//g; s/ //g'))
740 done
742 # Missing file was created by slitaz_apps_conf function from tazx
743 . $CONFIG
745 icon='preferences-desktop-default-applications'
746 eval $(yad --title="$(_n 'SliTaz default applications')" \
747 --window-icon="$icon" --image="$icon" --image-on-top \
748 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
749 --form \
750 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
751 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
752 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
753 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
754 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
755 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
756 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
758 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
759 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
760 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
761 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
762 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
763 -i $CONFIG
764 ;;
766 gpl)
767 yad --title='GNU General Public License' --window-icon='text-x-generic' \
768 --geometry='650x500' \
769 --image='/usr/share/pixmaps/gpl3.png' --image-on-top \
770 --center \
771 --text-info \
772 --fontname='monospace' \
773 --button 'OK' < /usr/share/licenses/gpl.txt
774 ;;
776 *)
777 usage
778 ;;
779 esac
781 exit 0