tazpanel annotate settings.cgi @ rev 521

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