slitaz-tools view tazbox/tazbox @ rev 912

tazx: add default applications dialog, replace lists from tazbox.
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Wed Nov 05 19:01:28 2014 +0200 (2014-11-05)
parents 8d6054abc5ee
children e0c2b81e8b1e
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 # Ask root permissions for system settings
524 ask_root() {
525 if [ $(id -u) != 0 ]; then
526 exec tazbox su $0 $@
527 exit 0
528 fi
529 }
531 #
532 # Commands
533 #
534 case "$1" in
535 su)
536 # Don't show dialog if we are root
537 test $(id -u) = 0 && exec ${@:2}
538 SU_CMD="${@:2}"
539 # Check if a password has been saved before launching main dialog
540 if [ -s $HOME/.config/slitaz/subox.conf ]; then
541 PASSWD=$(cat $HOME/.config/slitaz/subox.conf)
542 CHECKED="TRUE"
543 fi
544 # Display the main dialog (ask for password)
545 main=$(su_main $SU_CMD)
546 # Deal with --button values and exit if cancelled to avoid erasing
547 # saved password.
548 [ $? == 1 ] && exit 0
549 # Save or erase Autosaved password
550 if [ $(echo $main | cut -f2 -d"|") == "TRUE" ]; then
551 echo $main | cut -f 1 -d "|" > $HOME/.config/slitaz/subox.conf
552 chmod 0600 $HOME/.config/slitaz/subox.conf
553 else
554 cat /dev/null > $HOME/.config/slitaz/subox.conf
555 fi
556 # Try to login & execute. If password is wrong execute error dialog
557 SU_CMD_QUOTED="$(echo "dbus-launch $SU_CMD" --exit-with-session | sed 's|&|\\&|g')"
558 echo $main | cut -f 1 -d "|" | su -c "$SU_CMD_QUOTED &" || su_error ;;
559 logout)
560 # Logout window with actions
561 if [ "$oldstyle" ]; then
562 answer=$(logout_oldstyle)
563 else
564 logout_main; answer=$?
565 fi
566 # Deal with --button values
567 # DE and WM started with a custom -session script should export
568 # XDG_CURRENT_DESKTOP
569 case $answer in
570 4|*exit)
571 case $XDG_CURRENT_DESKTOP in
572 LXDE)
573 [ "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
574 [ "$DESKTOP_SESSION" == "compiz" ] && killall compiz
575 openbox --exit ;;
576 openbox) openbox --exit ;;
577 compiz) killall compiz ;;
578 *)
579 # Try to kill other WM that dont set XDG var.
580 jwm -exit 2>/dev/null ;;
581 esac ;;
582 3|*reboot)
583 reboot || reboot -f ;;
584 2|*halt)
585 poweroff ;;
586 esac ;;
587 out)
588 # Pipe a command into a GTK window
589 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command ;;
590 out-dl)
591 # A tiny GTK window for Busybox wget output
592 url=$2; opts="--tail --button=gtk-cancel:1"
593 icon=folder-downloads; title="$(_ 'Downloading...')"
594 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
595 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
596 cancel_dl ;;
597 locale)
598 ask_root $@ && locale ;;
599 keymap)
600 ask_root $@ && keymap ;;
601 tz)
602 ask_root $@ && tz ;;
603 manage_i18n)
604 ask_root $@ && manage_i18n $2 ;;
605 recharge)
606 ask_root $@; opts="--on-top"; tazpkg recharge | output_command ;;
607 setup)
608 ask_root $@ && setup ;;
609 new-file)
610 newfile ;;
611 all-apps)
612 all_apps ;;
613 notify|-n)
614 # On screen notification box.
615 icon="$3"
616 time="$4"
617 [ "$icon" ] || icon=info
618 [ "$time" ] || time=4
619 yad --width=520 --height=80 --timeout=$time --timeout-indicator=right \
620 --on-top --center --no-buttons --borders=12 --undecorated \
621 --skip-taskbar --image=$icon --image-on-top --text="<b>$2</b>" ;;
622 tazapps)
623 # Default applications configuration script. System wide config file
624 # is /etc/slitaz/applications.conf and each user can have personal
625 # settings. System wide for root and personal config for user.
626 export CONFIG="$HOME/.config/slitaz/applications.conf"
627 if [ "$(id -u)" = 0 ]; then
628 [ ! -f $CONFIG ] || mv -f $CONFIG /etc/slitaz/applications.conf
629 export CONFIG="/etc/slitaz/applications.conf"
630 fi
632 for a in FILE_MANAGERS BROWSERS EDITORS TERMINALS WINDOW_MANAGERS;
633 do
634 eval $(expr $a=$(echo $(/usr/bin/tazx get-applist ${a%%S} \
635 only-installed yad) | sed 's/ /!/g ; s/!!//g; s/ //g'))
636 done
638 # Missing file was created by slitaz_apps_conf function from tazx
639 . $CONFIG
641 icon=preferences-desktop-default-applications
642 eval $(yad --title="$(_n 'SliTaz default applications')" \
643 --window-icon=$icon --image=$icon --image-on-top \
644 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
645 --form \
646 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
647 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
648 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
649 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
650 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
651 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
652 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
654 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
655 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
656 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
657 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
658 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
659 -i $CONFIG ;;
660 gpl)
661 yad --title="GNU General Public License" --window-icon=text-x-generic \
662 --geometry="650x500" \
663 --image=/usr/share/pixmaps/gpl3.png --image-on-top \
664 --center \
665 --text-info \
666 --fontname=monospace \
667 --button "OK" < /usr/share/licenses/gpl.txt ;;
668 *)
669 usage ;;
670 esac
672 exit 0