slitaz-tools view tazbox/tazbox @ rev 939

tazbox: fix subox icon when ~/.local/share/applications is absent; fix working with freegeoip; write full list of icons used; all other files: 2015 and insert blank lines.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Apr 17 07:35:02 2015 +0300 (2015-04-17)
parents 7bda33bbdf48
children 3be081525506
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 # download dir (may be in a config file)
17 DOWNLOADS=$HOME/Downloads
20 # some constants to be used inside functions
22 tmp=/tmp/keymap.list
23 db=/usr/share/i18n/locales
24 zi=/usr/share/zoneinfo/
25 ztab=${zi}zone-mini.tab
26 csv=/tmp/freegeoip.csv
29 #
30 # Functions
31 #
33 usage() {
34 newline; _ 'SliTaz tiny GUI boxes for the desktop'
36 newline; boldify $(_ 'Usage:')
37 echo " $(basename $0) [$(_n 'command')]"
39 newline; boldify $(_ 'Commands:')
40 optlist "\
41 usage $(_ 'Display this short help usage')
42 su $(_ 'Execute a command as super-user')
43 logout $(_ 'Desktop logout box with actions')
44 out $(_ 'Pipe a command output into a GTK window')
45 out-dl $(_ 'Pipe wget output into a GTK window')
46 locale $(_ 'Configure system language (root)')
47 keymap $(_ 'Configure system keymap (root)')
48 tz $(_ 'Configure system timezone (root)')
49 setup $(_ 'System initial setup (locale, keymap & timezone)')
50 new-file $(_ 'Create a new file or folder on the desktop')
51 all-apps $(_ 'Display icons of all installed applications')
52 notify $(_ 'Notify user with a desktop centered box')
53 tazapps $(_ 'Configure SliTaz default applications')"
54 newline
55 }
58 # try to find icon in .desktop files
60 find_icon() {
61 local_desktop=$(find $HOME/.local/share/applications
62 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
63 system_desktop=$(find /usr/share/applications \
64 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
65 desktop="${local_desktop:-$system_desktop}"
66 [ -n "$desktop" ] && cat $desktop | sed '/\[Desktop\ Entry\]/,/^\[/!d' | \
67 sed '/^Icon=/!d' | head -n1 | cut -d= -f2
68 }
71 # su frontend GUIs
73 su_main() {
74 CMD1="$1"; shift; CMD2="$(echo $@ | sed 's|&|&amp;|g')"
75 : ${icon=$(find_icon $CMD1)}
76 icon="${icon:-dialog-password}"
78 yad --title="$(_n 'SliTaz admin password')" --window-icon=$icon \
79 --width=520 --on-top --center \
80 --image=$icon --image-on-top \
81 --text="$(_n 'Please enter root password (default root) to execute:')\n
82 <span foreground=\"red\"><tt><b>$CMD1</b> $CMD2</tt></span>\n" \
83 --form \
84 --field="$(_n 'Password:'):H" $PASSWD \
85 --field="$(_n 'Autosave password'):CHK" $CHECKED
86 }
89 su_error() {
90 icon='dialog-error'
91 yad --title="$(_n 'Error')" --window-icon=$icon \
92 --width=320 --on-top --center \
93 --image=$icon --image-on-top \
94 --text="\n<b>$(_n 'Error: wrong password!')</b>\n" \
95 --button="gtk-close:1"
96 }
99 # user may press cancel on download.
101 cancel_dl() {
102 if [ "$?" == 1 ]; then
103 _ "CANCEL"
104 rm -f $DOWNLOADS/$(basename $url)
105 fi
106 }
109 # output a command in a GTK window
111 output_command() {
112 : ${title=$(_n 'TazBox Output')}
113 : ${icon=dialog-information}
115 yad --title="$title" --window-icon=$icon \
116 --geometry="600x220+0-24" --fore="#ffffff" --back="#000000" \
117 --text-info --fontname=monospace --wrap $opts \
118 --button="gtk-close:1"
119 }
122 # logout GUI function
124 logout_main() {
125 icon='/usr/share/pixmaps/slitaz-icon.png'
126 yad --title="$(_n 'SliTaz Logout')" --window-icon=$icon \
127 --on-top --center --height=130 \
128 --image=$icon --image-on-top \
129 --text="<b>$(_n 'SliTaz Logout - Please choose an action:')</b>" \
130 --always-print-result \
131 --button "$(_n 'Close X session')!system-log-out:4" \
132 --button "$(_n 'Reboot system')!system-reboot:3" \
133 --button "$(_n 'Shutdown system')!system-shutdown:2"
134 }
137 # generate keymap list
139 gen_kmap_list() {
140 echo > $tmp
141 cd /usr/share/kbd/keymaps/i386
142 # we first need a list to sort and then use \n for Yad list.
143 for i in $(find -type f | sed '/include/d; s|./||'); do
144 echo "$(basename $i .map.gz)|$(dirname $i)" >> $tmp
145 done
146 }
149 # Initial Config functions
151 setup_main() {
152 icon='locale'
153 gen_kmap_list
154 locale=$(ls -1 $db | grep ^[a-z][a-z]_[A-Z][A-Z] | tr "\n" "!")
155 keymap=$(cat $tmp | sort | tr "\n" "!")
156 timezone=$(find $zi -type f | sed s,$zi,,g | grep -v -F '.tab' | tr "\n" "!")
157 yad --title="$(_n 'SliTaz Initial Setup')" --window-icon=$icon \
158 --width=500 \
159 --image=$icon --image-on-top \
160 --text="<big>$(_n 'Here you can set your preferences \n for <b>locale, keymap and timezone</b>.')</big>" \
161 --form \
162 --field "$(_n 'Locale'):CB" $locale \
163 --field "$(_n 'Keymap'):CB" $keymap \
164 --field "$(_n 'Timezone'):CB" $timezone
165 }
168 setup() {
169 choices=$(setup_main)
170 locale=$(echo $choices | cut -d"|" -f1)
171 keymap=$(echo $choices | cut -d"|" -f2)
172 timezone=$(echo $choices | cut -d"|" -f3)
173 [ $locale ] && tazlocale init $locale
174 [ $keymap ] && tazkeymap init $keymap
175 [ $timezone ] && echo $timezone > /etc/TZ
176 }
179 #
180 # Locale functions
181 #
183 locale_main() {
184 icon='preferences-desktop-locale'
185 for locale in $(ls -1 $db | grep '[a-z]_[A-Z]'); do
186 desc=$(fgrep -m1 title $db/$locale | cut -d'"' -f2)
187 ll_CC=${locale%%@*}
188 echo -e "${ll_CC##*_}\n$locale\n$desc"
189 done | \
190 yad --title="$(_n 'SliTaz locale')" --window-icon=$icon \
191 --width=600 --height=380 --sticky --on-top --center \
192 --image=$icon --image-on-top \
193 --text="<b>$(_n 'Language configuration')</b> \
194 \n\n$(_ 'Tip: manage locales list by installing/removing locale packages.')" \
195 --list --column="$(_n 'Flag'):IMG" --column $(_n 'Name') \
196 --column $(_n 'Description') \
197 --print-column=2 --separator='' \
198 --button="$(_n 'Manage')!stock_properties:2" \
199 --button="gtk-cancel:1" --button="gtk-ok:0"
200 }
203 locale() {
204 locale=$(locale_main)
205 # Deal with --button values
206 case $? in
207 2) tazbox manage_i18n main ;;
208 1) exit 0 ;;
209 *) continue ;;
210 esac
211 # System language configuration.
212 if [ "$locale" ]; then
213 tazlocale $locale
214 tazbox notify "$(_ 'Locale was set to $locale')" \
215 preferences-desktop-locale 3
216 fi
217 }
220 # Keymap functions
222 keymap_main() {
223 icon='preferences-desktop-keyboard'
224 gen_kmap_list
225 for i in $(sort $tmp); do
226 echo "$i" | tr '|' '\n'
227 done | \
228 yad --title="$(_ 'SliTaz keymap')" --window-icon=$icon \
229 --width=500 --height=380 --sticky --on-top --center \
230 --image=$icon --image-on-top \
231 --text="<b>$(_n 'Keyboard configuration')</b>" \
232 --list --column $(_n 'Keymap') --column $(_n 'Type') \
233 --print-column=1 --separator=''
234 rm -f $tmp
235 }
238 keymap() {
239 keymap=$(keymap_main)
240 # Deal with --button values
241 [ x$? == x1 ] && exit 0
242 # System keymap configuration
243 [ "$keymap" ] && tazkeymap $keymap
244 }
247 # Free GeoIP service
248 # Response: IP,CountryCode,CountryName, ...
250 geoip() {
251 [ ! -e $csv ] && wget -q -T3 -O $csv http://freegeoip.net/csv/ 2&>/dev/null
252 [ -e $csv ] && cut -d, -f2 $csv
253 }
256 #
257 # TZ functions
258 #
261 # list of all existing available locations for country
263 tz_list() {
264 find $zi | \
265 grep -E "$(cat $ztab | grep "^$1 " | cut -d' ' -f2 | tr ' ' '|')" | \
266 grep -v -E "posix|right" | \
267 sed 's|.*/||g' | sort
268 }
271 # ask for confirmation only if we have what to choose
273 tz_suggest() {
274 CountryCode=$(geoip)
275 if [ "x$CountryCode" != x ]; then
276 if [ "x$(tz_list $CountryCode)" != x ]; then
277 CountryName=$(cut -d, -f3 $csv)
278 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
279 --on-top --center \
280 --image=$CountryCode --image-on-top \
281 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
282 $(_ 'Are you agreed?')" \
283 --button="gtk-yes:0" --button="gtk-no:1"
284 [ $? == 0 ] && echo $CountryCode
285 fi
286 fi
287 }
290 tz_select() {
291 case x$1 in
292 x)
293 # first pass - country
294 tmpcc=$(mktemp)
296 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
297 grep -m1 $(basename $tzfile) $ztab
298 done | cut -d' ' -f1 | sort -u > $tmpcc
300 for CC in $(cat $tmpcc); do
301 cat << EOT
302 $CC
303 $CC
304 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d' ' -f2)
305 EOT
306 done | \
307 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
308 --width=500 --height=380 --on-top --center \
309 --image=$icon --image-on-top \
310 --text="<b>$(_ 'TimeZone Configuration')</b> \
311 \n$(_ 'Select country and press "Forward" or manually select timezone file.') \
312 \n\n$(_ 'Tip: manage timezones list by installing/removing locale packages.')" \
313 --list \
314 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
315 --button="$(_n 'Manage')!stock_properties:4" \
316 --button="$(_n 'Manual')!gtk-index:2" \
317 --button="gtk-go-forward:0" \
318 --button="gtk-cancel:1" --always-print-result \
319 --print-column=2 --separator=''
320 ;;
321 xindex)
322 # manual selection of file with timezone info
323 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
324 --width=500 --on-top --center \
325 --image=$icon --image-on-top \
326 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
327 --form --field=":FL" ${zi}UTC --separator='' | \
328 sed "s|$zi||"
329 ;;
330 *)
331 # second pass - city/place
332 list=$(tz_list $1)
333 icon=$1
334 if [ $(echo "$list" | wc -l) != 1 ]; then
335 echo "$list" | \
336 yad --title="$(_ 'SliTaz TZ')" --window-icon=$icon \
337 --width=500 --height=380 --on-top --center \
338 --image=$icon --image-on-top \
339 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
340 --list --column $(_n 'Location/City') --separator=''
341 else
342 echo $list
343 fi
344 ;;
345 esac
346 }
349 tz() {
350 icon=clock
351 arg=$(tz_suggest)
353 timezone=$(tz_select $arg)
354 case $? in
355 1) exit 0 ;;
356 0) [ x$arg == x ] && timezone=$(tz_select "$timezone")
357 [ x$timezone == x ] && exit 0
358 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
359 sed "s|$zi||") ;;
360 2) timezone=$(tz_select "index") ;;
361 4) tazbox manage_i18n main;;
362 esac
364 [ "x$timezone" == x ] && exit 0
365 echo $timezone > /etc/TZ
366 export TZ=$timezone
367 tazbox notify "$(_ 'TimeZone was set to $timezone')" $icon 3
368 rm -f $tmpcc
369 }
372 #
373 # Manage i18n packages
374 #
377 # if installed
379 if_installed() {
380 [ -d /var/lib/tazpkg/installed/$1 ]
381 }
384 # get package's description, install flag and sizes
386 desc_etc()
387 {
388 INFO="$(grep -m1 -A3 -x -F $1 /var/lib/tazpkg/packages.txt)"
389 DESC=$(echo "$INFO" | sed -n 3p)
390 if if_installed $1; then
391 INST="TRUE"; echo $1 >> $ORIG_LIST
392 else
393 INST="FALSE"
394 fi
395 SIZES=$(echo "$INFO" | sed -n 4p)
396 SIZE1=${SIZES%% *}
397 SIZE2=$(echo $SIZES | cut -d' ' -f2 | tr -d '(')
398 echo -e "$INST\n$1\n$DESC\n${SIZE1//.0}\n${SIZE2//.0}" >> $PKGS_LIST
399 }
402 # remove temp
404 rm_temp() {
405 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
406 }
409 # install/remove locale packages
411 manage_i18n() {
412 tazbox notify "$(_ 'Please wait')" appointment-soon &
414 PKGS_LIST=$(mktemp)
415 ORIG_LIST=$(mktemp)
416 ANSWER=$(mktemp)
417 NEW_LIST=$(mktemp)
418 LIST1=$(mktemp)
419 LIST2=$(mktemp)
420 PLIST=/var/lib/tazpkg/packages.list
422 for i in $(grep -E '^locale' $PLIST | grep -v 'extra' | \
423 sed 's|\(locale-[a-zA-Z_]*\).*|\1|'); do
424 desc_etc $i
425 done
427 if [ "x$1" != xmain ]; then
428 for i in $(grep -E '^locale' $PLIST | grep 'extra' | \
429 sed 's|\(locale-[a-zA-Z_]*-extra\).*|\1|'); do
430 desc_etc $i
431 done
432 if if_installed libQtCore; then
433 for i in $(grep -E '^qt-locale' $PLIST | \
434 sed 's|\(qt-locale-[a-zA-Z_]*\).*|\1|'); do
435 desc_etc $i
436 done
437 fi
438 if if_installed razorqt; then
439 for i in $(grep -E '^razorqt-locale' $PLIST | \
440 sed 's|\(razorqt-locale-[a-zA-Z_]*\).*|\1|'); do
441 desc_etc $i
442 done
443 fi
444 if if_installed firefox; then
445 for i in $(grep -E '^firefox-langpack' $PLIST | \
446 sed 's|\(firefox-langpack-[a-zA-Z_]*\).*|\1|'); do
447 desc_etc $i
448 done
449 fi
450 if if_installed thunderbird; then
451 for i in $(grep -E '^thunderbird-langpack' $PLIST | \
452 sed 's|\(thunderbird-langpack-[a-zA-Z_]*\).*|\1|'); do
453 desc_etc $i
454 done
455 fi
456 if if_installed squirrelmail; then
457 for i in $(grep -E '^squirrelmail' $PLIST | \
458 grep -E '^squirrelmail-[a-z][a-z][_-]' | \
459 sed 's|\(squirrelmail-[a-zA-Z_]*\)-.*|\1|'); do
460 desc_etc $i
461 done
462 fi
463 if if_installed aspell; then
464 for i in $(grep -E '^aspell' $PLIST | \
465 grep -E 'aspell-[a-z][a-z][^a-z]' | \
466 sed 's|\(aspell-[a-zA-Z_]*\)-.*|\1|'); do
467 desc_etc $i
468 done
469 fi
470 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
471 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
472 ufraw|-locales qupzilla|-locales"
473 for i in $OTHER_LOCALE; do
474 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
475 done
476 fi
478 icon='stock_properties'
479 cat $PKGS_LIST | \
480 {
481 yad --title="$(_n 'Manage locale packages')" --window-icon=$icon \
482 --width=600 --height=400 --on-top --center \
483 --image=$icon --image-on-top \
484 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
485 --list --multiple --ellipsize=END --expand-column=3 \
486 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
487 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
488 --column="$(_n 'Installed'):TEXT" \
489 --button="$(_n 'Recharge list')!reload:tazbox recharge" \
490 --button="$(_n 'Install/Remove')!system-upgrade:2" \
491 --button="gtk-cancel:1" \
492 --print-all
493 } > $ANSWER
495 if [ "x$?" == "x1" ]; then rm_temp; exit 0; fi
497 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
499 # check difference between ORIG_LIST and NEW_LIST
500 sort -o $LIST1 $ORIG_LIST
501 sort -o $LIST2 $NEW_LIST
502 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
503 if [ "x$DIFF" == "x" ]; then rm_temp; exit 0; fi
505 # output log to gtk window
506 title="$(_n 'TazPkg log')"; icon="tazpkg"; opts="--tail"
507 {
508 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
509 _ 'REMOVE: $pkg'
510 yes | tazpkg -r $pkg --output="raw"
511 done
512 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
513 _ 'INSTALL: $pkg'
514 tazpkg -gi $pkg --output="raw"
515 done
516 echo -e "\n\n$(_n 'Done!')\n"
517 } | output_command
518 rm_temp
519 }
523 # New file functions
525 newfile_main() {
526 icon='gtk-new'
527 yad --title="$(_n 'New file')" --window-icon=$icon \
528 --width=460 --height=160 --on-top --center \
529 --image=$icon --image-on-top \
530 --icon=$icon \
531 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
532 --entry --entry-label="$(_n 'File name')" \
533 --ricon=editclear \
534 --always-print-result \
535 --button="$(_n 'SHell script')!application-x-shellscript:4" \
536 --button="$(_n 'Folder')!folder:3" \
537 --button="$(_n 'File')!empty:2" \
538 --button="gtk-cancel:1"
539 }
542 newfile() {
543 file=$(newfile_main)
544 ret=$?
545 [ "$file" ] || exit 0
546 case $ret in
547 4)
548 cat > $HOME/Desktop/$file << EOT
549 #!/bin/sh
550 #
552 EOT
553 chmod +x $HOME/Desktop/$file ;;
554 3) mkdir -p $HOME/Desktop/$file ;;
555 2) touch $HOME/Desktop/$file ;;
556 1) exit 0 ;;
557 esac
558 }
561 # All applications
563 all_apps() {
564 icon='stock_bookmark'
565 yad --title="$(_n 'All Applications')" --window-icon=$icon \
566 --width=400 --height=400 \
567 --icons --compact \
568 --read-dir=/usr/share/applications \
569 --button="gtk-close:0"
570 }
573 # Ask root permissions for system settings
575 ask_root() {
576 if [ $(id -u) != 0 ]; then
577 exec tazbox su $0 $@
578 exit 0
579 fi
580 }
583 #
584 # Commands
585 #
587 case "$1" in
588 su)
589 # Don't show dialog if we are root
590 test $(id -u) = 0 && exec ${@:2}
591 SU_CMD="${@:2}"
593 # Check if a password has been saved before launching main dialog
594 if [ -s $HOME/.config/slitaz/subox.conf ]; then
595 PASSWD=$(cat $HOME/.config/slitaz/subox.conf)
596 CHECKED="TRUE"
597 fi
599 # Display the main dialog (ask for password)
600 main=$(su_main $SU_CMD)
602 # Deal with --button values and exit if cancelled to avoid erasing
603 # saved password.
604 [ $? == 1 ] && exit 0
606 # Save or erase Autosaved password
607 if [ $(echo $main | cut -f2 -d"|") == "TRUE" ]; then
608 echo $main | cut -f 1 -d "|" > $HOME/.config/slitaz/subox.conf
609 chmod 0600 $HOME/.config/slitaz/subox.conf
610 else
611 cat /dev/null > $HOME/.config/slitaz/subox.conf
612 fi
614 # Try to login & execute. If password is wrong execute error dialog
615 SU_CMD_QUOTED="$(echo "dbus-launch --exit-with-session $SU_CMD" | sed 's|&|\\&|g')"
616 echo $main | cut -f 1 -d "|" | su -c "$SU_CMD_QUOTED &" || su_error ;;
617 logout)
618 # Logout window with actions
619 if [ "$oldstyle" ]; then
620 answer=$(logout_oldstyle)
621 else
622 logout_main; answer=$?
623 fi
625 # Deal with --button values
626 # DE and WM started with a custom -session script should export
627 # XDG_CURRENT_DESKTOP
628 case $answer in
629 4|*exit)
630 case $XDG_CURRENT_DESKTOP in
631 LXDE)
632 [ "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
633 [ "$DESKTOP_SESSION" == "compiz" ] && killall compiz
634 openbox --exit ;;
635 openbox) openbox --exit ;;
636 compiz) killall compiz ;;
637 *)
638 # Try to kill other WM that dont set XDG var.
639 jwm -exit 2>/dev/null ;;
640 esac ;;
641 3|*reboot)
642 reboot || reboot -f ;;
643 2|*halt)
644 poweroff ;;
645 esac ;;
646 out)
647 # Pipe a command into a GTK window
648 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command ;;
649 out-dl)
650 # A tiny GTK window for Busybox wget output
651 url=$2; opts="--tail --button=gtk-cancel:1"
652 icon='folder-downloads'; title="$(_ 'Downloading...')"
653 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
654 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
655 cancel_dl ;;
656 locale)
657 ask_root $@ && locale ;;
658 keymap)
659 ask_root $@ && keymap ;;
660 tz)
661 ask_root $@ && tz ;;
662 manage_i18n)
663 ask_root $@ && manage_i18n $2 ;;
664 recharge)
665 ask_root $@; opts="--on-top"; tazpkg recharge | output_command ;;
666 setup)
667 ask_root $@ && setup ;;
668 new-file)
669 newfile ;;
670 all-apps)
671 all_apps ;;
672 notify|-n)
673 # On screen notification box.
674 icon="$3"
675 time="$4"
676 [ "$icon" ] || icon=info
677 [ "$time" ] || time=4
678 yad --width=520 --height=80 --timeout=$time --timeout-indicator=right \
679 --on-top --center --no-buttons --borders=12 --undecorated \
680 --skip-taskbar --image=$icon --image-on-top --text="<b>$2</b>" ;;
681 tazapps)
682 # Default applications configuration script. System wide config file
683 # is /etc/slitaz/applications.conf and each user can have personal
684 # settings. System wide for root and personal config for user.
685 export CONFIG="$HOME/.config/slitaz/applications.conf"
686 if [ "$(id -u)" = 0 ]; then
687 [ ! -f $CONFIG ] || mv -f $CONFIG /etc/slitaz/applications.conf
688 export CONFIG="/etc/slitaz/applications.conf"
689 fi
691 for a in FILE_MANAGERS BROWSERS EDITORS TERMINALS WINDOW_MANAGERS;
692 do
693 eval $(expr $a=$(echo $(LC_ALL=C tazx get-applist ${a%%S} \
694 only-installed yad) | sed 's/ /!/g ; s/!!//g; s/ //g'))
695 done
697 # Missing file was created by slitaz_apps_conf function from tazx
698 . $CONFIG
700 icon='preferences-desktop-default-applications'
701 eval $(yad --title="$(_n 'SliTaz default applications')" \
702 --window-icon=$icon --image=$icon --image-on-top \
703 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
704 --form \
705 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
706 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
707 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
708 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
709 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
710 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
711 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
713 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
714 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
715 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
716 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
717 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
718 -i $CONFIG ;;
719 gpl)
720 yad --title="GNU General Public License" --window-icon=text-x-generic \
721 --geometry="650x500" \
722 --image=/usr/share/pixmaps/gpl3.png --image-on-top \
723 --center \
724 --text-info \
725 --fontname=monospace \
726 --button "OK" < /usr/share/licenses/gpl.txt ;;
727 *)
728 usage ;;
729 esac
731 exit 0