# HG changeset patch # User Aleksej Bobylev # Date 1474623160 -10800 # Node ID 02ac7cd16669f18928b0a42bbb657ca0282d45dc # Parent 2b400bf4af9859af4ac75602fd827d73d40163bb settings.cgi: tweaks: change only first menu icon (right user/logon menu will not be affected) diff -r 2b400bf4af98 -r 02ac7cd16669 settings.cgi --- a/settings.cgi Sun Sep 18 17:39:10 2016 +0200 +++ b/settings.cgi Fri Sep 23 12:32:40 2016 +0300 @@ -174,21 +174,32 @@ fi for panel in $(find $lxpanel -type f -iname panel); do + # Change first icon in "Plugin {" > "type = menu" > "image = *" awk -vicon="/usr/share/pixmaps/$(GET tweak).png" ' - BEGIN{ found = "0"; } + BEGIN{ found = 0; changed = 0; } { - if ($1 == "Plugin") { found = "1"; } + # First matched icon not changed yet + if (changed == 0) { + # 1: first line of plugin definition found + if ($1 == "Plugin") { found = 1; } - if (found == "1" && $1 == "type") { - if ($3 == "menu") found = "2"; else found = "0"; - } + # 2: plugin is menu type + if (found == 1 && $1 == "type") { + found = ($3 == "menu") ? 2 : 0; + } - if (found == "2" && $1 == "Plugin") { found = "0"; } + # 0: reset, begin of new plugin found + if (found == 2 && $1 == "Plugin") { found = 0; } - if (found == "2" && index($1, "image")) { - printf " image=%s\n", icon; - found = 0; + # change image in the first menu plugin + if (found == 2 && index($1, "image")) { + printf " image=%s\n", icon; + changed = 1; found = 0; + } else { + print; + } } else { + # just pass input to output print; } }