slitaz-tools view tazbox/tazbox @ rev 972
Update fr.po (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 27 12:04:44 2016 +0200 (2016-03-27) |
parents | 72f3c042d777 |
children | 53c750021d6d |
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 vnc $(_ 'Launch a framebuffer VNC viewer')"
60 newline
61 }
64 # try to find icon in .desktop files
66 find_icon() {
67 local_desktop=$(find $HOME/.local/share/applications \
68 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
69 system_desktop=$(find /usr/share/applications \
70 -name ${1##*/}.desktop 2&>/dev/null | head -n1)
71 desktop="${local_desktop:-$system_desktop}"
72 [ -n "$desktop" ] && cat $desktop | sed '/\[Desktop\ Entry\]/,/^\[/!d' | \
73 sed '/^Icon=/!d' | head -n1 | cut -d= -f2
74 }
77 # su frontend GUIs
79 su_main() {
80 CMD1="${1%% *}"; CMD2="$(echo "${1#* }" | sed 's|&|&|g')"
81 : ${icon=$(find_icon $CMD1)}
82 icon="${icon:-dialog-password}"
84 yad --title="$(_n 'SliTaz admin password')" --window-icon=$icon \
85 --width=520 --on-top --center \
86 --image=$icon --image-on-top \
87 --text="$(_n 'Please enter root password (default root) to execute:')\n
88 <span foreground=\"red\"><tt><b>$CMD1</b> $CMD2</tt></span>\n" \
89 --form \
90 --field="$(_n 'Password:'):H" $PASSWD \
91 --field="$(_n 'Autosave password'):CHK" $CHECKED
92 }
95 su_error() {
96 icon='dialog-error'
97 yad --title="$(_n 'Error')" --window-icon=$icon \
98 --width=320 --on-top --center \
99 --image=$icon --image-on-top \
100 --text="\n<b>$(_n 'Error: wrong password!')</b>\n" \
101 --button="gtk-close:1"
102 }
105 # user may press cancel on download.
107 cancel_dl() {
108 if [ "$?" -eq 1 ]; then
109 _ "CANCEL"
110 rm -f $DOWNLOADS/$(basename $url)
111 fi
112 }
115 # output a command in a GTK window
117 output_command() {
118 : ${title=$(_n 'TazBox Output')}
119 : ${icon=dialog-information}
121 yad --title="$title" --window-icon="$icon" \
122 --geometry='600x220+0-24' --fore='#ffffff' --back='#000000' \
123 --text-info --fontname=monospace --wrap $opts \
124 --button='gtk-close:1'
125 }
128 # logout GUI function
130 logout_main() {
131 icon='/usr/share/pixmaps/slitaz-icon.png'
132 yad --title="$(_n 'SliTaz Logout')" --window-icon="$icon" \
133 --on-top --center --height='130' \
134 --image="$icon" --image-on-top \
135 --text="<b>$(_n 'SliTaz Logout - Please choose an action:')</b>" \
136 --always-print-result \
137 --button "$(_n 'Close X session')!system-log-out:4" \
138 --button "$(_n 'Reboot system')!system-reboot:3" \
139 --button "$(_n 'Shutdown system')!system-shutdown:2"
140 }
143 # generate keymap list
145 gen_kmap_list() {
146 echo > $tmp
147 cd /usr/share/kbd/keymaps/i386
148 # we first need a list to sort and then use \n for Yad list.
149 for i in $(find -type f | sed '/include/d; s|./||'); do
150 echo "$(basename $i .map.gz)|$(dirname $i)" >> $tmp
151 done
152 }
155 # Initial Config functions
157 setup_main() {
158 icon='preferences-desktop-locale'
159 gen_kmap_list
160 locale=$(ls -1 $db | grep ^[a-z][a-z]_[A-Z][A-Z] | tr "\n" "!")
161 keymap=$(cat $tmp | sort | tr "\n" "!")
162 timezone=$(find $zi -type f | sed s,$zi,,g | grep -v -F '.tab' | tr "\n" "!")
163 yad --title="$(_n 'SliTaz Initial Setup')" --window-icon=$icon \
164 --width='500' \
165 --image="$icon" --image-on-top \
166 --text="<big>$(_n 'Here you can set your preferences \n for <b>locale, keymap and timezone</b>.')</big>" \
167 --form \
168 --field "$(_n 'Locale'):CB" $locale \
169 --field "$(_n 'Keymap'):CB" $keymap \
170 --field "$(_n 'Timezone'):CB" $timezone
171 }
174 setup() {
175 choices=$(setup_main)
176 locale=$( echo $choices | cut -d'|' -f1)
177 keymap=$( echo $choices | cut -d'|' -f2)
178 timezone=$(echo $choices | cut -d'|' -f3)
179 [ -n "$locale" ] && tazlocale init $locale
180 [ -n "$keymap" ] && tazkeymap init $keymap
181 [ -n "$timezone" ] && echo $timezone > /etc/TZ
182 }
185 #
186 # Locale functions
187 #
189 locale_main() {
190 icon='preferences-desktop-locale'
191 for locale in $(ls -1 $db | grep '[a-z]_[A-Z]'); do
192 desc=$(fgrep -m1 title $db/$locale | cut -d'"' -f2)
193 ll_CC=${locale%%@*}
194 echo -e "${ll_CC##*_}\n$locale\n$desc"
195 done | \
196 yad --title="$(_n 'SliTaz locale')" --window-icon="$icon" \
197 --width='600' --height='380' --sticky --on-top --center \
198 --image="$icon" --image-on-top \
199 --text="<b>$(_n 'Language configuration')</b> \
200 \n\n$(_ 'Tip: manage locales list by installing/removing locale packages.')" \
201 --list --column="$(_n 'Flag'):IMG" --column $(_n 'Name') \
202 --column $(_n 'Description') \
203 --print-column='2' --separator='' \
204 --button="$(_n 'Manage')!document-properties:2" \
205 --button="gtk-cancel:1" --button="gtk-ok:0"
206 }
209 locale() {
210 locale=$(locale_main)
211 # Deal with --button values
212 case $? in
213 2) tazbox manage_i18n main ;;
214 1) exit 0 ;;
215 *) continue ;;
216 esac
217 # System language configuration.
218 if [ "$locale" ]; then
219 tazlocale $locale
220 tazbox notify "$(_ 'Locale was set to %s' "$locale")" \
221 preferences-desktop-locale 3
222 fi
223 }
226 # Keymap functions
228 keymap_main() {
229 icon='preferences-desktop-keyboard'
230 gen_kmap_list
231 for i in $(sort $tmp); do
232 echo "$i" | tr '|' '\n'
233 done | \
234 yad --title="$(_ 'SliTaz keymap')" --window-icon=$icon \
235 --width=500 --height=380 --sticky --on-top --center \
236 --image=$icon --image-on-top \
237 --text="<b>$(_n 'Keyboard configuration')</b>" \
238 --list --column $(_n 'Keymap') --column $(_n 'Type') \
239 --print-column=1 --separator=''
240 rm -f $tmp
241 }
244 keymap() {
245 keymap=$(keymap_main)
246 # Deal with --button values
247 [ "$?" -eq 1 ] && exit 0
248 # System keymap configuration
249 [ -n "$keymap" ] && tazkeymap $keymap
250 }
253 # Free GeoIP service
254 # Response: IP,CountryCode,CountryName, ...
256 geoip() {
257 # freegeoip.net can be in the blocked hosts list. Return only correct answer or nothing
258 [ ! -e $csv ] && wget -q -T3 -O - http://freegeoip.net/csv/ 2&>/dev/null | \
259 grep '[0-9.]*,.*,.*,.*,.*,.*,.*,.*,[0-9.]*,[0-9.]*' > $csv
260 [ -e $csv ] && cut -d, -f2 $csv
261 }
264 #
265 # TZ functions
266 #
269 # list of all existing available locations for country
271 tz_list() {
272 find $zi | \
273 grep -E "$(awk -F$'\t' -vv="$1" '{if ($1 == v || $2 ~ v) print $2}' $ztab | tr ' ' '|')" | \
274 grep -v -E "posix|right" | \
275 sed 's|.*/||g' | sort
276 }
279 # ask for confirmation only if we have what to choose
281 tz_suggest() {
282 CountryCode=$(geoip)
283 if [ -n "$CountryCode" ]; then
284 if [ -n "$(tz_list $CountryCode)" ]; then
285 CountryName=$(cut -d, -f3 $csv)
286 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
287 --on-top --center \
288 --image="$CountryCode" --image-on-top \
289 --text="$(_ 'Suggested location:') <b>$CountryName</b>\n
290 $(_ 'Are you agreed?')" \
291 --button='gtk-yes:0' --button='gtk-no:1'
292 [ "$?" -eq 0 ] && echo $CountryCode
293 fi
294 fi
295 }
298 tz_select() {
299 case x$1 in
300 x)
301 # first pass - country
302 tmpcc=$(mktemp)
304 for tzfile in $(find $zi -type f -regex '.*info/[ABCEIMP].*'); do
305 grep -m1 $(basename $tzfile) $ztab
306 done | cut -d$'\t' -f1 | sort -u > $tmpcc
308 for CC in $(cat $tmpcc); do
309 cat << EOT
310 $CC
311 $CC
312 $(grep -m1 "$CC " ${zi}iso3166.tab | cut -d$'\t' -f2 | sed 's|\&|&|g')
313 EOT
314 done | \
315 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
316 --width='500' --height='380' --on-top --center \
317 --image="$icon" --image-on-top \
318 --text="<b>$(_ 'TimeZone Configuration')</b> \
319 \n$(_ 'Select country and press "Forward" or manually select timezone file.') \
320 \n\n$(_ 'Tip: manage timezones list by installing/removing locale packages.')" \
321 --list \
322 --column="$(_n 'Flag'):IMG" --column=$(_n 'Code') --column=$(_n 'Country') \
323 --button="$(_n 'Manage')!document-properties:4" \
324 --button="$(_n 'Manual')!gtk-index:2" \
325 --button="gtk-go-forward:0" \
326 --button="gtk-cancel:1" --always-print-result \
327 --print-column='2' --separator=''
328 ;;
329 xindex)
330 # manual selection of file with timezone info
331 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
332 --width='500' --on-top --center \
333 --image="$icon" --image-on-top \
334 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select time zone')" \
335 --form --field=":FL" ${zi}UTC --separator='' | \
336 sed "s|$zi||"
337 ;;
338 *)
339 # second pass - city/place
340 list=$(tz_list $1)
341 icon="$1"
342 if [ $(echo "$list" | wc -l) != 1 ]; then
343 echo "$list" | \
344 yad --title="$(_ 'SliTaz TZ')" --window-icon="$icon" \
345 --width='500' --height='380' --on-top --center \
346 --image="$icon" --image-on-top \
347 --text="<b>$(_ 'TimeZone Configuration')</b>\n$(_ 'Select location')" \
348 --list --column $(_n 'Location/City') --separator=''
349 else
350 echo $list
351 fi
352 ;;
353 esac
354 }
357 tz() {
358 icon='preferences-system-time'
359 arg=$(tz_suggest)
361 timezone=$(tz_select $arg)
362 case $? in
363 1) exit 0 ;;
364 0)
365 [ -n "$timezone" ] && timezone=$(tz_select "$timezone")
366 [ -z "$timezone" ] && exit 0
367 timezone=$(find $zi -name $timezone | grep -v -E "posix|right" | \
368 sed "s|$zi||")
369 ;;
370 2) timezone=$(tz_select "index") ;;
371 4) tazbox manage_i18n main;;
372 esac
374 [ -z "$timezone" ] && exit 0
375 echo $timezone > /etc/TZ
376 export TZ=$timezone
377 tazbox notify "$(_ 'TimeZone was set to %s' "$timezone")" $icon 3
378 rm -f $tmpcc
379 }
382 #
383 # Manage i18n packages
384 #
387 # if installed
389 if_installed() {
390 [ -d "$INSTALLED/$1" ]
391 }
394 # get package's description, install flag and sizes
396 desc_etc() {
397 if grep -q "^$1"$'\t' "$PKGS_DB/installed.info"; then
398 echo 'TRUE' >> $PKGS_LIST; echo $1 >> $ORIG_LIST
399 else
400 echo 'FALSE' >> $PKGS_LIST
401 fi
402 awk -F$'\t' -vp="$1" '
403 ($1==p){
404 split($7, s, " ");
405 printf "%s\n%s\n%s\n%s\n", $1, $4, s[1], s[2];
406 }' "$PKGS_DB/packages.info" >> $PKGS_LIST
407 }
410 # remove temp
412 rm_temp() {
413 rm -f $PKGS_LIST $ORIG_LIST $ANSWER $NEW_LIST $LIST1 $LIST2
414 }
417 # install/remove locale packages
419 manage_i18n() {
420 PKGS_LIST=$(mktemp)
421 ORIG_LIST=$(mktemp)
422 ANSWER=$(mktemp)
423 NEW_LIST=$(mktemp)
424 LIST1=$(mktemp)
425 LIST2=$(mktemp)
426 PINFO="$PKGS_DB/packages.info"
428 if [ ! -e "$PINFO" ]; then
429 icon='dialog-warning'
430 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
431 --width='400' --on-top --center \
432 --image="$icon" --image-on-top \
433 --text="$(_n 'Please, recharge packages database.')" \
434 --button="$(_n 'Recharge list')!view-refresh:2" \
435 --button="gtk-cancel:1"
437 case "$?" in
438 1) rm_temp; return;;
439 2) tazbox recharge;;
440 esac
441 fi
443 tazbox notify "$(_ 'Please wait')" appointment-soon &
445 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+$/{print $1}' $PINFO); do
446 desc_etc $i
447 done
449 if [ "$1" != 'main' ]; then
450 for i in $(awk -F$'\t' '$1~/^locale-[a-z_A-Z]+-extra$/{print $1}' $PINFO); do
451 desc_etc $i
452 done
454 if if_installed libQtCore; then
455 for i in $(awk -F$'\t' '$1~/^qt-locale/{print $1}' $PINFO); do
456 desc_etc $i
457 done
458 fi
460 if if_installed razorqt; then
461 for i in $(awk -F$'\t' '$1~/^razorqt-locale/{print $1}' $PINFO); do
462 desc_etc $i
463 done
464 fi
466 if if_installed firefox; then
467 for i in $(awk -F$'\t' '$1~/^firefox-langpack/{print $1}' $PINFO); do
468 desc_etc $i
469 done
470 fi
472 if if_installed thunderbird; then
473 for i in $(awk -F$'\t' '$1~/^thunderbird-langpack/{print $1}' $PINFO); do
474 desc_etc $i
475 done
476 fi
478 if if_installed squirrelmail; then
479 for i in $(awk -F$'\t' '$1~/^squirrelmail-[a-z][a-z][_-]/{print $1}' $PINFO); do
480 desc_etc $i
481 done
482 fi
484 if if_installed aspell; then
485 for i in $(awk -F$'\t' '$1~/^aspell-[a-z][a-z]_?[A-Z]?[A-Z]?$/{print $1}' $PINFO); do
486 desc_etc $i
487 done
488 fi
490 OTHER_LOCALE="gnome-commander|-i18n gnome-vfs|-i18n gpa|-langpack \
491 gucharmap|-i18n lxterminal|-locales lyx|-locales rox-filer|-locales \
492 ufraw|-locales qupzilla|-locales"
493 for i in $OTHER_LOCALE; do
494 if if_installed ${i%%|*}; then desc_etc ${i/|/}; fi
495 done
496 fi
498 icon='preferences-desktop-locale'
499 cat $PKGS_LIST | \
500 {
501 yad --title="$(_n 'Manage locale packages')" --window-icon="$icon" \
502 --width='600' --height='400' --on-top --center \
503 --image="$icon" --image-on-top \
504 --text="$(_n 'Check only locale packages you need and press "Install/Remove".')" \
505 --list --multiple --ellipsize='END' --expand-column='3' \
506 --column="$(_n 'Inst.'):CHK" --column="$(_n 'Package Name'):TEXT" \
507 --column="$(_n 'Description'):TEXT" --column="$(_n 'Size'):TEXT" \
508 --column="$(_n 'Installed'):TEXT" \
509 --button="$(_n 'Recharge list')!view-refresh:4" \
510 --button="$(_n 'Install/Remove')!gtk-execute:2" \
511 --button="gtk-cancel:1" \
512 --print-all
513 } > $ANSWER
515 case "$?" in
516 1) rm_temp; exit 0;;
517 4) tazbox recharge; rm_temp; tazbox manage_i18n; exit 0;;
518 esac
520 grep -e 'TRUE' $ANSWER | cut -d'|' -f2 > $NEW_LIST
522 # check difference between ORIG_LIST and NEW_LIST
523 sort -o $LIST1 $ORIG_LIST
524 sort -o $LIST2 $NEW_LIST
525 DIFF=$(diff $LIST1 $LIST2 | sed '/---/d;/+++/d;/@@/d')
526 if [ -z "$DIFF" ]; then rm_temp; exit 0; fi
528 # output log to gtk window
529 title="$(_n 'TazPkg log')"; icon='system-software-update'; opts='--tail'
530 {
531 for pkg in $(echo "$DIFF" | grep -e '^-' | sed 's|^-||g'); do
532 _ 'REMOVE: %s' "$pkg"
533 yes | tazpkg -r $pkg --output='raw'
534 done
535 for pkg in $(echo "$DIFF" | grep -e '^+' | sed 's|^+||g'); do
536 _ 'INSTALL: %s' "$pkg"
537 tazpkg -gi $pkg --output='raw'
538 done
539 echo -e "\n\n$(_n 'Done!')\n"
540 } | output_command
541 rm_temp
542 }
546 # New file functions
548 newfile_main() {
549 icon='document-new'
550 yad --title="$(_n 'New file')" --window-icon="$icon" \
551 --width='460' --height='160' --on-top --center \
552 --image="$icon" --image-on-top \
553 --icon="$icon" \
554 --text="<b>$(_n 'Create a new file or folder on your desktop')</b>" \
555 --entry --entry-label="$(_n 'File name')" \
556 --ricon='edit-clear' \
557 --always-print-result \
558 --button="$(_n 'SHell script')!application-x-shellscript:4" \
559 --button="$(_n 'Folder')!folder:3" \
560 --button="$(_n 'File')!empty:2" \
561 --button='gtk-cancel:1'
562 }
565 newfile() {
566 file=$(newfile_main)
567 ret=$?
568 [ -z "$file" ] && exit 0
569 case $ret in
570 4)
571 cat > "$HOME/Desktop/$file" << EOT
572 #!/bin/sh
573 #
575 EOT
576 chmod +x "$HOME/Desktop/$file" ;;
577 3) mkdir -p "$HOME/Desktop/$file" ;;
578 2) touch "$HOME/Desktop/$file" ;;
579 1) exit 0 ;;
580 esac
581 }
584 # All applications
586 all_apps() {
587 icon='user-bookmarks'
588 yad --title="$(_n 'All Applications')" --window-icon="$icon" \
589 --width='400' --height='400' \
590 --icons --compact \
591 --read-dir='/usr/share/applications' \
592 --button='gtk-close:0'
593 }
596 # Ask root permissions for system settings
598 ask_root() {
599 if [ "$(id -u)" -ne 0 ]; then
600 exec tazbox su $0 $@
601 exit 0
602 fi
603 }
606 vnc_main() {
607 icon='video-display'
608 yad --title="$(_n 'Framebuffer VNC viewer')" --window-icon="$icon" \
609 --width='250' --height='160' --on-top --center \
610 --image="$icon" --image-on-top --icon="$icon" \
611 --form \
612 --text="<b>$(_n 'Remote display connection')</b>" "localhost 5900" \
613 --field="$(_n 'VNC Server')" \
614 --field="$(_n 'Via a SSH tunnel'):CHK" \
615 --always-print-result \
616 --button="$(_n 'On this console'):1" \
617 --button="$(_n 'In a new console'):0"
618 }
621 newvt()
622 {
623 ask_root newvt $@ || return
624 openvt -sw $@
625 deallocvt
626 }
629 vnc() {
630 server=$(vnc_main)
631 status=$?
632 # Deal with --button values
633 [ "$server" ] || return
634 case "$server" in
635 *TRUE\|) fbvnc=sshfbvnc ;;
636 *) fbvnc=fbvnc ;;
637 esac
638 case "$status" in
639 1) $fbvnc ${server%%|*} ;;
640 0) newvt $fbvnc ${server%%|*} ;;
641 esac
642 }
645 #
646 # Commands
647 #
649 case "$1" in
650 su)
651 shift
652 # Don't show dialog if we are root
653 [ "$(id -u)" -eq 0 ] && exec "$@"
654 SU_CMD="$@"
655 SUBOX_CONF="$HOME/.config/slitaz/subox.conf"
657 # Check if a password has been saved before launching main dialog
658 if [ -s "$SUBOX_CONF" ]; then
659 PASSWD="$(cat $SUBOX_CONF)"
660 CHECKED='TRUE'
661 fi
663 # Display the main dialog (ask for password)
664 main="$(su_main "$SU_CMD")"
666 # Deal with --button values and exit if cancelled to avoid erasing
667 # saved password.
668 [ "$?" -eq 1 ] && exit 0
670 # Save or erase Autosaved password
671 if [ $(echo "$main" | cut -d"|" -f2) == 'TRUE' ]; then
672 echo "$main" | cut -d"|" -f1 > $SUBOX_CONF
673 chmod 0600 $SUBOX_CONF
674 else
675 cat /dev/null > $SUBOX_CONF
676 fi
678 # Try to login & execute. If password is wrong execute error dialog
679 SU_CMD_QUOTED="$(echo "dbus-launch --exit-with-session $SU_CMD" | sed 's|&|\\&|g')"
680 echo $main | cut -d"|" -f1 | su -c "$SU_CMD_QUOTED &" || su_error
681 ;;
683 logout)
684 # Logout window with actions
685 if [ -n "$oldstyle" ]; then
686 answer=$(logout_oldstyle)
687 else
688 logout_main; answer=$?
689 fi
691 # Deal with --button values
692 # DE and WM started with a custom -session script should export
693 # XDG_CURRENT_DESKTOP
694 case $answer in
695 4|*exit)
696 case $XDG_CURRENT_DESKTOP in
697 LXDE)
698 [ -n "$_LXSESSION_PID" ] && kill $_LXSESSION_PID
699 [ "$DESKTOP_SESSION" == 'compiz' ] && killall compiz
700 openbox --exit ;;
701 openbox) openbox --exit ;;
702 compiz) killall compiz ;;
703 *)
704 # Try to kill other WM that dont set XDG var.
705 jwm -exit 2>/dev/null ;;
706 esac ;;
707 3|*reboot)
708 reboot || reboot -f ;;
709 2|*halt)
710 poweroff ;;
711 esac
712 ;;
714 out)
715 # Pipe a command into a GTK window
716 sed 's|\[.m||g; s|\[[0-9][0-9]*G| |g' | output_command
717 ;;
719 out-dl)
720 # A tiny GTK window for Busybox wget output
721 url="$2"; opts='--tail --button=gtk-cancel:1'
722 icon='folder-download'; title="$(_ 'Downloading...')"
723 [ -d $DOWNLOADS ] || mkdir -p $DOWNLOADS
724 busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
725 cancel_dl
726 ;;
728 locale)
729 ask_root $@ && locale
730 ;;
732 keymap)
733 ask_root $@ && keymap
734 ;;
736 tz)
737 ask_root $@ && tz
738 ;;
740 manage_i18n)
741 ask_root $@ && manage_i18n $2
742 ;;
744 recharge)
745 ask_root $@; opts='--on-top'; output=raw tazpkg recharge | output_command
746 ;;
748 setup)
749 ask_root $@ && setup
750 ;;
752 new-file)
753 newfile
754 ;;
756 all-apps)
757 all_apps
758 ;;
760 notify|-n)
761 # On screen notification box.
762 icon="$3"
763 time="$4"
764 [ -z "$icon" ] && icon='dialog-information'
765 [ -z "$time" ] && time='4'
766 yad --width='520' --height='80' --timeout="$time" --timeout-indicator='right' \
767 --on-top --center --no-buttons --borders='12' --undecorated \
768 --skip-taskbar --image="$icon" --image-on-top --text="<b>$2</b>"
769 ;;
771 tazapps)
772 # Default applications configuration script. System wide config file
773 # is /etc/slitaz/applications.conf and each user can have personal
774 # settings. System wide for root and personal config for user.
775 export CONFIG="$HOME/.config/slitaz/applications.conf"
776 if [ "$(id -u)" -eq 0 ]; then
777 [ ! -f $CONFIG ] || mv -f $CONFIG /etc/slitaz/applications.conf
778 export CONFIG='/etc/slitaz/applications.conf'
779 fi
781 for a in FILE_MANAGERS BROWSERS EDITORS TERMINALS WINDOW_MANAGERS; do
782 eval $(expr $a=$(echo $(LC_ALL=C tazx get-applist ${a%%S} \
783 only-installed yad) | sed 's/ /!/g ; s/!!//g; s/ //g'))
784 done
786 # Missing file was created by slitaz_apps_conf function from tazx
787 . $CONFIG
789 icon='preferences-desktop-default-applications'
790 eval $(yad --title="$(_n 'SliTaz default applications')" \
791 --window-icon="$icon" --image="$icon" --image-on-top \
792 --text="<b>$(_n 'SliTaz default applications configuration')</b>" \
793 --form \
794 --field="$(_n 'File manager:'):CBE" "$FILE_MANAGERS" \
795 --field="$(_n 'Web browser:'):CBE" "$BROWSERS" \
796 --field="$(_n 'Text editor:'):CBE" "$EDITORS" \
797 --field="$(_n 'Terminal:'):CBE" "$TERMINALS" \
798 --field="$(_n 'Window manager:'):CBE" "$WINDOW_MANAGERS" | \
799 awk -F'|' '{printf "FILE_MANAGER=\"%s\"\nBROWSER=\"%s\"\nEDITOR=\"%s\"\
800 TERMINAL=\"%s\"\nWINDOW_MANAGER=\"%s\"\n", $1, $2, $3, $4, $5}')
802 sed '/FILE_MANAGER=/s|"\([^"]*\)"|"'$FILE_MANAGER'"|; \
803 /BROWSER=/s|"\([^"]*\)"|"'$BROWSER'"|; \
804 /EDITOR=/s|"\([^"]*\)"|"'$EDITOR'"|; \
805 /TERMINAL=/s|"\([^"]*\)"|"'$TERMINAL'"|; \
806 /WINDOW_MANAGER=/s|"\([^"]*\)"|"'$WINDOW_MANAGER'"|' \
807 -i $CONFIG
808 ;;
810 gpl)
811 yad --title='GNU General Public License' --window-icon='text-x-copying' \
812 --geometry='650x500' \
813 --image='/usr/share/pixmaps/gpl3.png' --image-on-top \
814 --center \
815 --text-info \
816 --fontname='monospace' \
817 --button 'OK' < /usr/share/licenses/gpl.txt
818 ;;
820 vnc)
821 vnc
822 ;;
824 newvt)
825 $@
826 ;;
828 *)
829 usage
830 ;;
831 esac
833 exit 0