The /usr/local/jwmconfig2/panel-buttons script supplied with Slacko 5.3.3 adds one extra comment and deletes one line in /root/.jwmrc-tray every time a button is added to the tray.
The comment added is always a copy of this existing comment:
Code: Select all
<!-- Additional TrayButton attribute: label -->
The line removed is the first non-blank line following the last button added.
If the original /root/.jwmrc-tray supplied with Slacko 5.3.3 is used as a starting point, adding buttons causes the following behavior:
The first time a button is added, the line deleted is just a comment, so the tray is created as expected. But when a second button is added, this line is deleted:
So the pager buttons (for switching desktops) disappear.
Adding a third button just deletes another comment, but adding a fourth button deletes this line:
So the task list disappears.
Adding a fifth button deletes this line:
And the dock is gone.
Adding a sixth button just deletes another comment, but adding a seventh deletes only the first line of a comment, which confuses JWM, and everything else vanishes -- in this case, the swallowed program (xload) and the clock.
Adding an eighth and ninth button deletes the last two lines of that same comment, so JWM is no longer confused, and the swallowed program and the clock reappear.
OK, I think I need not continue adding buttons. You get the idea.
The reason that lines are being deleted is that the number of lines remaining in .jwmrc-tray after the last line with a TrayButton definition is sometimes calculated incorrectly. And that happens because the total number of lines in .jwmrc-tray is sometimes calculated wrongly. The total is found using
wc -l which counts newline characters, not lines. If the last line in the file has no newline character, the value returned by
wc -l will be one shy of the actual number of lines.
The original .jwmrc-tray file supplied with Slacko 5.3.3 has no newline character in the last line.
While supplying a .jwmrc-tray file that ends with a newline character would make this problem go away at least initially, it wouldn't be the most robust solution. A user might manually edit the file and leave off the final newline -- something that is not ruled-out by the JWM documentation, and something that JWM itself is perfectly happy with. It would be better if the panel-buttons script could tolerate a configuration file that didn't end with a newline character.
An earlier version of the panel-buttons script (in jwmconfig2-20111110.pet in
the puppy-common-official repository) included an
October 2011 solution from Karl Godt, which appended a newline character to the file if it didn't already end with one. That works.
An alternative solution would be to use
sed -n $= to count the lines, instead of
wc -l. Using
sed -n $= counts lines, not newline characters.
So line 62:
Code: Select all
total=`wc -l /root/.jwmrc-tray | sed -e 's/ *//' | sed -e 's/ .*//g'` ### get total number of lines
could be replaced by
Code: Select all
total=`sed -n $= /root/.jwmrc-tray` ### get total number of lines
As for the extra comment that gets added every time a button is added, that doesn't cause any problems (other than making the file grow unnecessarily), so could be ignored. But it could be fixed by filtering the comment out of CURRENTBTNSCODE by replacing line 24:
Code: Select all
CURRENTBTNCODE=$(grep "TrayButton" $HOME/.jwmrc-tray|grep -v "root:3")
with:
Code: Select all
CURRENTBTNCODE=$(grep '^[[:blank:]]*<TrayButton' $HOME/.jwmrc-tray|grep -v "root:3")
Line 25 is fine:
Code: Select all
CURRENTBTNS=$(grep "TrayButton" $HOME/.jwmrc-tray|grep -v "root:3"|\
But it could be given the same treatment as line 24, by changing it to:
Code: Select all
CURRENTBTNS=$(grep '^[[:blank:]]*<TrayButton' $HOME/.jwmrc-tray|grep -v "root:3"|\
That way, if the user happened to add a single-line comment containing the word "TrayButton", it would not become part of CURRENTBTNS, even if it didn't also contain the word "Additional". This would also eliminate the need for line 26.
By the way, although I ran into this problem in Slacko 5.3.3, it looks like the same panel-buttons script is in jwmconfig2-121105.pet, which I think is used by Slacko 5.4.