# HG changeset patch # User Aleksej Bobylev # Date 1430497801 -10800 # Node ID 84d34ba7dc0607e4179576faafaa686cd8bbd336 # Parent 12e726724a741d5baca42c05b02340864bd9b780 settings.cgi: add tweaks to quick change terminal prompt style, and LXPanel menu button style. diff -r 12e726724a74 -r 84d34ba7dc06 settings.cgi --- a/settings.cgi Thu Apr 30 18:37:05 2015 +0200 +++ b/settings.cgi Fri May 01 19:30:01 2015 +0300 @@ -12,7 +12,6 @@ . lib/libtazpanel get_config -header TITLE=$(_ 'TazPanel - Settings') @@ -95,6 +94,76 @@ *\ style*) sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG . $CONFIG ;; + + + *\ tweak\ *) + HOME="$(awk -F: -vu=$REMOTE_USER '$1==u{print $6}' /etc/passwd)" + [ -z "$HOME" ] && exit 0 + + case $REMOTE_USER in + root) color=31; ind='#';; + *) color=32; ind='$';; + esac + + case $(GET tweak) in + monochrome) + # PS1='\u@\h:\w\$ ' + sed -i "s|^PS1=.*|PS1='\\\\u@\\\\h:\\\\w\\\\$ind '|" $HOME/.profile;; + colored) + # PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\$ ' + sed -i "s|^PS1=.*|PS1='\\\\\\[\\\\e\[0;${color}m\\\\\\]\\\\u@\\\\h\\\\\\[\\\\e\\[0m\\\\\\]:\\\\\\[\\\\e\\[0;33m\\\\\\]\\\\w\\\\\\[\\\\e\\[0m\\\\\\]\\\\$ind '|" $HOME/.profile;; + slitaz-*) + lxpanel="$HOME/.config/lxpanel" + if [ ! -e "$lxpanel" ]; then + mkdir -p "$lxpanel"; cp /etc/lxpanel/default /etc/lxpanel/slitaz $lxpanel + fi + for panel in $(find /home/tux/.config/lxpanel -type f -iname panel); do + awk -vicon="/usr/share/pixmaps/$(GET tweak).png" ' + BEGIN{ found = "0"; } + { + if ($1 == "Plugin") { found = "1"; } + + if (found == "1" && $1 == "type") { + if ($3 == "menu") found = "2"; else found = "0"; + } + + if (found == "2" && $1 == "Plugin") { found = "0"; } + + if (found == "2" && index($1, "image")) { + printf " image=%s\n", icon; + found = 0; + } else { + print; + } + } + ' $panel > $panel.new + mv -f $panel.new $panel + done + + # `lxpanelctl restart` exists, but it breaks often leaving us without any panel + killall lxpanel; DISPLAY=':0.0' lxpanel & + ;; + menu-notext) + dd="$HOME/.local/share/desktop-directories" + mkdir -p $dd + echo -e '[Desktop Entry]\nType=Directory\nName=' > $dd/SliTazMenu.directory + killall lxpanel; DISPLAY=':0.0' lxpanel & + ;; + menu-text) + dd="$HOME/.local/share/desktop-directories/SliTazMenu.directory" + [ -f "$dd" ] && rm "$dd" + killall lxpanel; DISPLAY=':0.0' lxpanel & + ;; + esac + exit 0 + ;; + + + *\ menuIcon\ *) + icon="/usr/share/pixmaps/$(GET menuIcon).png" + [ ! -r $icon ] && exit 0 + header "Content-Type: image/png"; cat $icon; exit 0 + ;; esac @@ -105,14 +174,16 @@ # Default xHTML content # +header xhtml_header -check_root_tazpanel case " $(GET) " in *\ group*) # # Groups management # + check_root_tazpanel + cat <$(_ 'Manage groups') @@ -206,6 +277,8 @@ # # Users management # + check_root_tazpanel + cat <$(_ 'Manage users') @@ -314,6 +387,8 @@ # # Choose locale # + check_root_tazpanel + LOADING_MSG="$(_ 'Please wait...')"; loading_msg cur_loc=$(locale | grep LANG | cut -d= -f2) @@ -388,10 +463,123 @@ ;; + *\ tweaks\ *) + # + # Small tweaks for user + # + + user="$REMOTE_USER"; host="$(hostname)" + HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)" + font="${TERM_FONT:-monospace}"; palette=$(echo $TERM_PALETTE | tr A-Z a-z) + case $user in + root) color=31; ind="#";; + *) color=32; ind="$";; + esac + + prompt_bw="$user@$host:/usr/bin$ind" + prompt_c="$user@$host:/usr/bin$ind" + cursor="_" + cat < +function tweak(tweakName) { + // Send request to the server + var hiddenImg = document.createElement('IMG'); + hiddenImg.src = "settings.cgi?tweak=" + tweakName; +} + + +
+
$(_ 'Small quick tweaks for user %s' "$user")
+ +
$(_ 'Terminal prompt') + + + + + +
+ +
+$prompt_bw uname -r
$(uname -r)
$prompt_bw date
$(date)
$prompt_bw $cursor +
+
+ +
+$prompt_c uname -r
$(uname -r)
$prompt_c date
$(date)
$prompt_c $cursor +
+
+ +

$(_ 'Manual edit: %s' "~/.profile")
+$(_ 'To take effect: log out and log in to system or execute command in the terminal:')

+ +
. ~/.profile
+
+ +
+ +
+ $(_ 'Menu button appearance') + + + + + +
+
+ $(_ 'Icon:') +
+
+
+ +
+
+
+ $(_ 'Text:') +
+ +
+
+

$(_ 'Manual edit: %s' \ + "~/.local/share/desktop-directories/SliTazMenu.directory + $( + find $HOME/.config/lxpanel -type f -name panel | awk -vh="$HOME" \ + '{ printf "%s ", $1, gensub(h, "~", "")}' + )")

+
+
+EOT + ;; + + *) # # Default system settings page # + check_root_tazpanel cat <$(_ 'System settings') diff -r 12e726724a74 -r 84d34ba7dc06 styles/default/header.html --- a/styles/default/header.html Thu Apr 30 18:37:05 2015 +0200 +++ b/styles/default/header.html Fri May 01 19:30:01 2015 +0300 @@ -78,9 +78,10 @@
  • $(_ 'Settings') -
  • $(_ 'Summary')
  • -
  • $(_ 'Users')
  • -
  • $(_ 'Groups')
  • +
  • $(_ 'Summary')
  • +
  • $(_ 'Users')
  • +
  • $(_ 'Groups')
  • +
  • $(_ 'Tweaks')
  • $(for i in menu.d/settings/* ; do [ -f $i ] && sh $i menu $i ; done)