tazpanel view settings.cgi @ rev 506
boot.cgi: typo
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jul 12 13:51:30 2015 +0200 (2015-07-12) |
parents | 3117717c007d |
children | 0e464ccf165e |
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 # Get system database. LDAP compatible.
21 getdb() {
22 getent $1 2>/dev/null || cat /etc/$1
23 }
26 listdb() {
27 for item in $(getdb $1 | cut -d: -f1); do
28 echo "<option>$item</option>\n"
29 done
30 }
33 restart_lxpanel() {
34 # `lxpanelctl restart` exists, but it breaks often leaving us without any panel
35 lxpanel_pid="$(ps -o comm,pid | fgrep lxpanel | awk '{print $2}')"
36 lxpanel_user="$(ps -o comm,user | fgrep lxpanel | awk '{print $2}')"
37 lxpanel_comm="$(ps -o pid,args | grep -e "^\ *$lxpanel_pid " | awk '{$1="";print}')"
39 if [ "$USER" == "$lxpanel_user" ]; then
40 kill $lxpanel_pid
41 DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' $lxpanel_comm &
42 fi
43 }
47 #
48 # Commands executed before page loading.
49 #
51 case " $(GET) " in
52 *\ do\ *)
53 users=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="user") print $2}')
54 groups=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="group")print $2}')
56 case $(GET do) in
58 # Groups page
59 delgroups) for i in $groups; do delgroup $i; done ;;
60 addgroup) addgroup $groups ;;
61 addmember) addgroup $(GET member) $groups ;;
62 delmember) delgroup $(GET member) $groups ;;
64 # Users page
65 delusers) for i in $users; do deluser $i; done ;;
66 lockusers) for i in $users; do passwd -l $i | log; done ;;
67 unlockusers) for i in $users; do passwd -u $i | log; done ;;
68 chpasswd) echo "$users:$(GET password)" | chpasswd -m | log ;;
69 adduser)
70 if [ -n "$users" ]; then
71 name="$(GET name)"
72 adduser -D -s /bin/sh -g "${name:-SliTaz User}" -G users -h /home/$users $users
73 echo "$user:$(GET passwd)" | chpasswd -m | log
74 for i in audio cdrom floppy video tty; do addgroup $users $i; done
75 passwd -u $users | log
76 fi ;;
78 # System time
79 calendar) # display Yad date picker (AJAX)
80 new_date="$(DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' \
81 yad --calendar --on-top --mouse --undecorated \
82 --window-icon=config-date --title="$(_ 'Set date')" \
83 --date-format='%x<span style="display:none">%F</span>')"
84 header
85 echo "$new_date"; exit 0;;
87 settz) # set timezone
88 GET tz > /etc/TZ ;;
90 date) # only accepted format is MMDDhhmm[[YY]YY][.ss]
91 if [ -n "$(GET dateFull)" ]; then
92 dateFull="$(GET dateFull)" # %F = YYYY-MM-DD
93 date $(printf '%02d%02d%02d%02d%d.%02d' "${dateFull:5:2}" \
94 "${dateFull:8:2}" "$(GET hour)" "$(GET min)" \
95 "${dateFull:0:4}" "$(GET sec)") >/dev/null
96 else
97 date $(printf '%02d%02d%02d%02d%d.%02d' "$(GET month)" \
98 "$(GET day)" "$(GET hour)" "$(GET min)" "$(GET year)" \
99 "$(GET sec)") >/dev/null
100 fi;;
102 rdate) # get and possibly set the system date/time from a remote host
103 rdate -s tick.greyware.com ;;
105 hwclock) # query and set hardware clock (RTC)
106 hwclock -w -u ;;
108 gethwclock) # get date/time from hardware clock (AJAX)
109 header; hwclock -ur | sed 's|0.000000 seconds||'; exit 0;;
111 esac
112 ;;
115 *\ gen_locale\ *) new_locale=$(GET gen_locale) ;;
116 *\ gen_keymap\ *) new_keymap=$(GET gen_keymap) ;;
118 *\ apply_xorg_kbd\ *)
119 sed -i "s/XkbLayout.*/XkbLayout \" \"$(GET apply_xorg_kbd)\"/" \
120 /etc/X11/xorg.conf.d/40-Keyboard.conf ;;
121 *\ style*)
122 sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG
123 . $CONFIG ;;
126 *\ tweak\ *)
127 HOME="$(awk -F: -vu=$REMOTE_USER '$1==u{print $6}' /etc/passwd)"
128 [ -z "$HOME" ] && exit 0
130 dd="$HOME/.local/share/desktop-directories"; sd="$dd/SliTazMenu.directory"
132 case "$REMOTE_USER" in
133 root) color='31'; ind='#';;
134 *) color='32'; ind='$';;
135 esac
137 case $(GET tweak) in
138 monochrome)
139 # PS1='\u@\h:\w\$ '
140 sed -i "s|^PS1=.*|PS1='\\\\u@\\\\h:\\\\w\\\\$ind '|" $HOME/.profile;;
141 colored)
142 # PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\$ '
143 sed -i "s|^PS1=.*|PS1='\\\\\\[\\\\e\[0;${color}m\\\\\\]\\\\u@\\\\h\\\\\\[\\\\e\\[0m\\\\\\]:\\\\\\[\\\\e\\[0;33m\\\\\\]\\\\w\\\\\\[\\\\e\\[0m\\\\\\]\\\\$ind '|" $HOME/.profile;;
144 slitaz-*)
145 lxpanel="$HOME/.config/lxpanel"
146 if [ ! -e "$lxpanel" ]; then
147 mkdir -p "$lxpanel"; cp /etc/lxpanel/default /etc/lxpanel/slitaz $lxpanel
148 fi
150 for panel in $(find $lxpanel -type f -iname panel); do
151 awk -vicon="/usr/share/pixmaps/$(GET tweak).png" '
152 BEGIN{ found = "0"; }
153 {
154 if ($1 == "Plugin") { found = "1"; }
156 if (found == "1" && $1 == "type") {
157 if ($3 == "menu") found = "2"; else found = "0";
158 }
160 if (found == "2" && $1 == "Plugin") { found = "0"; }
162 if (found == "2" && index($1, "image")) {
163 printf " image=%s\n", icon;
164 found = 0;
165 } else {
166 print;
167 }
168 }
169 ' $panel > $panel.new
170 mv -f $panel.new $panel
171 done
173 restart_lxpanel;;
174 menu-notext)
175 mkdir -p $dd
176 echo -e '[Desktop Entry]\nType=Directory\nName=' > $sd
177 restart_lxpanel;;
178 menu-text)
179 [ -f "$sd" ] && rm "$sd"
180 restart_lxpanel;;
181 esac
182 exit 0
183 ;;
186 *\ menuIcon\ *) # return specified image (AJAX)
187 icon="/usr/share/pixmaps/$(GET menuIcon).png"
188 [ ! -r $icon ] && exit 0
189 header "Content-Type: image/png"; cat $icon; exit 0
190 ;;
191 esac
197 #
198 # Default xHTML content
199 #
201 header
203 case " $(GET) " in
204 *\ group*)
205 #
206 # Groups management
207 #
208 xhtml_header "$(_ 'Manage groups')"
209 check_root_tazpanel
211 cat <<EOT
212 <section id="groups">
213 <form class="wide">
214 <header>
215 <input type="hidden" name="groups"/>
216 <!-- $(_ 'Selection:') -->
217 <button name="do" value="delgroups" data-icon="delete">$(_ 'Delete group')</button>
218 </header>
220 <div class="scroll">
221 <table class="wide zebra scroll">
222 <thead>
223 <tr class="thead">
224 <td>$(_ 'Group')</td>
225 <td>$(_ 'Group ID')</td>
226 <td>$(_ 'Members')</td>
227 </tr>
228 </thead>
229 <tbody>
230 EOT
231 for group in $(getdb group | cut -d: -f1); do
232 IFS=':'
233 set -- $(getdb group | grep "^$group:")
234 unset IFS
235 cat <<EOT
236 <tr>
237 <td><input type="checkbox" name="group" value="$group" id="$group"/>
238 <label for="$group" data-icon="group">$group</label></td>
239 <td>$3</td>
240 <td>${4//,/, }</td>
241 </tr>
242 EOT
243 done
244 cat <<EOT
245 </tbody>
246 </table>
247 </div>
248 </form>
249 </section>
252 <section>
253 <header>$(_ 'Add a new group')</header>
254 <form class="wide">
255 <input type="hidden" name="groups"/>
256 <footer>$(_ 'Group name:') <input type="text" name="group"/>
257 <button type="submit" name="do" value="addgroup" data-icon="add">$(_ 'Create group')</button>
258 </footer>
259 </form>
260 </section>
263 <section>
264 <header>$(_ 'Manage group membership')</header>
265 <form class="wide">
266 <input type="hidden" name="groups"/>
267 <div>
268 $(_ 'Group name:') <select name="group">$(listdb group)</select>
269 $(_ 'User name:') <select name="member">$(listdb passwd)</select>
270 </div>
271 <footer>
272 <button name="do" value="addmember" data-icon="add">$(_ 'Add user')</button>
273 <button name="do" value="delmember" data-icon="delete">$(_ 'Remove user')</button>
274 </footer>
275 </form>
276 </section>
278 EOT
279 ;;
282 *\ user*)
283 #
284 # Users management
285 #
286 xhtml_header "$(_ 'Manage users')"
287 check_root_tazpanel
289 cat <<EOT
290 <section id="users">
291 <form class="wide">
292 <header>
293 <!--$(_ 'Selection:')-->
294 <button name="do" value="delusers" data-icon="delete">$(_ 'Delete user')</button>
295 <button name="do" value="lockusers" data-icon="lock" >$(_ 'Lock user' )</button>
296 <button name="do" value="unlockusers" data-icon="unlock">$(_ 'Unlock user')</button>
297 </header>
299 <table class="wide zebra center">
300 <thead>
301 <tr>
302 <td>$(_ 'Login')</td>
303 <td>$(_ 'User ID')</td>
304 <td>$(_ 'User Name')</td>
305 <td>$(_ 'Home')</td>
306 <td>$(_ 'Shell')</td>
307 </tr>
308 </thead>
309 </tbody>
310 EOT
311 for login in $(getdb passwd | cut -d: -f1); do
312 if [ -d "/home/$login" ]; then
313 blocked=''; usericon='user'
314 if grep -qs "^$login:!" /etc/shadow; then
315 blocked='class="color31"'
316 usericon="lock"
317 fi
318 IFS=':'
319 set -- $(getdb passwd | grep "^$login:")
320 unset IFS
321 cat <<EOT
322 <tr>
323 <td style="white-space: nowrap">
324 <input type="checkbox" name="user" value="$login" id="$login"/>
325 <label for="$login" data-icon="$usericon" $blocked>$login</label></td>
326 <td>$3:$4</td>
327 <td>$(echo $5 | sed s/,.*//)</td>
328 <td>$6</td>
329 <td>$7</td>
330 </tr>
331 EOT
332 fi
333 done
334 cat <<EOT
335 </tbody>
336 </table>
337 EOT
338 cat <<EOT
339 <footer>
340 $(_ 'Password:')
341 <input type="password" name="password"/>
342 <button type="submit" name="do" value="chpasswd" data-icon="ok">$(_ 'Change password')</button>
343 </footer>
344 </form>
345 </section>
348 <section>
349 <header>$(_ 'Add a new user')</header>
351 <form>
352 <input type="hidden" name="users"/>
353 <table class="summary">
354 <tr><td>$(_ 'User login:')</td>
355 <td><input type="text" name="user" size="30" pattern="[a-z]*"/></td></tr>
356 <tr><td>$(_ 'User name:')</td>
357 <td><input type="text" name="name" size="30"/></td></tr>
358 <tr><td>$(_ 'User password:')</td>
359 <td><input type="password" name="passwd" size="30"/></td></tr>
360 </table>
362 <footer>
363 <button type="submit" name="do" value="adduser" data-icon="add">$(_ 'Create user')</button>
364 </footer>
365 </form>
366 </section>
367 EOT
369 # `who` output is empty in the SLiM sessions
370 if [ -n "$(who)" ]; then
371 cat <<EOT
372 <section>
373 <header>$(_ 'Current user sessions')</header>
374 <pre>$(who)</pre>
375 </section>
376 EOT
377 fi
379 # `last` output is empty (just header) in the Live mode
380 if [ "$(last | wc -l)" != "1" ]; then
381 cat <<EOT
382 <section>
383 <header>$(_ 'Last user sessions')</header>
384 <div class="scroll"><pre>$(last)</pre></div>
385 </section>
386 EOT
387 fi
388 ;;
391 *\ locale*)
392 #
393 # Choose locale
394 #
395 xhtml_header "$(_ 'Choose locale')"
396 check_root_tazpanel
398 loading_msg "$(_ 'Please wait...')"
400 cur_loc=$(locale | grep LANG | cut -d= -f2)
401 cat <<EOT
402 <section id="locale">
403 <header>$(_ 'Current locale settings:')</header>
404 <div>
405 <pre>$(locale)</pre>
406 </div>
407 </section>
409 <section>
410 <header>$(_ 'Locales that are currently installed on the machine:')</header>
411 <div>
412 <pre>$(locale -a)</pre>
413 </div>
414 </section>
415 EOT
417 is_installed "glibc-locale"
418 [ $? = 1 ] &&
419 msg tip $(_ \
420 "Can't see your language?<br/>You can \
421 <a href='pkgs.cgi?do=Install&glibc-locale'>install glibc-locale</a> \
422 to see a larger list of available locales.")
425 cat <<EOT
426 <section>
427 <header>$(_ 'Available locales:')</header>
428 <form class="wide">
429 <table class="wide zebra">
430 <thead>
431 <tr><td>$(_ 'Code')</td>
432 <td>$(_ 'Language')</td>
433 <td>$(_ 'Territory')</td>
434 <td>$(_ 'Description')</td>
435 </tr>
436 </thead>
437 <tbody>
438 EOT
439 for locale in $(find /usr/share/i18n/locales -type f | sort); do
440 locale_name=$(basename $locale)
441 locale_title=$(grep -m 1 -e '^ *title' $locale | cut -d'"' -f2)
442 if [ -n "$locale_title" ]; then
443 sel=''; [ "$locale_name" == "$cur_loc" ] && sel='checked="checked"'
444 cat <<EOT
445 <tr>
446 <td>
447 <input type="radio" name="gen_locale" value="$locale_name" $sel id="$locale_name"/>
448 <label for="$locale_name">$locale_name</label>
449 </td>
450 <td>$(gettext -d iso_639 "$(grep -m 1 -e '^ *language' $locale | cut -d '"' -f2)")</td>
451 <td>$(gettext -d iso_3166 "$(grep -m 1 -e '^ *territory' $locale | cut -d '"' -f2)")</td>
452 <td>$locale_title</td>
453 </tr>
454 EOT
455 fi
456 done
457 cat <<EOT
458 </tbody>
459 </table>
461 <footer>
462 <button type="submit" data-icon="ok">$(_ 'Activate')</button>
463 </footer>
464 </form>
465 </section>
466 EOT
467 ;;
470 *\ tweaks\ *)
471 #
472 # Small tweaks for user
473 #
474 user="$REMOTE_USER"; host="$(hostname)"
475 xhtml_header "$(_ 'Small quick tweaks for user %s' "$user")"
477 HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)"
478 font="${TERM_FONT:-monospace}"; palette=$(echo $TERM_PALETTE | tr A-Z a-z)
479 case $user in
480 root) color=31; ind="#";;
481 *) color=32; ind="$";;
482 esac
484 prompt_bw="$user@$host:/usr/bin$ind"
485 prompt_c="<span class=\"color$color\">$user@$host</span>:<span class=\"color33\">/usr/bin</span>$ind"
486 cursor="<span class=\"color47\">_</span>"
487 cat <<EOT
488 <script type="text/javascript">
489 function tweak(tweakName) {
490 // Send request to the server
491 var hiddenImg = document.createElement('IMG');
492 hiddenImg.src = "settings.cgi?tweak=" + tweakName;
493 }
494 </script>
496 <section>
497 <header>$(_ 'Small quick tweaks for user %s' "$user")</header>
499 <div>
500 <fieldset><legend>$(_ 'Terminal prompt')</legend>
501 <table class="wide">
502 <tr>
503 <td>
504 <label>
505 <input type="radio" name="termPrompt" onclick="tweak('monochrome')"/>
506 $(_ 'Monochrome')
507 </label>
508 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
509 $prompt_bw uname -r<br/>$(uname -r)<br/>$prompt_bw date<br/>$(date)<br/>$prompt_bw $cursor
510 </pre>
511 </td>
512 <td>
513 <label>
514 <input type="radio" name="termPrompt" onclick="tweak('colored')"/>
515 $(_ 'Colored')
516 </label>
517 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
518 $prompt_c uname -r<br/>$(uname -r)<br/>$prompt_c date<br/>$(date)<br/>$prompt_c $cursor
519 </pre>
520 </td>
521 </tr>
522 </table>
524 <p>$(_ 'Manual edit: %s' "<a data-icon=\"conf\" href="index.cgi?file=$HOME/.profile">~/.profile</a>")<br/>
525 $(_ 'To take effect: log out and log in to system or execute command in the terminal:')</p>
527 <pre>. ~/.profile</pre>
528 </fieldset>
530 <br/>
532 <fieldset>
533 <legend>$(_ 'Menu button appearance')</legend>
534 <table class="wide">
535 <tr>
536 <td style="vertical-align: top">
537 <fieldset>
538 <legend>$(_ 'Icon:')</legend>
539 <label>
540 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu-empty')"/>
541 $(_ 'Do not show')
542 </label><br/>
543 <label>
544 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button-red')"/>
545 <img src="?menuIcon=slitaz-button-red"/>
546 </label><br/>
547 <label>
548 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu')"/>
549 <img src="?menuIcon=slitaz-menu"/>
550 </label><br/>
551 <label>
552 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button')"/>
553 <img src="?menuIcon=slitaz-button"/>
554 </label>
555 </fieldset>
556 </td>
557 <td style="vertical-align: top">
558 <fieldset>
559 <legend>$(_ 'Text:')</legend>
560 <label>
561 <input type="radio" name="menuText" onclick="tweak('menu-notext')"/>
562 $(_ 'Do not show')
563 </label><br/>
564 <label>
565 <input type="radio" name="menuText" onclick="tweak('menu-text')"/>
566 $(_ 'Show text')
567 </label>
568 </fieldset>
569 </td>
570 </tr>
571 </table>
572 <p>$(_ 'Manual edit: %s' \
573 "<a data-icon=\"conf\" href=\"index.cgi?file=$HOME/.local/share/desktop-directories/SliTazMenu.directory\">~/.local/share/desktop-directories/SliTazMenu.directory</a>
574 $(
575 find $HOME/.config/lxpanel -type f -name panel | awk -vh="$HOME" \
576 '{ printf "<a data-icon=\"conf\" href=\"index.cgi?file=%s\">%s</a> ", $1, gensub(h, "~", "")}'
577 )")</p>
578 </fieldset>
579 </div>
580 </section>
581 EOT
582 ;;
585 *)
586 #
587 # Default system settings page
588 #
589 xhtml_header "$(_ 'Manage system time, users or language settings')"
590 check_root_tazpanel
592 cat <<EOT
593 <form><!--
594 --><button name="users" data-icon="user" >$(_ 'Manage users' )</button><!--
595 --><button name="groups" data-icon="group">$(_ 'Manage groups')</button>
596 </form>
598 <section>
599 <header>$(_ 'System time')</header>
600 <div>
601 <form class="wide" id="sysTimeForm">
602 <fieldset><legend>$(_ 'Time zone:')</legend>
603 <select name="tz">
604 $(cd /usr/share/zoneinfo; find * -type f ! -name '*.tab' | sort | \
605 awk -vtz="$(cat /etc/TZ)" \
606 '{printf("<option%s>%s</option>", ($1 == tz)?" selected":"", $1)}')
607 </select>
608 <button name="do" value="settz" data-icon="ok">$(_ 'Change')</button>
609 </fieldset>
611 <fieldset><legend>$(_ 'System time:')</legend>
612 $(date | sed 's|[0-9][0-9]:[0-9:]*|<span id="time">&</span>|')
613 <button name="do" value="rdate" data-icon="sync">$(_ 'Sync online')</button>
614 </fieldset>
616 <fieldset id="hwclock1"><legend>$(_ 'Hardware clock:')</legend>
617 <span id="hwclocks">$(hwclock -ur | sed 's|0.000000 seconds||')</span>
618 <button name="do" value="hwclock" id="hwclock" data-icon="clock">$(_ 'Set hardware clock')</button>
619 </fieldset>
621 <fieldset><legend>$(_ 'Set date')</legend>
622 EOT
623 if [ -z "$(which yad)" ]; then
624 cat <<EOT
625 <input type="number" name="day" value="$(date +%d)" min="1" max="31" size="4" required/>
626 <select name="month" value="$(date +%m)">
627 $(for i in $(seq 12); do
628 sel=''; [ "$i" == "$(date +%-m)" ] && sel=' selected'
629 printf "<option value=\"%s\"$sel>%s</option>" $(date -d $i.01-01:01 '+%m %B')
630 done)
631 </select>
632 <input type="number" name="year" value="$(date +%Y)" min="2015" max="2030" size="6" required/>
633 EOT
634 else
635 cat <<EOT
636 <button onclick="datePicker(); return false">
637 <span id="dateTime" data-icon="calendar">$(date +%x)<span style="display:none">$(date +%F)</span></span>
638 </button>
639 EOT
640 fi
641 cat <<EOT
642 - <input type="number" name="hour" value="$(date +%H)" min="0" max="23" size="4" required/><!--
643 -->:<input type="number" name="min" value="$(date +%M)" min="0" max="59" size="4" required/><!--
644 -->:<input type="number" name="sec" value="00" min="0" max="59" size="4" required/>
645 EOT
646 if [ -z "$(which yad)" ]; then
647 cat <<EOT
648 <button name="do" value="date" data-icon="ok">$(_ 'Set date')</button>
649 EOT
650 else
651 cat <<EOT
653 <button data-icon="ok" onclick="submitSysTimeForm()">$(_ 'Set date')</button>
654 EOT
655 fi
656 cat <<EOT
657 </fieldset>
658 </form>
659 </div>
661 <script type="text/javascript">
662 // Live time on page
663 Date.prototype.timeNow = function() {
664 return ((this.getHours() < 10)?"0":"") + this.getHours() + ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
665 }
666 setInterval(function(){
667 document.getElementById('time').innerText = new Date().timeNow();
668 //ajax('settings.cgi?do=gethwclock', '1', 'hwclocks');
669 }, 1000);
672 // Run date picker and return value to the 'dateTime' element
673 function datePicker() {
674 ajax('settings.cgi?do=calendar', '1', 'dateTime');
675 }
677 // Actions to do before form submit and submit
678 function submitSysTimeForm() {
679 sysTimeForm = document.getElementById('sysTimeForm');
681 var dateFull = document.createElement('INPUT');
682 dateFull.name = 'dateFull';
683 dateFull.value = document.getElementById('dateTime').childNodes[1].innerText;
684 dateFull.type = 'hidden';
685 sysTimeForm.appendChild(dateFull);
687 var submitDo = document.createElement('INPUT');
688 submitDo.name = 'do'; submitDo.value = 'date';
689 submitDo.type = 'hidden';
690 sysTimeForm.appendChild(submitDo);
692 sysTimeForm.submit();
693 }
694 </script>
695 </section>
696 EOT
699 #
700 # Locale settings
701 #
702 cat <<EOT
703 <section>
704 <header id="locale">$(_ 'System language')</header>
705 <div>
706 <form>
707 EOT
708 # Check if a new locale was requested
709 if [ -n "$new_locale" ]; then
710 rm -rf /usr/lib/locale/$new_locale
711 localedef -i $new_locale -c -f UTF-8 \
712 /usr/lib/locale/$new_locale
713 # System configuration
714 echo "LANG=$new_locale" > /etc/locale.conf
715 echo "LC_ALL=$new_locale" >> /etc/locale.conf
716 msg warn "$(_ \
717 'You must logout and login again to your current session to use %s locale.' $new_locale)"
718 else
719 cat <<EOT
720 $(_ 'Current system locale:')
721 <strong>$(locale | grep LANG | cut -d= -f2)</strong>
722 <button name="locale" data-icon="locale">$(_ 'Change')</button>
723 EOT
724 fi
725 cat <<EOT
726 </div>
727 </form>
728 </section>
731 <section>
732 <header id="keymap">$(_ 'Keyboard layout')</header>
733 <div>
734 EOT
735 # Check if a new keymap was requested
736 if [ -n "$new_keymap" ]; then
737 echo "$new_keymap" > /etc/keymap.conf
738 if [ -x /bin/loadkeys ]; then
739 loadkeys $new_keymap
740 else
741 loadkmap < /usr/share/kmap/$new_keymap.kmap
742 fi
743 fi
745 keymap=$(cat /etc/keymap.conf)
746 _ 'Current console keymap: %s' $keymap
747 if [ -n "$keymap" ]; then
748 case "$keymap" in
749 fr_CH*)
750 keymap="ch" ;;
751 ru)
752 keymap="us,ru" ;;
753 slovene)
754 keymap=si ;;
755 *)
756 keymap=${keymap%-lat*}
757 keymap=${keymap%-abnt2} ;;
758 esac
759 keyboard_config=/etc/X11/xorg.conf.d/40-Keyboard.conf
760 cat <<EOT
761 <form id="settings"></form>
762 <form id="index" action="index.cgi"></form>
763 <br/>
764 $(_ 'Suggested keymap for Xorg:') $keymap
765 <button form="settings" name="apply_xorg_kbd" value="$keymap" data-icon="ok">$(_ 'Activate')</button>
766 <button form="index" name="file" value="$keyboard_config" data-icon="edit">$(_ 'Edit')</button>
767 <input form="index" type="hidden" name="action" value="edit" />
768 <br/>
769 EOT
770 fi
771 cat <<EOT
772 <form>
773 $(_ 'Available keymaps:')
774 <select name="gen_keymap">
775 $(list_keymaps)
776 </select>
777 <button type="submit" data-icon="ok">$(_ 'Activate')</button>
778 </form>
779 </div>
780 </section>
783 <section>
784 <header>$(_ 'Panel configuration')</header>
785 <div>
786 <form class="wide">
787 <fieldset><legend>$(_ 'Style:')</legend>
788 <select name="style">$(list_styles)</select>
789 <button data-icon="ok">$(_ 'Activate')</button>
790 </fieldset>
791 </form>
793 <fieldset><legend>$(_ 'Configuration files:')</legend>
794 <button form="index" name="file" value="$CONFIG" data-icon="edit">$(_ 'Panel')</button>
795 <button form="index" name="file" value="$HTTPD_CONF" data-icon="edit">$(_ 'Server')</button>
796 </fieldset>
798 <p>$(_ 'TazPanel provides a debugging mode and page:')
799 <a href="index.cgi?debug">debug</a>
800 </p>
801 </div>
802 </section>
803 EOT
804 ;;
805 esac
807 xhtml_footer
808 exit 0