slitaz-tools view tazbox/tazbox @ rev 958

tazbox: fix possibly problems with geoip
(It ended before with the empty message box with [Yes] [No] buttons)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Nov 12 11:37:45 2015 +0200 (2015-11-12)
parents bffe37afb546
children 72f3c042d777
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='preferences-desktop-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')!document-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 # freegeoip.net can be in the blocked hosts list. Return only correct answer or nothing
257 [ ! -e $csv ] && wget -q -T3 -O - http://freegeoip.net/csv/ 2&>/dev/null | \
258 grep '[0-9.]*,.*,.*,.*,.*,.*,.*,.*,[0-9.]*,[0-9.]*' > $csv
259 [ -e $csv ] && cut -d, -f2 $csv
260 }
263 #
264 # TZ functions
265 #
268 # list of all existing available locations for country
270 tz_list() {
271 find $zi | \
272 grep -E "$(awk -F$'\t' -vv="$1" '{if ($1 == v || $2 ~ v) print $2}' $ztab | tr ' ' '|')" | \
273 grep -v -E "posix|right" | \
274 sed 's|.*/||g' | sort
275 }
278 # ask for confirmation only if we have what to choose
280 tz_suggest() {
281 CountryCode=$(geoip)
282 if [ -n "$CountryCode" ]; then
283 if [ -n "$(tz_list $CountryCode)" ]; then
284 CountryName=$(cut -d, -f3 $csv)
285 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
286 --on-top --center \
287 --image="$CountryCode" --image-on-top \
288 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
289 $(_ 'Are you agreed?')" \
290 --button='gtk-yes:0' --button='gtk-no:1'
291 [ "$?" -eq 0 ] && echo $CountryCode
292 fi
293 fi
294 }
297 tz_select() {
298 case x$1 in
299 x)
300 # first pass - country
301 tmpcc=$(mktemp)
303 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
304 grep -m1 $(basename $tzfile) $ztab
305 done | cut -d$'\t' -f1 | sort -u > $tmpcc
307 for CC in $(cat $tmpcc); do
308 cat << EOT
309 $CC
310 $CC
311 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d$'\t' -f2 | sed 's|\&|&amp;|g')
312 EOT
313 done | \
314 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
315 --width='500' --height='380' --on-top --center \
316 --image="$icon" --image-on-top \
317 --text="<b>$(_ 'TimeZone Configuration')</b> \
318 \n$(_ 'Select country and press "Forward" or manually select timezone file.') \
319 \n\n$(_ 'Tip: manage timezones list by installing/removing locale packages.')" \
320 --list \
321 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
322 --button="$(_n 'Manage')!document-properties:4" \
323 --button="$(_n 'Manual')!gtk-index:2" \
324 --button="gtk-go-forward:0" \
325 --button="gtk-cancel:1" --always-print-result \
326 --print-column='2' --separator=''
327 ;;
328 xindex)
329 # manual selection of file with timezone info
330 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
331 --width='500' --on-top --center \
332 --image="$icon" --image-on-top \
333 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
334 --form --field=":FL" ${zi}UTC --separator='' | \
335 sed "s|$zi||"
336 ;;
337 *)
338 # second pass - city/place
339 list=$(tz_list $1)
340 icon="$1"
341 if [ $(echo "$list" | wc -l) != 1 ]; then
342 echo "$list" | \
343 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
344 --width='500' --height='380' --on-top --center \
345 --image="$icon" --image-on-top \
346 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
347 --list --column $(_n 'Location/City') --separator=''
348 else
349 echo $list
350 fi
351 ;;
352 esac
353 }
356 tz() {
357 icon='preferences-system-time'
358 arg=$(tz_suggest)
360 timezone=$(tz_select $arg)
361 case $? in
362 1) exit 0 ;;
363 0)
364 [ -n "$timezone" ] && timezone=$(tz_select "$timezone")
365 [ -z "$timezone" ] && exit 0
366 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
367 sed "s|$zi||")
368 ;;
369 2) timezone=$(tz_select "index") ;;
370 4) tazbox manage_i18n main;;
371 esac
373 [ -z "$timezone" ] && exit 0
374 echo $timezone > /etc/TZ
375 export TZ=$timezone
376 tazbox notify "$(_ 'TimeZone was set to %s' "$timezone")" $icon 3
377 rm -f $tmpcc
378 }
381 #
382 # Manage i18n packages
383 #
386 # if installed
388 if_installed() {
389 [ -d "$INSTALLED/$1" ]
390 }
393 # get package's description, install flag and sizes
395 desc_etc() {
396 if grep -q "^$1"$'\t' "$PKGS_DB/installed.info"; then
397 echo 'TRUE' >> $PKGS_LIST; echo $1 >> $ORIG_LIST
398 else
399 echo 'FALSE' >> $PKGS_LIST
400 fi
401 awk -F$'\t' -vp="$1" '
402 ($1==p){
403 split($7, s, " ");
404 printf "%s\n%s\n%s\n%s\n", $1, $4, s[1], s[2];
405 }' "$PKGS_DB/packages.info" >> $PKGS_LIST
406 }
409 # remove temp
411 rm_temp() {
412 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
413 }
416 # install/remove locale packages
418 manage_i18n() {
419 PKGS_LIST=$(mktemp)
420 ORIG_LIST=$(mktemp)
421 ANSWER=$(mktemp)
422 NEW_LIST=$(mktemp)
423 LIST1=$(mktemp)
424 LIST2=$(mktemp)
425 PINFO="$PKGS_DB/packages.info"
427 if [ ! -e "$PINFO" ]; then
428 icon='dialog-warning'
429 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
430 --width='400' --on-top --center \
431 --image="$icon" --image-on-top \
432 --text="$(_n 'Please, recharge packages database.')" \
433 --button="$(_n 'Recharge list')!view-refresh:2" \
434 --button="gtk-cancel:1"
436 case "$?" in
437 1) rm_temp; return;;
438 2) tazbox recharge;;
439 esac
440 fi
442 tazbox notify "$(_ 'Please wait')" appointment-soon &
444 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+$/{print $1}' $PINFO); do
445 desc_etc $i
446 done
448 if [ "$1" != 'main' ]; then
449 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+-extra$/{print $1}' $PINFO); do
450 desc_etc $i
451 done
453 if if_installed libQtCore; then
454 for i in $(awk -F$'\t' '$1~/^qt-locale/{print $1}' $PINFO); do
455 desc_etc $i
456 done
457 fi
459 if if_installed razorqt; then
460 for i in $(awk -F$'\t' '$1~/^razorqt-locale/{print $1}' $PINFO); do
461 desc_etc $i
462 done
463 fi
465 if if_installed firefox; then
466 for i in $(awk -F$'\t' '$1~/^firefox-langpack/{print $1}' $PINFO); do
467 desc_etc $i
468 done
469 fi
471 if if_installed thunderbird; then
472 for i in $(awk -F$'\t' '$1~/^thunderbird-langpack/{print $1}' $PINFO); do
473 desc_etc $i
474 done
475 fi
477 if if_installed squirrelmail; then
478 for i in $(awk -F$'\t' '$1~/^squirrelmail-[a-z][a-z][_-]/{print $1}' $PINFO); do
479 desc_etc $i
480 done
481 fi
483 if if_installed aspell; then
484 for i in $(awk -F$'\t' '$1~/^aspell-[a-z][a-z]_?[A-Z]?[A-Z]?$/{print $1}' $PINFO); do
485 desc_etc $i
486 done
487 fi
489 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
490 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
491 ufraw|-locales qupzilla|-locales"
492 for i in $OTHER_LOCALE; do
493 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
494 done
495 fi
497 icon='preferences-desktop-locale'
498 cat $PKGS_LIST | \
499 {
500 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
501 --width='600' --height='400' --on-top --center \
502 --image="$icon" --image-on-top \
503 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
504 --list --multiple --ellipsize='END' --expand-column='3' \
505 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
506 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
507 --column="$(_n 'Installed'):TEXT" \
508 --button="$(_n 'Recharge list')!view-refresh:4" \
509 --button="$(_n 'Install/Remove')!gtk-execute:2" \
510 --button="gtk-cancel:1" \
511 --print-all
512 } > $ANSWER
514 case "$?" in
515 1) rm_temp; exit 0;;
516 4) tazbox recharge; rm_temp; tazbox manage_i18n; exit 0;;
517 esac
519 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
521 # check difference between ORIG_LIST and NEW_LIST
522 sort -o $LIST1 $ORIG_LIST
523 sort -o $LIST2 $NEW_LIST
524 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
525 if [ -z "$DIFF" ]; then rm_temp; exit 0; fi
527 # output log to gtk window
528 title="$(_n 'TazPkg log')"; icon='system-software-update'; opts='--tail'
529 {
530 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
531 _ 'REMOVE: %s' "$pkg"
532 yes | tazpkg -r $pkg --output='raw'
533 done
534 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
535 _ 'INSTALL: %s' "$pkg"
536 tazpkg -gi $pkg --output='raw'
537 done
538 echo -e "\n\n$(_n 'Done!')\n"
539 } | output_command
540 rm_temp
541 }
545 # New file functions
547 newfile_main() {
548 icon='document-new'
549 yad --title="$(_n 'New file')" --window-icon="$icon" \
550 --width='460' --height='160' --on-top --center \
551 --image="$icon" --image-on-top \
552 --icon="$icon" \
553 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
554 --entry --entry-label="$(_n 'File name')" \
555 --ricon='edit-clear' \
556 --always-print-result \
557 --button="$(_n 'SHell script')!application-x-shellscript:4" \
558 --button="$(_n 'Folder')!folder:3" \
559 --button="$(_n 'File')!empty:2" \
560 --button='gtk-cancel:1'
561 }
564 newfile() {
565 file=$(newfile_main)
566 ret=$?
567 [ -z "$file" ] && exit 0
568 case $ret in
569 4)
570 cat > "$HOME/Desktop/$file" << EOT
571 #!/bin/sh
572 #
574 EOT
575 chmod +x "$HOME/Desktop/$file" ;;
576 3) mkdir -p "$HOME/Desktop/$file" ;;
577 2) touch "$HOME/Desktop/$file" ;;
578 1) exit 0 ;;
579 esac
580 }
583 # All applications
585 all_apps() {
586 icon='user-bookmarks'
587 yad --title="$(_n 'All Applications')" --window-icon="$icon" \
588 --width='400' --height='400' \
589 --icons --compact \
590 --read-dir='/usr/share/applications' \
591 --button='gtk-close:0'
592 }
595 # Ask root permissions for system settings
597 ask_root() {
598 if [ "$(id -u)" -ne 0 ]; then
599 exec tazbox su $0 $@
600 exit 0
601 fi
602 }
605 #
606 # Commands
607 #
609 case "$1" in
610 su)
611 shift
612 # Don't show dialog if we are root
613 [ "$(id -u)" -eq 0 ] && exec "$@"
614 SU_CMD="$@"
615 SUBOX_CONF="$HOME/.config/slitaz/subox.conf"
617 # Check if a password has been saved before launching main dialog
618 if [ -s "$SUBOX_CONF" ]; then
619 PASSWD="$(cat $SUBOX_CONF)"
620 CHECKED='TRUE'
621 fi
623 # Display the main dialog (ask for password)
624 main="$(su_main "$SU_CMD")"
626 # Deal with --button values and exit if cancelled to avoid erasing
627 # saved password.
628 [ "$?" -eq 1 ] && exit 0
630 # Save or erase Autosaved password
631 if [ $(echo "$main" | cut -d"|" -f2) == 'TRUE' ]; then
632 echo "$main" | cut -d"|" -f1 > $SUBOX_CONF
633 chmod 0600 $SUBOX_CONF
634 else
635 cat /dev/null > $SUBOX_CONF
636 fi
638 # Try to login & execute. If password is wrong execute error dialog
639 SU_CMD_QUOTED="$(echo "dbus-launch --exit-with-session $SU_CMD" | sed 's|&|\\&|g')"
640 echo $main | cut -d"|" -f1 | su -c "$SU_CMD_QUOTED &" || su_error
641 ;;
643 logout)
644 # Logout window with actions
645 if [ -n "$oldstyle" ]; then
646 answer=$(logout_oldstyle)
647 else
648 logout_main; answer=$?
649 fi
651 # Deal with --button values
652 # DE and WM started with a custom -session script should export
653 # XDG_CURRENT_DESKTOP
654 case $answer in
655 4|*exit)
656 case $XDG_CURRENT_DESKTOP in
657 LXDE)
658 [ -n "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
659 [ "$DESKTOP_SESSION" == 'compiz' ] && killall compiz
660 openbox --exit ;;
661 openbox) openbox --exit ;;
662 compiz) killall compiz ;;
663 *)
664 # Try to kill other WM that dont set XDG var.
665 jwm -exit 2>/dev/null ;;
666 esac ;;
667 3|*reboot)
668 reboot || reboot -f ;;
669 2|*halt)
670 poweroff ;;
671 esac
672 ;;
674 out)
675 # Pipe a command into a GTK window
676 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command
677 ;;
679 out-dl)
680 # A tiny GTK window for Busybox wget output
681 url="$2"; opts='--tail --button=gtk-cancel:1'
682 icon='folder-download'; title="$(_ 'Downloading...')"
683 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
684 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
685 cancel_dl
686 ;;
688 locale)
689 ask_root $@ && locale
690 ;;
692 keymap)
693 ask_root $@ && keymap
694 ;;
696 tz)
697 ask_root $@ && tz
698 ;;
700 manage_i18n)
701 ask_root $@ && manage_i18n $2
702 ;;
704 recharge)
705 ask_root $@; opts='--on-top'; output=raw tazpkg recharge | output_command
706 ;;
708 setup)
709 ask_root $@ && setup
710 ;;
712 new-file)
713 newfile
714 ;;
716 all-apps)
717 all_apps
718 ;;
720 notify|-n)
721 # On screen notification box.
722 icon="$3"
723 time="$4"
724 [ -z "$icon" ] && icon='dialog-information'
725 [ -z "$time" ] && time='4'
726 yad --width='520' --height='80' --timeout="$time" --timeout-indicator='right' \
727 --on-top --center --no-buttons --borders='12' --undecorated \
728 --skip-taskbar --image="$icon" --image-on-top --text="<b>$2</b>"
729 ;;
731 tazapps)
732 # Default applications configuration script. System wide config file
733 # is /etc/slitaz/applications.conf and each user can have personal
734 # settings. System wide for root and personal config for user.
735 export CONFIG="$HOME/.config/slitaz/applications.conf"
736 if [ "$(id -u)" -eq 0 ]; then
737 [ ! -f $CONFIG ] || mv -f $CONFIG /etc/slitaz/applications.conf
738 export CONFIG='/etc/slitaz/applications.conf'
739 fi
741 for a in FILE_MANAGERS BROWSERS EDITORS TERMINALS WINDOW_MANAGERS; do
742 eval $(expr $a=$(echo $(LC_ALL=C tazx get-applist ${a%%S} \
743 only-installed yad) | sed 's/ /!/g ; s/!!//g; s/ //g'))
744 done
746 # Missing file was created by slitaz_apps_conf function from tazx
747 . $CONFIG
749 icon='preferences-desktop-default-applications'
750 eval $(yad --title="$(_n 'SliTaz default applications')" \
751 --window-icon="$icon" --image="$icon" --image-on-top \
752 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
753 --form \
754 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
755 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
756 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
757 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
758 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
759 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
760 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
762 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
763 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
764 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
765 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
766 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
767 -i $CONFIG
768 ;;
770 gpl)
771 yad --title='GNU General Public License' --window-icon='text-x-copying' \
772 --geometry='650x500' \
773 --image='/usr/share/pixmaps/gpl3.png' --image-on-top \
774 --center \
775 --text-info \
776 --fontname='monospace' \
777 --button 'OK' < /usr/share/licenses/gpl.txt
778 ;;
780 *)
781 usage
782 ;;
783 esac
785 exit 0