Bug 83488

Summary: Does not create applications-kmenuedit.menu file
Product: [Applications] kmenuedit Reporter: Frans Pop <elendil>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 0.5   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: strace for 'kmenuedit --nofork'
.menu files
/etc/xdg/menus/applications.menu and referenced files
~/.config/menus directory for a newly created user

Description Frans Pop 2004-06-16 14:08:35 UTC
Version:           0.5 (using KDE 3.2.2,  (testing/unstable))
Compiler:          gcc version 3.3.3 (Debian 20040401)
OS:                Linux (i686) release 2.6.5.20040613-1

I think I may have found the cause of the bug reports where it says 'kmenuedit does not save changes'.

If the file '~/.config/menus/applications-kmenuedit.menu' does not exist when kmenuedit is started, there will be a warning in ~/.xsession-errors (Could not read...), but the file is _not_ created when changes are saved.

I think this means that, even though a .desktop file is created in ~/.local/share/applications with the changes made in kmenuedit, they will never be used and will appear to 'not have been saved'.

I tested this on a newly installed Debian Sarge system (KDE 3.2.2) by modifying the Command for fortune (Debian/Apps/Text/Fortune) from
'[...] /usr/games/fortune | [...]' to '[...] /usr/games/fortune -s -n 30 | [...]'.
This should result in only fortunes shorter than 30 characters to be displayed.
If I 'cat ~/.local/share/applications/fortune.desktop', the changes are there.

However, if I run fortune from the menu, I still get long fortunes and if I run kmenuedit again, the changes are not there.
So it looks like in both cases the original /var/lib/menu-xdg/applications/menu-xdg/fortune.desktop is being used. Logging out and logging back in makes no difference.

Hope this helps.
Comment 1 Frans Pop 2004-06-16 14:41:11 UTC
Created attachment 6384 [details]
strace for 'kmenuedit --nofork'

I did an strace for this problem.
Some relevant lines from this:

$ egrep "(fortune|\.config/menus/)" kmenuedit.strace
stat64("/home/fjp/.config/menus/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) =
0
open("/home/fjp/.config/menus/applications-kmenuedit.menu",
O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
write(2, "kmenuedit: WARNING: Could not re"..., 87
kmenuedit: WARNING: Could not read
/home/fjp/.config/menus/applications-kmenuedit.menu
access("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop", W_OK) = -1
EACCES (Permission denied)
access("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop", F_OK) = 0
access("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop", W_OK) = -1
EACCES (Permission denied)
access("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop", F_OK) = 0
lstat64("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop",
{st_mode=S_IFREG|0644, st_size=244, ...}) = 0
open("/var/lib/menu-xdg/applications/menu-xdg/fortune.desktop",
O_RDONLY|O_LARGEFILE) = 11
access("/home/fjp/.local/share/applications/fortune.desktop", W_OK) = -1 ENOENT
(No such file or directory)
access("/home/fjp/.local/share/applications/fortune.desktop", F_OK) = -1 ENOENT
(No such file or directory)
lstat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
stat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
lstat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
stat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
lstat64("/home/fjp/.local/share/applications/fortune.desktop", 0xbfffe99c) = -1
ENOENT (No such file or directory)
lstat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
stat64("/home/fjp/.local/share/applications/fortune.desktop", 0x81fb9c0) = -1
ENOENT (No such file or directory)
access("/home/fjp/.local/share/applications/fortune.desktop", W_OK) = -1 ENOENT
(No such file or directory)
access("/home/fjp/.local/share/applications/fortune.desktop", F_OK) = -1 ENOENT
(No such file or directory)
open("/home/fjp/.local/share/applications/fortune.desktopMbhFoa.new",
O_RDWR|O_CREAT|O_EXCL, 0600) = 11
stat64("/home/fjp/.local/share/applications/fortune.desktop", 0xbfffe8ac) = -1
ENOENT (No such file or directory)
rename("/home/fjp/.local/share/applications/fortune.desktopMbhFoa.new",
"/home/fjp/.local/share/applications/fortune.desktop") = 0
lstat64("/home/fjp/.local/share/applications/fortune.desktop",
{st_mode=S_IFREG|0600, st_size=333, ...}) = 0
Comment 2 Waldo Bastian 2004-06-16 14:53:16 UTC
You wrote: "Does not create applications-kmenuedit.menu file"

In this case that should not be a problem, since that file is not needed. The layout of the menu has not changed, so there is nothing to save. The changes that you made to fortune.desktop seem to get saved correctly as well.

So the only actual issue is why ~/.local/share/applications/fortune.desktop
doesn't get used.

Does it help if you run "kbuildsycoca --noincremental" ?

What does "kbuildsycoca --menutest" say about fortune.desktop ?
Comment 3 Frans Pop 2004-06-16 15:22:49 UTC
Thanks for your quick reaction.

This is the result of your suggestions.

fjp@strider:~$ kbuildsycoca --menutest | grep fortune
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
kbuildsycoca running...
Reusing existing ksycoca
kbuildsycoca: WARNING: Property 'X-KDE-Weight' is defined multiple times (KOfficeFilter)
Debian/Apps/Text/       fortune.desktop /var/lib/menu-xdg/applications/menu-xdg/fortune.desktop

fjp@strider:~$ kbuildsycoca --noincremental
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
kbuildsycoca running...
kbuildsycoca: WARNING: Property 'X-KDE-Weight' is defined multiple times (KOfficeFilter)

I also tried starting fortune from the menu after running 'kbuildsycoca --noincremental', but no improvement.
There was also no change in the output from 'kbuildsycoca --menutest | grep fortune'.
Comment 4 Waldo Bastian 2004-06-16 21:30:32 UTC
Can you show the output of:
	export | grep XDG

Can you check which applications.menu files you have around and attach them to this bugreport?

By default /var/lib/menu-xdg isn't used, so I am wondering how things are configured so that it looks there. That might point to why it doesn't look in ~/.local/share/applications.
Comment 5 Frans Pop 2004-06-16 22:02:33 UTC
Created attachment 6391 [details]
.menu files

Nothing for XDG in export. Looks like the problem is the fact that Debian uses
a simlink in /etc/xdg/menus!
Is this a packaging error or should it be supported?

fjp@strider:/etc/xdg/menus$ export | grep XDG
fjp@strider:/etc/xdg/menus$ ls -l * (output edited!)
applications.menu
debian-menu.menu -> /var/lib/menu-xdg/menus/debian-menu.menu
kde-information.menu
kde-screensavers.menu
kde-settings.menu
applications-merged/kde-essential.menu
Comment 6 Waldo Bastian 2004-07-20 13:53:59 UTC
There must also be a symlink somewhere to 
/var/lib/menu-xdg/applications/menu-xdg

I think that one confuses kmenuedit.
Comment 7 Frans Pop 2004-07-20 15:19:22 UTC
Sorry, can't confirm that.
I have done an extensive scan on my system, but I can find no other symlinks involving menu-xdg.
Comment 8 Waldo Bastian 2004-07-21 13:28:21 UTC
Due to the nature of the debian-menu.menu file entries under the Debian menu can not be edited:

The application files specified in the debian-menu.menu file via <AppDir>/var/lib/menu-xdg/applications/menu-xdg</AppDir> take precedence over
files under ~/.local/applications, as explained on
http://freedesktop.org/Standards/menu-spec/0.8/ar01s06.html

"For each <Menu> element, build a pool of desktop entries by collecting entries found in each <AppDir> for the menu element. If two entries have the same desktop-file id, the entry for the earlier (closer to the top of the file) <AppDir> must be discarded."

The solution for Debian would be to remove the line
<AppDir>/var/lib/menu-xdg/applications/menu-xdg</AppDir> from debian-menu.menu
and place it in applications.menu somewhere in front of
<DefaultAppDirs/>
Comment 9 Alexey Neyman 2004-07-23 18:59:00 UTC
I have the same problem with the Fedora Core 2 distribution. I just tried to add the 'Acrobat Reader' icon to menu; but it did not appear there. What I found is that the newly created file was available as

/home/avn/.local/share/applications/Acrobat\ Reader.desktop

while kbuildsycoca, apparently, tries to open

/home/avn/.kde/share/applnk/Office/Acrobat\ Reader.desktop

Copying the .desktop file from .local/share/applications to .kde/share/applnk/Office and rerunning kbuildsycoca
made the icon for acroread appear in the K-menu.

Is it a KDE's fault or a misconfiguration in the Fedora package?
Comment 10 Waldo Bastian 2004-07-29 15:12:15 UTC
Alexey:

1) Can you attach Fedora's /etc/xdg/menus/applications.menu file?
If it references other files (Look out for <MergeFile> in application.menu), can you attach those as well?

2) Did you already have a
/home/avn/.kde/share/applnk/Office/Acrobat\ Reader.desktop file?

3) If you delete /home/avn/.kde/share/applnk/Office/Acrobat\ Reader.desktop,
does it then work if you copy
/home/avn/.local/share/applications/Acrobat\ Reader.desktop
to
/home/avn/.local/share/applications/kde-Acrobat\ Reader.desktop
?
Comment 11 Alexey Neyman 2004-07-29 16:23:57 UTC
Waldo,

Answers:

1. First, in Fedora there are 2 files:
/etc/xdg/menus/applications.menu
/etc/xdg/menus/applications.menu.kde

Both reference some additional files, attached as well. I'm attaching both,
with all files referenced.

2. No, I had no such file before I copied it from .local/..... directory.

3. <See below>

I just cleared out all instances of Acrobat Reader and started over (removed all Acrobat\ Reader.desktop files, and removed any mentions of it from the .config/menus/applications-kmenuedit.menu file).

That is, step by step:

1. I invoked kmenuedit and added an entry for Acrobat Reader.

* Acrobat\ Reader.destop file is created in ~/.local/share/applications
* The line "<Filename>Acrobat Reader.desktop</Filename>" appeared in the
  ~/.config/menus/applications-kmenuedit.menu file (that file is referenced
  from the /etc/xdg/menus/applications.menu
* "Acrobat Reader" item did not appear in the K-Menu

2. Ran 'kbuildsycoca --noincremental'

* No visible changes

3. Moved ~/.local/share/applications/Acrobat\ Reader.desktop to
   ~/.local/share/applications/kde-Acrobat\ Reader.desktop.

* No visible changes

4. Ran 'kbuildsycoca --noincremental'

* No visible changes

5. Moved ~/.local/share/applications/kde-Acrobat\ Reader.desktop
  to .kde/share/applnk/Office/Acrobat\ Reader.desktop.

* 'Acrobat Reader' item appeared in K-Menu
Comment 12 Alexey Neyman 2004-07-29 16:27:05 UTC
Created attachment 6909 [details]
/etc/xdg/menus/applications.menu and referenced files
Comment 13 Waldo Bastian 2004-07-29 17:02:45 UTC
Do you have any other files in ~/.config/menus ?
Comment 14 Alexey Neyman 2004-07-30 07:40:08 UTC
Yes, attached is a tarball of ~/.config/menus directory for a newly created user. This directory along with its contents is created during the first login.
Comment 15 Alexey Neyman 2004-07-30 07:41:06 UTC
Created attachment 6919 [details]
~/.config/menus directory for a newly created user
Comment 16 Waldo Bastian 2004-07-31 17:44:31 UTC
Alexey: Does it work correctly if you delete ~/.config/menu/applications.menu

I suspect your problem is a duplicate of bug BR82610 which got fixed in
kdelibs/kded/vfolder_menu.cpp r1.19.2.3 / r1.24
Comment 17 Alexey Neyman 2004-08-02 07:25:46 UTC
Yes, that's it! Thanks a lot!
Comment 18 Waldo Bastian 2005-03-17 16:56:17 UTC
#1-#8: Debian bug
#9-#17: Fixed