tazpanel view settings.cgi @ rev 588
Un-fuzzy already translated messages; finish ru.po translations
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Apr 20 11:36:15 2016 +0300 (2016-04-20) |
parents | c79a4557c4b5 |
children | 5f988d8f32b1 |
line source
1 #!/bin/sh
2 #
3 # System settings CGI interface: user, locale, keyboard, date. Since we
4 # don't have multiple pages here there is only one case used to get command
5 # values and the full content is followed directly.
6 #
7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
8 #
11 # Common functions from libtazpanel
13 . lib/libtazpanel
14 get_config
16 TITLE=$(_ 'System settings')
19 listdb() {
20 for item in $(getdb $1 | cut -d: -f1); do
21 echo "<option>$item</option>\n"
22 done
23 }
26 restart_lxpanel() {
27 # `lxpanelctl restart` exists, but it breaks often leaving us without any panel
29 # parameters needed to run graphical application from script
30 if [ -z "$XAUTHORITY" ]; then
31 if [ -e "$HOME/.Xauthority" ]; then
32 export XAUTHORITY="$HOME/.Xauthority"
33 elif [ -e '/var/run/slim.auth' ]; then
34 export XAUTHORITY='/var/run/slim.auth'
35 fi
36 fi
37 [ -z "$DISPLAY" ] && export DISPLAY=':0.0'
39 # find LXPanel ProcessID, filter out zombie '[lxpanel]' (if any)
40 lxpanel_pid="$(ps -o comm,pid,args | fgrep lxpanel | fgrep -v fgrep | fgrep -v '[' | awk '{print $2}')"
42 # if LXPanel not running, just run it with default option
43 if [ -z "$lxpanel_pid" ]; then
44 lxpanel -p slitaz &
45 else
46 # who started LXPanel?..
47 lxpanel_user="$(ps -o pid,user | fgrep "$lxpanel_pid " | awk '{print $2}')"
49 # ... current user?
50 if [ "$USER" == "$lxpanel_user" ]; then
51 # custom command?
52 lxpanel_comm="$(ps -o pid,args | grep -e "^\ *$lxpanel_pid " | awk '{$1="";print}')"
53 [ -z "$lxpanel_comm" ] && lxpanel_comm='lxpanel -p slitaz'
55 # stop LXPanel and start it again with the same command
56 kill $lxpanel_pid
57 $lxpanel_comm &
58 fi
59 fi
61 }
65 #
66 # Commands executed before page loading.
67 #
69 case " $(GET) " in
70 *\ do\ *)
71 users=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="user") print $2}')
72 groups=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="group")print $2}')
74 case $(GET do) in
76 # Groups page
77 delgroups) for i in $groups; do delgroup $i; done ;;
78 addgroup) addgroup $groups ;;
79 addmember) addgroup $(GET member) $groups ;;
80 delmember) delgroup $(GET member) $groups ;;
82 # Users page
83 delusers) for i in $users; do deluser $i; done ;;
84 lockusers) for i in $users; do passwd -l $i | log; done ;;
85 unlockusers) for i in $users; do passwd -u $i | log; done ;;
86 chpasswd) echo "$users:$(GET password)" | chpasswd -m | log ;;
87 adduser)
88 if [ -n "$users" ]; then
89 name="$(GET name)"
90 adduser -D -s /bin/sh -g "${name:-SliTaz User}" -G users -h /home/$users $users
91 echo "$user:$(GET passwd)" | chpasswd -m | log
92 for i in audio cdrom floppy video tty; do addgroup $users $i; done
93 passwd -u $users | log
94 fi ;;
96 # System time
97 calendar)
98 # display Yad date picker (AJAX)
99 new_date="$(DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' \
100 yad --calendar --on-top --mouse --undecorated \
101 --window-icon=config-date --title="$(_ 'Set date')" \
102 --date-format='%x<span style="display:none">%F</span>')"
103 header
104 echo "$new_date"; exit 0;;
106 settz)
107 # set timezone
108 GET tz > /etc/TZ ;;
110 date)
111 # only accepted format is MMDDhhmm[[YY]YY][.ss]
112 if [ -n "$(GET dateFull)" ]; then
113 dateFull="$(GET dateFull)" # %F = YYYY-MM-DD
114 date $(printf '%02d%02d%02d%02d%d.%02d' "${dateFull:5:2}" \
115 "${dateFull:8:2}" "$(GET hour)" "$(GET min)" \
116 "${dateFull:0:4}" "$(GET sec)") >/dev/null
117 else
118 date $(printf '%02d%02d%02d%02d%d.%02d' "$(GET month)" \
119 "$(GET day)" "$(GET hour)" "$(GET min)" "$(GET year)" \
120 "$(GET sec)") >/dev/null
121 fi;;
123 rdate)
124 # get and possibly set the system date/time from a remote host
125 rdate -s tick.greyware.com ;;
127 hwclock)
128 # query and set hardware clock (RTC)
129 hwclock -w -u ;;
131 gethwclock)
132 # get date/time from hardware clock (AJAX)
133 header; hwclock -ur | sed 's|0.000000 seconds||'; exit 0;;
135 esac
136 ;;
139 *\ gen_locale\ *) new_locale=$(GET gen_locale) ;;
140 *\ gen_keymap\ *) new_keymap=$(GET gen_keymap) ;;
142 *\ apply_xorg_kbd\ *)
143 sed -i "s/XkbLayout.*/XkbLayout \" \"$(GET apply_xorg_kbd)\"/" \
144 /etc/X11/xorg.conf.d/40-Keyboard.conf ;;
145 *\ style*)
146 sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG
147 . $CONFIG ;;
150 *\ tweak\ *)
151 HOME="$(getdb passwd | awk -F: -vu=$REMOTE_USER '$1==u{print $6}')"
152 [ ! -d "$HOME" ] && exit 0
154 dd="$HOME/.local/share/desktop-directories"; sd="$dd/SliTazMenu.directory"
156 case "$REMOTE_USER" in
157 root) color='31'; ind='#';;
158 *) color='32'; ind='$';;
159 esac
161 case $(GET tweak) in
162 monochrome)
163 # PS1='\u@\h:\w\$ '
164 sed -i "s|^PS1=.*|PS1='\\\\u@\\\\h:\\\\w\\\\$ind '|" $HOME/.profile;;
165 colored)
166 # PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\$ '
167 sed -i "s|^PS1=.*|PS1='\\\\\\[\\\\e\[0;${color}m\\\\\\]\\\\u@\\\\h\\\\\\[\\\\e\\[0m\\\\\\]:\\\\\\[\\\\e\\[0;33m\\\\\\]\\\\w\\\\\\[\\\\e\\[0m\\\\\\]\\\\$ind '|" $HOME/.profile;;
168 slitaz-*)
169 lxpanel="$HOME/.config/lxpanel"
170 if [ ! -e "$lxpanel" ]; then
171 mkdir -p "$lxpanel"; cp /etc/lxpanel/default /etc/lxpanel/slitaz $lxpanel
172 fi
174 for panel in $(find $lxpanel -type f -iname panel); do
175 awk -vicon="/usr/share/pixmaps/$(GET tweak).png" '
176 BEGIN{ found = "0"; }
177 {
178 if ($1 == "Plugin") { found = "1"; }
180 if (found == "1" && $1 == "type") {
181 if ($3 == "menu") found = "2"; else found = "0";
182 }
184 if (found == "2" && $1 == "Plugin") { found = "0"; }
186 if (found == "2" && index($1, "image")) {
187 printf " image=%s\n", icon;
188 found = 0;
189 } else {
190 print;
191 }
192 }
193 ' $panel > $panel.new
194 mv -f $panel.new $panel
195 done
197 restart_lxpanel;;
198 menu-notext)
199 mkdir -p $dd
200 echo -e '[Desktop Entry]\nType=Directory\nName=' > $sd
201 restart_lxpanel;;
202 menu-text)
203 [ -f "$sd" ] && rm "$sd"
204 restart_lxpanel;;
205 esac
206 exit 0
207 ;;
210 *\ menuIcon\ *)
211 # return specified image (AJAX)
212 icon="/usr/share/pixmaps/$(GET menuIcon).png"
213 [ ! -r $icon ] && exit 0
214 header "Content-Type: image/png"; cat $icon; exit 0
215 ;;
216 esac
222 #
223 # Default xHTML content
224 #
226 header
228 case " $(GET) " in
229 *\ group*)
230 #
231 # Groups management
232 #
233 xhtml_header "$(_ 'Manage groups')"
234 check_root_tazpanel
236 cat <<EOT
237 <section id="groups">
238 <form class="wide">
239 <header>
240 <input type="hidden" name="groups"/>
241 <!-- $(_ 'Selection:') -->
242 <button name="do" value="delgroups" data-icon="@delete@">$(_ 'Delete group')</button>
243 </header>
245 <div class="scroll">
246 <table class="wide zebra scroll">
247 <thead>
248 <tr class="thead">
249 <td>$(_ 'Group')</td>
250 <td>$(_ 'Group ID')</td>
251 <td>$(_ 'Members')</td>
252 </tr>
253 </thead>
254 <tbody>
255 EOT
256 for group in $(getdb group | cut -d: -f1); do
257 IFS=':'
258 set -- $(getdb group | grep "^$group:")
259 unset IFS
260 cat <<EOT
261 <tr>
262 <td><input type="checkbox" name="group" value="$group" id="$group"/>
263 <label for="$group" data-icon="@group@">$group</label></td>
264 <td>$3</td>
265 <td>${4//,/, }</td>
266 </tr>
267 EOT
268 done
269 cat <<EOT
270 </tbody>
271 </table>
272 </div>
273 </form>
274 </section>
277 <section>
278 <header>$(_ 'Add a new group')</header>
279 <form class="wide">
280 <input type="hidden" name="groups"/>
281 <footer>$(_ 'Group name:') <input type="text" name="group"/>
282 <button type="submit" name="do" value="addgroup" data-icon="@add@">$(_ 'Create group')</button>
283 </footer>
284 </form>
285 </section>
288 <section>
289 <header>$(_ 'Manage group membership')</header>
290 <form class="wide">
291 <input type="hidden" name="groups"/>
292 <div>
293 $(_ 'Group name:') <select name="group">$(listdb group)</select>
294 $(_ 'User login:') <select name="member">$(listdb passwd)</select>
295 </div>
296 <footer>
297 <button name="do" value="addmember" data-icon="@add@">$(_ 'Add user')</button>
298 <button name="do" value="delmember" data-icon="@delete@">$(_ 'Remove user')</button>
299 </footer>
300 </form>
301 </section>
303 EOT
304 ;;
307 *\ user*)
308 #
309 # Users management
310 #
311 xhtml_header "$(_ 'Manage users')"
312 check_root_tazpanel
314 cat <<EOT
315 <section id="users">
316 <form class="wide">
317 <header>
318 <!--$(_ 'Selection:')-->
319 <button name="do" value="delusers" data-icon="@delete@">$(_ 'Delete user')</button>
320 <button name="do" value="lockusers" data-icon="@lock@" >$(_ 'Lock user' )</button>
321 <button name="do" value="unlockusers" data-icon="@unlock@">$(_ 'Unlock user')</button>
322 </header>
324 <table class="wide zebra center">
325 <thead>
326 <tr>
327 <td>$(_ 'Login')</td>
328 <td>$(_ 'User ID')</td>
329 <td>$(_ 'User Name')</td>
330 <td>$(_ 'Home')</td>
331 <td>$(_ 'Shell')</td>
332 </tr>
333 </thead>
334 </tbody>
335 EOT
336 for login in $(getdb passwd | cut -d: -f1); do
337 if [ -d "/home/$login" ]; then
338 blocked=''; usericon='@user@'
339 if getdb shadow | grep -qs "^$login:!"; then
340 blocked='class="color31"'
341 usericon='@lock@'
342 fi
343 IFS=':'
344 set -- $(getdb passwd | grep "^$login:")
345 unset IFS
346 cat <<EOT
347 <tr>
348 <td style="white-space: nowrap">
349 <input type="checkbox" name="user" value="$login" id="$login"/>
350 <label for="$login" data-icon="$usericon" $blocked>$login</label></td>
351 <td>$3:$4</td>
352 <td>$(echo $5 | sed s/,.*//)</td>
353 <td>$6</td>
354 <td>$7</td>
355 </tr>
356 EOT
357 fi
358 done
359 cat <<EOT
360 </tbody>
361 </table>
362 EOT
363 cat <<EOT
364 <footer>
365 $(_ 'Password:')
366 <input type="password" name="password" placeholder="$(_ 'New password')"/>
367 <button type="submit" name="do" value="chpasswd" data-icon="@ok@">$(_ 'Change password')</button>
368 </footer>
369 </form>
370 </section>
373 <section>
374 <header>$(_ 'Add a new user')</header>
376 <form>
377 <input type="hidden" name="users"/>
378 <table class="summary">
379 <tr><td>$(_ 'User login:')</td>
380 <td><input type="text" name="user" size="30" pattern="[a-z]*"/></td></tr>
381 <tr><td>$(_ 'User name:')</td>
382 <td><input type="text" name="name" size="30"/></td></tr>
383 <tr><td>$(_ 'User password:')</td>
384 <td><input type="password" name="passwd" size="30"/></td></tr>
385 </table>
387 <footer>
388 <button type="submit" name="do" value="adduser" data-icon="@add@">$(_ 'Create user')</button>
389 </footer>
390 </form>
391 </section>
392 EOT
394 # `who` output is empty in the SLiM sessions
395 if [ -n "$(who)" ]; then
396 cat <<EOT
397 <section>
398 <header>$(_ 'Current user sessions')</header>
399 <pre>$(who)</pre>
400 </section>
401 EOT
402 fi
404 # `last` output is empty (just header) in the Live mode
405 if [ "$(last | wc -l)" != "1" ]; then
406 cat <<EOT
407 <section>
408 <header>$(_ 'Last user sessions')</header>
409 <div class="scroll"><pre>$(last)</pre></div>
410 </section>
411 EOT
412 fi
413 ;;
416 *\ locale*)
417 #
418 # Choose locale
419 #
420 xhtml_header "$(_ 'Choose locale')"
421 check_root_tazpanel
423 loading_msg "$(_ 'Please wait...')"
425 cur_loc=$(locale | grep LANG | cut -d= -f2)
426 cat <<EOT
427 <section id="locale">
428 <header>$(_ 'Current locale settings:')</header>
429 <div>
430 <pre>$(locale)</pre>
431 </div>
432 </section>
434 <section>
435 <header>$(_ 'Locales that are currently installed on the machine:')</header>
436 <div>
437 <pre>$(locale -a)</pre>
438 </div>
439 </section>
440 EOT
442 is_installed "glibc-locale"
443 [ $? = 1 ] &&
444 msg tip $(_ \
445 "Can't see your language?<br/>You can \
446 <a href='pkgs.cgi?do=Install&glibc-locale'>install glibc-locale</a> \
447 to see a larger list of available locales.")
450 cat <<EOT
451 <section>
452 <header>$(_ 'Available locales:')</header>
453 <form class="wide">
454 <table class="wide zebra">
455 <thead>
456 <tr><td>$(_ 'Code')</td>
457 <td>$(_ 'Language')</td>
458 <td>$(_ 'Territory')</td>
459 <td>$(_ 'Description')</td>
460 </tr>
461 </thead>
462 <tbody>
463 EOT
464 for locale in $(find /usr/share/i18n/locales -type f | sort); do
465 locale_name=$(basename $locale)
466 locale_title=$(grep -m 1 -e '^ *title' $locale | cut -d'"' -f2)
467 if [ -n "$locale_title" ]; then
468 sel=''; [ "$locale_name" == "$cur_loc" ] && sel='checked="checked"'
469 cat <<EOT
470 <tr>
471 <td>
472 <input type="radio" name="gen_locale" value="$locale_name" $sel id="$locale_name"/>
473 <label for="$locale_name">$locale_name</label>
474 </td>
475 <td>$(gettext -d iso_639 "$(grep -m 1 -e '^ *language' $locale | cut -d '"' -f2)")</td>
476 <td>$(gettext -d iso_3166 "$(grep -m 1 -e '^ *territory' $locale | cut -d '"' -f2)")</td>
477 <td>$locale_title</td>
478 </tr>
479 EOT
480 fi
481 done
482 cat <<EOT
483 </tbody>
484 </table>
486 <footer>
487 <button type="submit" data-icon="@ok@">$(_ 'Activate')</button>
488 </footer>
489 </form>
490 </section>
491 EOT
492 ;;
495 *\ tweaks\ *)
496 #
497 # Small tweaks for user
498 #
499 user="$REMOTE_USER"; host="$(hostname)"
500 xhtml_header "$(_ 'Small quick tweaks for user %s' "$user")"
502 HOME="$(getdb passwd | awk -F: -vu=$user '$1==u{print $6}')"
503 font="${TERM_FONT:-monospace}"; palette=$(echo $TERM_PALETTE | tr A-Z a-z)
504 case $user in
505 root) color=31; ind="#";;
506 *) color=32; ind="$";;
507 esac
509 prompt_bw="$user@$host:/usr/bin$ind"
510 prompt_c="<span class=\"color$color\">$user@$host</span>:<span class=\"color33\">/usr/bin</span>$ind"
511 cursor="<span class=\"color47\">_</span>"
512 cat <<EOT
513 <script type="text/javascript">
514 function tweak(tweakName) {
515 // Send request to the server
516 var hiddenImg = document.createElement('IMG');
517 hiddenImg.src = "settings.cgi?tweak=" + tweakName;
518 }
519 </script>
521 <section>
522 <header>$(_ 'Small quick tweaks for user %s' "$user")</header>
524 <div>
525 <fieldset><legend>$(_ 'Terminal prompt')</legend>
526 <table class="wide">
527 <tr>
528 <td>
529 <label>
530 <input type="radio" name="termPrompt" onclick="tweak('monochrome')"/>
531 $(_ 'Monochrome')
532 </label>
533 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
534 $prompt_bw uname -r<br/>$(uname -r)<br/>$prompt_bw date<br/>$(date)<br/>$prompt_bw $cursor
535 </pre>
536 </td>
537 <td>
538 <label>
539 <input type="radio" name="termPrompt" onclick="tweak('colored')"/>
540 $(_ 'Colored')
541 </label>
542 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
543 $prompt_c uname -r<br/>$(uname -r)<br/>$prompt_c date<br/>$(date)<br/>$prompt_c $cursor
544 </pre>
545 </td>
546 </tr>
547 </table>
549 <p>$(_ 'Manual edit: %s' "<a data-icon=\"@conf@\" href="index.cgi?file=$HOME/.profile">~/.profile</a>")<br/>
550 $(_ 'To take effect: log out and log in to system or execute command in the terminal:')</p>
552 <pre>. ~/.profile</pre>
553 </fieldset>
555 <br/>
557 <fieldset>
558 <legend>$(_ 'Menu button appearance')</legend>
559 <table class="wide">
560 <tr>
561 <td style="vertical-align: top">
562 <fieldset>
563 <legend>$(_ 'Icon:')</legend>
564 <label>
565 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu-empty')"/>
566 $(_ 'Do not show')
567 </label><br/>
568 <label>
569 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button-red')"/>
570 <img src="?menuIcon=slitaz-button-red"/>
571 </label><br/>
572 <label>
573 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu')"/>
574 <img src="?menuIcon=slitaz-menu"/>
575 </label><br/>
576 <label>
577 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button')"/>
578 <img src="?menuIcon=slitaz-button"/>
579 </label>
580 </fieldset>
581 </td>
582 <td style="vertical-align: top">
583 <fieldset>
584 <legend>$(_ 'Text:')</legend>
585 <label>
586 <input type="radio" name="menuText" onclick="tweak('menu-notext')"/>
587 $(_ 'Do not show')
588 </label><br/>
589 <label>
590 <input type="radio" name="menuText" onclick="tweak('menu-text')"/>
591 $(_ 'Show text')
592 </label>
593 </fieldset>
594 </td>
595 </tr>
596 </table>
597 <p>$(_ 'Manual edit: %s' \
598 "<a data-icon=\"@conf@\" href=\"index.cgi?file=$HOME/.local/share/desktop-directories/SliTazMenu.directory\">~/.local/share/desktop-directories/SliTazMenu.directory</a>
599 $(
600 find $HOME/.config/lxpanel -type f -name panel | awk -vh="$HOME" \
601 '{ printf "<a data-icon=\"@conf@\" href=\"index.cgi?file=%s\">%s</a> ", $1, gensub(h, "~", "")}'
602 )")</p>
603 </fieldset>
604 </div>
605 </section>
606 EOT
607 ;;
610 *)
611 #
612 # Default system settings page
613 #
614 xhtml_header "$(_ 'Manage system time, users or language settings')"
615 check_root_tazpanel
617 cat <<EOT
618 <form><!--
619 --><button name="users" data-icon="@user@" >$(_ 'Manage users' )</button><!--
620 --><button name="groups" data-icon="@group@">$(_ 'Manage groups')</button>
621 </form>
623 <section>
624 <header>$(_ 'System time')</header>
625 <div>
626 <form class="wide" id="sysTimeForm">
627 <fieldset><legend>$(_ 'Time zone:')</legend>
628 <select name="tz">
629 $(cd /usr/share/zoneinfo; find * -type f ! -name '*.tab' | sort | \
630 awk -vtz="$(cat /etc/TZ)" \
631 '{printf("<option%s>%s</option>", ($1 == tz)?" selected":"", $1)}')
632 </select>
633 <button name="do" value="settz" data-icon="@ok@">$(_ 'Change')</button>
634 </fieldset>
636 <fieldset><legend>$(_ 'System time:')</legend>
637 $(date | sed 's|[0-9][0-9]:[0-9:]*|<span id="time">&</span>|')
638 <button name="do" value="rdate" data-icon="@sync@">$(_ 'Sync online')</button>
639 </fieldset>
641 <fieldset id="hwclock1"><legend>$(_ 'Hardware clock:')</legend>
642 <span id="hwclocks">$(hwclock -ur | sed 's|0.000000 seconds||')</span>
643 <button name="do" value="hwclock" id="hwclock" data-icon="@clock@">$(_ 'Set hardware clock')</button>
644 </fieldset>
646 <fieldset><legend>$(_ 'Set date')</legend>
647 EOT
648 if [ -z "$(which yad)" ]; then
649 cat <<EOT
650 <input type="number" name="day" value="$(date +%d)" min="1" max="31" size="4" required/>
651 <select name="month" value="$(date +%m)">
652 $(for i in $(seq 12); do
653 sel=''; [ "$i" == "$(date +%-m)" ] && sel=' selected'
654 printf "<option value=\"%s\"$sel>%s</option>" $(date -d $i.01-01:01 '+%m %B')
655 done)
656 </select>
657 <input type="number" name="year" value="$(date +%Y)" min="2015" max="2030" size="6" required/>
658 EOT
659 else
660 cat <<EOT
661 <button onclick="datePicker(); return false">
662 <span id="dateTime" data-icon="@calendar@">$(date +%x)<span style="display:none">$(date +%F)</span></span>
663 </button>
664 EOT
665 fi
666 cat <<EOT
667 - <input type="number" name="hour" value="$(date +%H)" min="0" max="23" size="4" required/><!--
668 -->:<input type="number" name="min" value="$(date +%M)" min="0" max="59" size="4" required/><!--
669 -->:<input type="number" name="sec" value="00" min="0" max="59" size="4" required/>
670 EOT
671 if [ -z "$(which yad)" ]; then
672 cat <<EOT
673 <button name="do" value="date" data-icon="@ok@">$(_ 'Set date')</button>
674 EOT
675 else
676 cat <<EOT
678 <button data-icon="@ok@" onclick="submitSysTimeForm()">$(_ 'Set date')</button>
679 EOT
680 fi
681 cat <<EOT
682 </fieldset>
683 </form>
684 </div>
686 <script type="text/javascript">
687 // Live time on page
688 Date.prototype.timeNow = function() {
689 return ((this.getHours() < 10)?"0":"") + this.getHours() + ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
690 }
691 setInterval(function(){
692 document.getElementById('time').textContent = new Date().timeNow();
693 //ajax('settings.cgi?do=gethwclock', '1', 'hwclocks');
694 }, 1000);
697 // Run date picker and return value to the 'dateTime' element
698 function datePicker() {
699 ajax('settings.cgi?do=calendar', '1', 'dateTime');
700 }
702 // Actions to do before form submit and submit
703 function submitSysTimeForm() {
704 sysTimeForm = document.getElementById('sysTimeForm');
706 var dateFull = document.createElement('INPUT');
707 dateFull.name = 'dateFull';
708 dateFull.value = document.getElementById('dateTime').childNodes[1].textContent;
709 dateFull.type = 'hidden';
710 sysTimeForm.appendChild(dateFull);
712 var submitDo = document.createElement('INPUT');
713 submitDo.name = 'do'; submitDo.value = 'date';
714 submitDo.type = 'hidden';
715 sysTimeForm.appendChild(submitDo);
717 sysTimeForm.submit();
718 }
719 </script>
720 </section>
721 EOT
724 #
725 # Locale settings
726 #
727 cat <<EOT
728 <section>
729 <header id="locale">$(_ 'System language')</header>
730 <div>
731 <form>
732 EOT
733 # Check if a new locale was requested
734 if [ -n "$new_locale" ]; then
735 rm -rf /usr/lib/locale/$new_locale
736 localedef -i $new_locale -c -f UTF-8 \
737 /usr/lib/locale/$new_locale
738 # System configuration
739 echo "LANG=$new_locale" > /etc/locale.conf
740 echo "LC_ALL=$new_locale" >> /etc/locale.conf
741 msg warn "$(_ \
742 'You must logout and login again to your current session to use %s locale.' $new_locale)"
743 else
744 cat <<EOT
745 $(_ 'Current system locale:')
746 <strong>$(locale | grep LANG | cut -d= -f2)</strong>
747 <button name="locale" data-icon="@locale@">$(_ 'Change')</button>
748 EOT
749 fi
750 cat <<EOT
751 </div>
752 </form>
753 </section>
756 <section>
757 <header id="keymap">$(_ 'Keyboard layout')</header>
758 <div>
759 EOT
760 # Check if a new keymap was requested
761 if [ -n "$new_keymap" ]; then
762 echo "$new_keymap" > /etc/keymap.conf
763 if [ -x /bin/loadkeys ]; then
764 loadkeys $new_keymap
765 else
766 loadkmap < /usr/share/kmap/$new_keymap.kmap
767 fi
768 fi
770 keymap=$(cat /etc/keymap.conf)
771 _ 'Current console keymap: %s' $keymap
772 if [ -n "$keymap" ]; then
773 case "$keymap" in
774 fr_CH*)
775 keymap="ch" ;;
776 ru)
777 keymap="us,ru" ;;
778 slovene)
779 keymap=si ;;
780 *)
781 keymap=${keymap%-lat*}
782 keymap=${keymap%-abnt2} ;;
783 esac
784 keyboard_config=/etc/X11/xorg.conf.d/40-Keyboard.conf
785 cat <<EOT
786 <form id="settings"></form>
787 <form id="index" action="index.cgi"></form>
788 <br/>
789 $(_ 'Suggested keymap for Xorg:') $keymap
790 <button form="settings" name="apply_xorg_kbd" value="$keymap" data-icon="@ok@">$(_ 'Activate')</button>
791 <button form="index" name="file" value="$keyboard_config" data-icon="@edit@">$(_ 'Edit')</button>
792 <input form="index" type="hidden" name="action" value="edit" />
793 <br/>
794 EOT
795 fi
796 cat <<EOT
797 <form>
798 $(_ 'Available keymaps:')
799 <select name="gen_keymap">
800 $(list_keymaps)
801 </select>
802 <button type="submit" data-icon="@ok@">$(_ 'Activate')</button>
803 </form>
804 </div>
805 </section>
808 <section>
809 <header>$(_ 'Panel configuration')</header>
810 <div>
811 <form class="wide">
812 <fieldset><legend>$(_ 'Style:')</legend>
813 <select name="style">$(list_styles)</select>
814 <button data-icon="@ok@">$(_ 'Activate')</button>
815 </fieldset>
816 </form>
818 <fieldset><legend>$(_ 'Configuration files:')</legend>
819 <button form="index" name="file" value="$CONFIG" data-icon="@edit@">$(_ 'Panel')</button>
820 <button form="index" name="file" value="$HTTPD_CONF" data-icon="@edit@">$(_ 'Server')</button>
821 </fieldset>
823 <p>$(_ 'TazPanel provides a debugging mode and page:')
824 <a href="index.cgi?debug">debug</a>
825 </p>
826 </div>
827 </section>
828 EOT
829 ;;
830 esac
832 xhtml_footer
833 exit 0