tazpanel annotate settings.cgi @ rev 617

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