tazpanel 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 2b400bf4af98
children 04d4a6cc373f
files settings.cgi
line diff
     1.1 --- a/settings.cgi	Sun Sep 18 17:39:10 2016 +0200
     1.2 +++ b/settings.cgi	Fri Sep 23 12:32:40 2016 +0300
     1.3 @@ -174,21 +174,32 @@
     1.4  				fi
     1.5  
     1.6  				for panel in $(find $lxpanel -type f -iname panel); do
     1.7 +					# Change first icon in "Plugin {" > "type = menu" > "image = *"
     1.8  					awk -vicon="/usr/share/pixmaps/$(GET tweak).png" '
     1.9 -					BEGIN{ found = "0"; }
    1.10 +					BEGIN{ found = 0; changed = 0; }
    1.11  					{
    1.12 -						if ($1 == "Plugin") { found = "1"; }
    1.13 +						# First matched icon not changed yet
    1.14 +						if (changed == 0) {
    1.15 +							# 1: first line of plugin definition found
    1.16 +							if ($1 == "Plugin") { found = 1; }
    1.17  
    1.18 -						if (found == "1" && $1 == "type") {
    1.19 -							if ($3 == "menu") found = "2"; else found = "0";
    1.20 -						}
    1.21 +							# 2: plugin is menu type
    1.22 +							if (found == 1 && $1 == "type") {
    1.23 +								found = ($3 == "menu") ? 2 : 0;
    1.24 +							}
    1.25  
    1.26 -						if (found == "2" && $1 == "Plugin") { found = "0"; }
    1.27 +							# 0: reset, begin of new plugin found
    1.28 +							if (found == 2 && $1 == "Plugin") { found = 0; }
    1.29  
    1.30 -						if (found == "2" && index($1, "image")) {
    1.31 -							printf "        image=%s\n", icon;
    1.32 -							found = 0;
    1.33 +							# change image in the first menu plugin
    1.34 +							if (found == 2 && index($1, "image")) {
    1.35 +								printf "        image=%s\n", icon;
    1.36 +								changed = 1; found = 0;
    1.37 +							} else {
    1.38 +								print;
    1.39 +							}
    1.40  						} else {
    1.41 +							# just pass input to output
    1.42  							print;
    1.43  						}
    1.44  					}