tazpanel view settings.cgi @ rev 601

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