tazpanel view settings.cgi @ rev 538

Speed-up interface: cache xhtml header; need to use 'tazpanel cc' to clean cache when TazPanel menu changes (in post-install and post-remove functions for TazPanel modules)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Aug 30 23:46:37 2015 +0300 (2015-08-30)
parents aaf630cf6a8b
children 3c251737e46b
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) # display Yad date picker (AJAX)
98 new_date="$(DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' \
99 yad --calendar --on-top --mouse --undecorated \
100 --window-icon=config-date --title="$(_ 'Set date')" \
101 --date-format='%x<span style="display:none">%F</span>')"
102 header
103 echo "$new_date"; exit 0;;
105 settz) # set timezone
106 GET tz > /etc/TZ ;;
108 date) # only accepted format is MMDDhhmm[[YY]YY][.ss]
109 if [ -n "$(GET dateFull)" ]; then
110 dateFull="$(GET dateFull)" # %F = YYYY-MM-DD
111 date $(printf '%02d%02d%02d%02d%d.%02d' "${dateFull:5:2}" \
112 "${dateFull:8:2}" "$(GET hour)" "$(GET min)" \
113 "${dateFull:0:4}" "$(GET sec)") >/dev/null
114 else
115 date $(printf '%02d%02d%02d%02d%d.%02d' "$(GET month)" \
116 "$(GET day)" "$(GET hour)" "$(GET min)" "$(GET year)" \
117 "$(GET sec)") >/dev/null
118 fi;;
120 rdate) # get and possibly set the system date/time from a remote host
121 rdate -s tick.greyware.com ;;
123 hwclock) # query and set hardware clock (RTC)
124 hwclock -w -u ;;
126 gethwclock) # get date/time from hardware clock (AJAX)
127 header; hwclock -ur | sed 's|0.000000 seconds||'; exit 0;;
129 esac
130 ;;
133 *\ gen_locale\ *) new_locale=$(GET gen_locale) ;;
134 *\ gen_keymap\ *) new_keymap=$(GET gen_keymap) ;;
136 *\ apply_xorg_kbd\ *)
137 sed -i "s/XkbLayout.*/XkbLayout \" \"$(GET apply_xorg_kbd)\"/" \
138 /etc/X11/xorg.conf.d/40-Keyboard.conf ;;
139 *\ style*)
140 sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG
141 . $CONFIG ;;
144 *\ tweak\ *)
145 HOME="$(getdb passwd | awk -F: -vu=$REMOTE_USER '$1==u{print $6}')"
146 [ ! -d "$HOME" ] && exit 0
148 dd="$HOME/.local/share/desktop-directories"; sd="$dd/SliTazMenu.directory"
150 case "$REMOTE_USER" in
151 root) color='31'; ind='#';;
152 *) color='32'; ind='$';;
153 esac
155 case $(GET tweak) in
156 monochrome)
157 # PS1='\u@\h:\w\$ '
158 sed -i "s|^PS1=.*|PS1='\\\\u@\\\\h:\\\\w\\\\$ind '|" $HOME/.profile;;
159 colored)
160 # PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\$ '
161 sed -i "s|^PS1=.*|PS1='\\\\\\[\\\\e\[0;${color}m\\\\\\]\\\\u@\\\\h\\\\\\[\\\\e\\[0m\\\\\\]:\\\\\\[\\\\e\\[0;33m\\\\\\]\\\\w\\\\\\[\\\\e\\[0m\\\\\\]\\\\$ind '|" $HOME/.profile;;
162 slitaz-*)
163 lxpanel="$HOME/.config/lxpanel"
164 if [ ! -e "$lxpanel" ]; then
165 mkdir -p "$lxpanel"; cp /etc/lxpanel/default /etc/lxpanel/slitaz $lxpanel
166 fi
168 for panel in $(find $lxpanel -type f -iname panel); do
169 awk -vicon="/usr/share/pixmaps/$(GET tweak).png" '
170 BEGIN{ found = "0"; }
171 {
172 if ($1 == "Plugin") { found = "1"; }
174 if (found == "1" && $1 == "type") {
175 if ($3 == "menu") found = "2"; else found = "0";
176 }
178 if (found == "2" && $1 == "Plugin") { found = "0"; }
180 if (found == "2" && index($1, "image")) {
181 printf " image=%s\n", icon;
182 found = 0;
183 } else {
184 print;
185 }
186 }
187 ' $panel > $panel.new
188 mv -f $panel.new $panel
189 done
191 restart_lxpanel;;
192 menu-notext)
193 mkdir -p $dd
194 echo -e '[Desktop Entry]\nType=Directory\nName=' > $sd
195 restart_lxpanel;;
196 menu-text)
197 [ -f "$sd" ] && rm "$sd"
198 restart_lxpanel;;
199 esac
200 exit 0
201 ;;
204 *\ menuIcon\ *) # return specified image (AJAX)
205 icon="/usr/share/pixmaps/$(GET menuIcon).png"
206 [ ! -r $icon ] && exit 0
207 header "Content-Type: image/png"; cat $icon; exit 0
208 ;;
209 esac
215 #
216 # Default xHTML content
217 #
219 header
221 case " $(GET) " in
222 *\ group*)
223 #
224 # Groups management
225 #
226 xhtml_header "$(_ 'Manage groups')"
227 check_root_tazpanel
229 cat <<EOT
230 <section id="groups">
231 <form class="wide">
232 <header>
233 <input type="hidden" name="groups"/>
234 <!-- $(_ 'Selection:') -->
235 <button name="do" value="delgroups" data-icon="delete">$(_ 'Delete group')</button>
236 </header>
238 <div class="scroll">
239 <table class="wide zebra scroll">
240 <thead>
241 <tr class="thead">
242 <td>$(_ 'Group')</td>
243 <td>$(_ 'Group ID')</td>
244 <td>$(_ 'Members')</td>
245 </tr>
246 </thead>
247 <tbody>
248 EOT
249 for group in $(getdb group | cut -d: -f1); do
250 IFS=':'
251 set -- $(getdb group | grep "^$group:")
252 unset IFS
253 cat <<EOT
254 <tr>
255 <td><input type="checkbox" name="group" value="$group" id="$group"/>
256 <label for="$group" data-icon="group">$group</label></td>
257 <td>$3</td>
258 <td>${4//,/, }</td>
259 </tr>
260 EOT
261 done
262 cat <<EOT
263 </tbody>
264 </table>
265 </div>
266 </form>
267 </section>
270 <section>
271 <header>$(_ 'Add a new group')</header>
272 <form class="wide">
273 <input type="hidden" name="groups"/>
274 <footer>$(_ 'Group name:') <input type="text" name="group"/>
275 <button type="submit" name="do" value="addgroup" data-icon="add">$(_ 'Create group')</button>
276 </footer>
277 </form>
278 </section>
281 <section>
282 <header>$(_ 'Manage group membership')</header>
283 <form class="wide">
284 <input type="hidden" name="groups"/>
285 <div>
286 $(_ 'Group name:') <select name="group">$(listdb group)</select>
287 $(_ 'User name:') <select name="member">$(listdb passwd)</select>
288 </div>
289 <footer>
290 <button name="do" value="addmember" data-icon="add">$(_ 'Add user')</button>
291 <button name="do" value="delmember" data-icon="delete">$(_ 'Remove user')</button>
292 </footer>
293 </form>
294 </section>
296 EOT
297 ;;
300 *\ user*)
301 #
302 # Users management
303 #
304 xhtml_header "$(_ 'Manage users')"
305 check_root_tazpanel
307 cat <<EOT
308 <section id="users">
309 <form class="wide">
310 <header>
311 <!--$(_ 'Selection:')-->
312 <button name="do" value="delusers" data-icon="delete">$(_ 'Delete user')</button>
313 <button name="do" value="lockusers" data-icon="lock" >$(_ 'Lock user' )</button>
314 <button name="do" value="unlockusers" data-icon="unlock">$(_ 'Unlock user')</button>
315 </header>
317 <table class="wide zebra center">
318 <thead>
319 <tr>
320 <td>$(_ 'Login')</td>
321 <td>$(_ 'User ID')</td>
322 <td>$(_ 'User Name')</td>
323 <td>$(_ 'Home')</td>
324 <td>$(_ 'Shell')</td>
325 </tr>
326 </thead>
327 </tbody>
328 EOT
329 for login in $(getdb passwd | cut -d: -f1); do
330 if [ -d "/home/$login" ]; then
331 blocked=''; usericon='user'
332 if getdb shadow | grep -qs "^$login:!"; then
333 blocked='class="color31"'
334 usericon="lock"
335 fi
336 IFS=':'
337 set -- $(getdb passwd | grep "^$login:")
338 unset IFS
339 cat <<EOT
340 <tr>
341 <td style="white-space: nowrap">
342 <input type="checkbox" name="user" value="$login" id="$login"/>
343 <label for="$login" data-icon="$usericon" $blocked>$login</label></td>
344 <td>$3:$4</td>
345 <td>$(echo $5 | sed s/,.*//)</td>
346 <td>$6</td>
347 <td>$7</td>
348 </tr>
349 EOT
350 fi
351 done
352 cat <<EOT
353 </tbody>
354 </table>
355 EOT
356 cat <<EOT
357 <footer>
358 $(_ 'Password:')
359 <input type="password" name="password" placeholder="$(_ 'New password')"/>
360 <button type="submit" name="do" value="chpasswd" data-icon="ok">$(_ 'Change password')</button>
361 </footer>
362 </form>
363 </section>
366 <section>
367 <header>$(_ 'Add a new user')</header>
369 <form>
370 <input type="hidden" name="users"/>
371 <table class="summary">
372 <tr><td>$(_ 'User login:')</td>
373 <td><input type="text" name="user" size="30" pattern="[a-z]*"/></td></tr>
374 <tr><td>$(_ 'User name:')</td>
375 <td><input type="text" name="name" size="30"/></td></tr>
376 <tr><td>$(_ 'User password:')</td>
377 <td><input type="password" name="passwd" size="30"/></td></tr>
378 </table>
380 <footer>
381 <button type="submit" name="do" value="adduser" data-icon="add">$(_ 'Create user')</button>
382 </footer>
383 </form>
384 </section>
385 EOT
387 # `who` output is empty in the SLiM sessions
388 if [ -n "$(who)" ]; then
389 cat <<EOT
390 <section>
391 <header>$(_ 'Current user sessions')</header>
392 <pre>$(who)</pre>
393 </section>
394 EOT
395 fi
397 # `last` output is empty (just header) in the Live mode
398 if [ "$(last | wc -l)" != "1" ]; then
399 cat <<EOT
400 <section>
401 <header>$(_ 'Last user sessions')</header>
402 <div class="scroll"><pre>$(last)</pre></div>
403 </section>
404 EOT
405 fi
406 ;;
409 *\ locale*)
410 #
411 # Choose locale
412 #
413 xhtml_header "$(_ 'Choose locale')"
414 check_root_tazpanel
416 loading_msg "$(_ 'Please wait...')"
418 cur_loc=$(locale | grep LANG | cut -d= -f2)
419 cat <<EOT
420 <section id="locale">
421 <header>$(_ 'Current locale settings:')</header>
422 <div>
423 <pre>$(locale)</pre>
424 </div>
425 </section>
427 <section>
428 <header>$(_ 'Locales that are currently installed on the machine:')</header>
429 <div>
430 <pre>$(locale -a)</pre>
431 </div>
432 </section>
433 EOT
435 is_installed "glibc-locale"
436 [ $? = 1 ] &&
437 msg tip $(_ \
438 "Can't see your language?<br/>You can \
439 <a href='pkgs.cgi?do=Install&amp;glibc-locale'>install glibc-locale</a> \
440 to see a larger list of available locales.")
443 cat <<EOT
444 <section>
445 <header>$(_ 'Available locales:')</header>
446 <form class="wide">
447 <table class="wide zebra">
448 <thead>
449 <tr><td>$(_ 'Code')</td>
450 <td>$(_ 'Language')</td>
451 <td>$(_ 'Territory')</td>
452 <td>$(_ 'Description')</td>
453 </tr>
454 </thead>
455 <tbody>
456 EOT
457 for locale in $(find /usr/share/i18n/locales -type f | sort); do
458 locale_name=$(basename $locale)
459 locale_title=$(grep -m 1 -e '^ *title' $locale | cut -d'"' -f2)
460 if [ -n "$locale_title" ]; then
461 sel=''; [ "$locale_name" == "$cur_loc" ] && sel='checked="checked"'
462 cat <<EOT
463 <tr>
464 <td>
465 <input type="radio" name="gen_locale" value="$locale_name" $sel id="$locale_name"/>
466 <label for="$locale_name">$locale_name</label>
467 </td>
468 <td>$(gettext -d iso_639 "$(grep -m 1 -e '^ *language' $locale | cut -d '"' -f2)")</td>
469 <td>$(gettext -d iso_3166 "$(grep -m 1 -e '^ *territory' $locale | cut -d '"' -f2)")</td>
470 <td>$locale_title</td>
471 </tr>
472 EOT
473 fi
474 done
475 cat <<EOT
476 </tbody>
477 </table>
479 <footer>
480 <button type="submit" data-icon="ok">$(_ 'Activate')</button>
481 </footer>
482 </form>
483 </section>
484 EOT
485 ;;
488 *\ tweaks\ *)
489 #
490 # Small tweaks for user
491 #
492 user="$REMOTE_USER"; host="$(hostname)"
493 xhtml_header "$(_ 'Small quick tweaks for user %s' "$user")"
495 HOME="$(getdb passwd | awk -F: -vu=$user '$1==u{print $6}')"
496 font="${TERM_FONT:-monospace}"; palette=$(echo $TERM_PALETTE | tr A-Z a-z)
497 case $user in
498 root) color=31; ind="#";;
499 *) color=32; ind="$";;
500 esac
502 prompt_bw="$user@$host:/usr/bin$ind"
503 prompt_c="<span class=\"color$color\">$user@$host</span>:<span class=\"color33\">/usr/bin</span>$ind"
504 cursor="<span class=\"color47\">_</span>"
505 cat <<EOT
506 <script type="text/javascript">
507 function tweak(tweakName) {
508 // Send request to the server
509 var hiddenImg = document.createElement('IMG');
510 hiddenImg.src = "settings.cgi?tweak=" + tweakName;
511 }
512 </script>
514 <section>
515 <header>$(_ 'Small quick tweaks for user %s' "$user")</header>
517 <div>
518 <fieldset><legend>$(_ 'Terminal prompt')</legend>
519 <table class="wide">
520 <tr>
521 <td>
522 <label>
523 <input type="radio" name="termPrompt" onclick="tweak('monochrome')"/>
524 $(_ 'Monochrome')
525 </label>
526 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
527 $prompt_bw uname -r<br/>$(uname -r)<br/>$prompt_bw date<br/>$(date)<br/>$prompt_bw $cursor
528 </pre>
529 </td>
530 <td>
531 <label>
532 <input type="radio" name="termPrompt" onclick="tweak('colored')"/>
533 $(_ 'Colored')
534 </label>
535 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
536 $prompt_c uname -r<br/>$(uname -r)<br/>$prompt_c date<br/>$(date)<br/>$prompt_c $cursor
537 </pre>
538 </td>
539 </tr>
540 </table>
542 <p>$(_ 'Manual edit: %s' "<a data-icon=\"conf\" href="index.cgi?file=$HOME/.profile">~/.profile</a>")<br/>
543 $(_ 'To take effect: log out and log in to system or execute command in the terminal:')</p>
545 <pre>. ~/.profile</pre>
546 </fieldset>
548 <br/>
550 <fieldset>
551 <legend>$(_ 'Menu button appearance')</legend>
552 <table class="wide">
553 <tr>
554 <td style="vertical-align: top">
555 <fieldset>
556 <legend>$(_ 'Icon:')</legend>
557 <label>
558 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu-empty')"/>
559 $(_ 'Do not show')
560 </label><br/>
561 <label>
562 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button-red')"/>
563 <img src="?menuIcon=slitaz-button-red"/>
564 </label><br/>
565 <label>
566 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu')"/>
567 <img src="?menuIcon=slitaz-menu"/>
568 </label><br/>
569 <label>
570 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button')"/>
571 <img src="?menuIcon=slitaz-button"/>
572 </label>
573 </fieldset>
574 </td>
575 <td style="vertical-align: top">
576 <fieldset>
577 <legend>$(_ 'Text:')</legend>
578 <label>
579 <input type="radio" name="menuText" onclick="tweak('menu-notext')"/>
580 $(_ 'Do not show')
581 </label><br/>
582 <label>
583 <input type="radio" name="menuText" onclick="tweak('menu-text')"/>
584 $(_ 'Show text')
585 </label>
586 </fieldset>
587 </td>
588 </tr>
589 </table>
590 <p>$(_ 'Manual edit: %s' \
591 "<a data-icon=\"conf\" href=\"index.cgi?file=$HOME/.local/share/desktop-directories/SliTazMenu.directory\">~/.local/share/desktop-directories/SliTazMenu.directory</a>
592 $(
593 find $HOME/.config/lxpanel -type f -name panel | awk -vh="$HOME" \
594 '{ printf "<a data-icon=\"conf\" href=\"index.cgi?file=%s\">%s</a> ", $1, gensub(h, "~", "")}'
595 )")</p>
596 </fieldset>
597 </div>
598 </section>
599 EOT
600 ;;
603 *)
604 #
605 # Default system settings page
606 #
607 xhtml_header "$(_ 'Manage system time, users or language settings')"
608 check_root_tazpanel
610 cat <<EOT
611 <form><!--
612 --><button name="users" data-icon="user" >$(_ 'Manage users' )</button><!--
613 --><button name="groups" data-icon="group">$(_ 'Manage groups')</button>
614 </form>
616 <section>
617 <header>$(_ 'System time')</header>
618 <div>
619 <form class="wide" id="sysTimeForm">
620 <fieldset><legend>$(_ 'Time zone:')</legend>
621 <select name="tz">
622 $(cd /usr/share/zoneinfo; find * -type f ! -name '*.tab' | sort | \
623 awk -vtz="$(cat /etc/TZ)" \
624 '{printf("<option%s>%s</option>", ($1 == tz)?" selected":"", $1)}')
625 </select>
626 <button name="do" value="settz" data-icon="ok">$(_ 'Change')</button>
627 </fieldset>
629 <fieldset><legend>$(_ 'System time:')</legend>
630 $(date | sed 's|[0-9][0-9]:[0-9:]*|<span id="time">&</span>|')
631 <button name="do" value="rdate" data-icon="sync">$(_ 'Sync online')</button>
632 </fieldset>
634 <fieldset id="hwclock1"><legend>$(_ 'Hardware clock:')</legend>
635 <span id="hwclocks">$(hwclock -ur | sed 's|0.000000 seconds||')</span>
636 <button name="do" value="hwclock" id="hwclock" data-icon="clock">$(_ 'Set hardware clock')</button>
637 </fieldset>
639 <fieldset><legend>$(_ 'Set date')</legend>
640 EOT
641 if [ -z "$(which yad)" ]; then
642 cat <<EOT
643 <input type="number" name="day" value="$(date +%d)" min="1" max="31" size="4" required/>
644 <select name="month" value="$(date +%m)">
645 $(for i in $(seq 12); do
646 sel=''; [ "$i" == "$(date +%-m)" ] && sel=' selected'
647 printf "<option value=\"%s\"$sel>%s</option>" $(date -d $i.01-01:01 '+%m %B')
648 done)
649 </select>
650 <input type="number" name="year" value="$(date +%Y)" min="2015" max="2030" size="6" required/>
651 EOT
652 else
653 cat <<EOT
654 <button onclick="datePicker(); return false">
655 <span id="dateTime" data-icon="calendar">$(date +%x)<span style="display:none">$(date +%F)</span></span>
656 </button>
657 EOT
658 fi
659 cat <<EOT
660 - <input type="number" name="hour" value="$(date +%H)" min="0" max="23" size="4" required/><!--
661 -->:<input type="number" name="min" value="$(date +%M)" min="0" max="59" size="4" required/><!--
662 -->:<input type="number" name="sec" value="00" min="0" max="59" size="4" required/>
663 EOT
664 if [ -z "$(which yad)" ]; then
665 cat <<EOT
666 <button name="do" value="date" data-icon="ok">$(_ 'Set date')</button>
667 EOT
668 else
669 cat <<EOT
671 <button data-icon="ok" onclick="submitSysTimeForm()">$(_ 'Set date')</button>
672 EOT
673 fi
674 cat <<EOT
675 </fieldset>
676 </form>
677 </div>
679 <script type="text/javascript">
680 // Live time on page
681 Date.prototype.timeNow = function() {
682 return ((this.getHours() < 10)?"0":"") + this.getHours() + ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
683 }
684 setInterval(function(){
685 document.getElementById('time').innerText = new Date().timeNow();
686 //ajax('settings.cgi?do=gethwclock', '1', 'hwclocks');
687 }, 1000);
690 // Run date picker and return value to the 'dateTime' element
691 function datePicker() {
692 ajax('settings.cgi?do=calendar', '1', 'dateTime');
693 }
695 // Actions to do before form submit and submit
696 function submitSysTimeForm() {
697 sysTimeForm = document.getElementById('sysTimeForm');
699 var dateFull = document.createElement('INPUT');
700 dateFull.name = 'dateFull';
701 dateFull.value = document.getElementById('dateTime').childNodes[1].innerText;
702 dateFull.type = 'hidden';
703 sysTimeForm.appendChild(dateFull);
705 var submitDo = document.createElement('INPUT');
706 submitDo.name = 'do'; submitDo.value = 'date';
707 submitDo.type = 'hidden';
708 sysTimeForm.appendChild(submitDo);
710 sysTimeForm.submit();
711 }
712 </script>
713 </section>
714 EOT
717 #
718 # Locale settings
719 #
720 cat <<EOT
721 <section>
722 <header id="locale">$(_ 'System language')</header>
723 <div>
724 <form>
725 EOT
726 # Check if a new locale was requested
727 if [ -n "$new_locale" ]; then
728 rm -rf /usr/lib/locale/$new_locale
729 localedef -i $new_locale -c -f UTF-8 \
730 /usr/lib/locale/$new_locale
731 # System configuration
732 echo "LANG=$new_locale" > /etc/locale.conf
733 echo "LC_ALL=$new_locale" >> /etc/locale.conf
734 msg warn "$(_ \
735 'You must logout and login again to your current session to use %s locale.' $new_locale)"
736 else
737 cat <<EOT
738 $(_ 'Current system locale:')
739 <strong>$(locale | grep LANG | cut -d= -f2)</strong>
740 <button name="locale" data-icon="locale">$(_ 'Change')</button>
741 EOT
742 fi
743 cat <<EOT
744 </div>
745 </form>
746 </section>
749 <section>
750 <header id="keymap">$(_ 'Keyboard layout')</header>
751 <div>
752 EOT
753 # Check if a new keymap was requested
754 if [ -n "$new_keymap" ]; then
755 echo "$new_keymap" > /etc/keymap.conf
756 if [ -x /bin/loadkeys ]; then
757 loadkeys $new_keymap
758 else
759 loadkmap < /usr/share/kmap/$new_keymap.kmap
760 fi
761 fi
763 keymap=$(cat /etc/keymap.conf)
764 _ 'Current console keymap: %s' $keymap
765 if [ -n "$keymap" ]; then
766 case "$keymap" in
767 fr_CH*)
768 keymap="ch" ;;
769 ru)
770 keymap="us,ru" ;;
771 slovene)
772 keymap=si ;;
773 *)
774 keymap=${keymap%-lat*}
775 keymap=${keymap%-abnt2} ;;
776 esac
777 keyboard_config=/etc/X11/xorg.conf.d/40-Keyboard.conf
778 cat <<EOT
779 <form id="settings"></form>
780 <form id="index" action="index.cgi"></form>
781 <br/>
782 $(_ 'Suggested keymap for Xorg:') $keymap
783 <button form="settings" name="apply_xorg_kbd" value="$keymap" data-icon="ok">$(_ 'Activate')</button>
784 <button form="index" name="file" value="$keyboard_config" data-icon="edit">$(_ 'Edit')</button>
785 <input form="index" type="hidden" name="action" value="edit" />
786 <br/>
787 EOT
788 fi
789 cat <<EOT
790 <form>
791 $(_ 'Available keymaps:')
792 <select name="gen_keymap">
793 $(list_keymaps)
794 </select>
795 <button type="submit" data-icon="ok">$(_ 'Activate')</button>
796 </form>
797 </div>
798 </section>
801 <section>
802 <header>$(_ 'Panel configuration')</header>
803 <div>
804 <form class="wide">
805 <fieldset><legend>$(_ 'Style:')</legend>
806 <select name="style">$(list_styles)</select>
807 <button data-icon="ok">$(_ 'Activate')</button>
808 </fieldset>
809 </form>
811 <fieldset><legend>$(_ 'Configuration files:')</legend>
812 <button form="index" name="file" value="$CONFIG" data-icon="edit">$(_ 'Panel')</button>
813 <button form="index" name="file" value="$HTTPD_CONF" data-icon="edit">$(_ 'Server')</button>
814 </fieldset>
816 <p>$(_ 'TazPanel provides a debugging mode and page:')
817 <a href="index.cgi?debug">debug</a>
818 </p>
819 </div>
820 </section>
821 EOT
822 ;;
823 esac
825 xhtml_footer
826 exit 0