Page 1 of 1

[SOLVED] in fluxbox, ~/.fluxbox/menu file overwritten

PostPosted: Jun 8th, '13, 10:54
by r0b0tl0ve
Every so often, the ~/.fluxbox/menu file, which controls the right-click menu for fluxbox, gets overwritten and replaced by the systemwide menu file. Why is this happening?

In the meantime, I have changed ~/.fluxbox/menu to be immutable, with `chattr +i`

Re: in fluxbox, ~/.fluxbox/menu file overwritten [RESOLVED]

PostPosted: Jun 18th, '13, 11:11
by r0b0tl0ve
I found the cause: in /etc/menu.d, the script named "fluxbox" does something kind of silly: it checks for a user-generated menu, and if it exists, it overwrites it. I have edited out that logic on my own system; I'll file a bug for this. Here's the patch:
Code: Select all
--- fluxbox.old   2013-06-18 02:01:28.610514703 -0700
+++ fluxbox   2013-06-18 02:01:55.725843341 -0700
@@ -1,10 +1,6 @@
 #!/bin/sh
 
-if [ "$USER_MENU" = "1" ]; then
- OUTPUTDIR=$HOME/.fluxbox
-else
- OUTPUTDIR=/etc/X11/fluxbox
-fi
+OUTPUTDIR=/etc/X11/fluxbox
 
 if [ "$VERBOSE" = "1" ]; then
  echo "writing to $OUTPUTDIR/menu"

Re: in fluxbox, ~/.fluxbox/menu file overwritten [RESOLVED]

PostPosted: Jun 18th, '13, 14:44
by djennings
IceWM does exactly the same thing.

Did you find out how the environment variable $USER_MENU gets set? If the menu is going to be written depending on that variable, it would be nice to know how it gets defined.

Re: in fluxbox, ~/.fluxbox/menu file overwritten [RESOLVED]

PostPosted: Jun 18th, '13, 20:19
by r0b0tl0ve
It gets set by /usr/bin/update-menus, which gets triggered when the file named ".menu-updates.stamp" is present in one of /var/lib/menu/ or $HOME. /usr/bin/update-menus is called by /etc/X11/xinit.d/update-menus. I suspect .menu-updates.stamp gets added when you install an rpm which adds or changes a menu item.

In any case, updating the menu is a good thing, it's the overzealous script in /etc/menu.d that is bad. There is a script there for icewm; too. Here's the patch:

Code: Select all
--- icewm.old   2013-06-18 11:23:56.464184933 -0700
+++ icewm   2013-06-18 11:24:56.865879012 -0700
@@ -1,10 +1,6 @@
 #!/bin/sh
 
-if [ "$USER_MENU" = "1" ]; then
- OUTPUTDIR=$HOME/.icewm
-else
- OUTPUTDIR=/usr/share/X11/icewm/
-fi
+OUTPUTDIR=/usr/share/X11/icewm/
 
 echo "prog \"Terminal\" /usr/share/icons/mini/terminals_section.png /usr/bin/xvt" > $OUTPUTDIR/menu

Re: in fluxbox, ~/.fluxbox/menu file overwritten [RESOLVED]

PostPosted: Jun 19th, '13, 00:25
by djennings
OK I think I understand how it works now. Installing a new package triggers /usr/bin/update-menus which runs as root and set USER_MENU=0

/usr/bin/update-menus runs through the files in /etc/menu.d and will write the system wide menus (not the user menus) it will touch the file /var/lib/menu/.menu-updates.stamp so when users log on they can detect the change.

When a user logs on the file /etc/X11/xinit.d/menu is run which detects the presence of /var/lib/menu/.menu-updates.stamp and runs update-menus again this time with the -u option which forces the creation of user menus in your /home

At no point does it try to test if you have edited your own menu. The scripts do what they are intended to do. It is just not what you would like them to do :-(
If you change the menu file in ~/.fluxbox.init you can use your own menu definition.