This forum has been archived. All content is frozen. Please use KDE Discuss instead.

NotShowIn and OnlyShowIn not recognized in expanded KDEDIRS

Tags: None
(comma "," separated)
woodsman
Registered Member
Posts
63
Karma
0
I have a small collection of *.desktop files I use to override the system defaults.

I use the KDEDIRS environment variable to access those *.desktop files:

KDEDIRS=/usr/local/kde_mods:/usr

The directory structure under /usr/local/kde_mods is exactly the same as /usr. The KDEDIRS variable is working because I have some global service menus installed there and they all appear in both the Dolphin and Konqueror context menus.

Yet when I add NotShowIn or OnlyShowIn in the *.desktop files the items still appear in the launcher menu (k-menu). For example, NotShowIn=KDE; or OnlyShowIn=XFCE;.

When I copy the *.desktop files to the appropriate directory in /usr or $HOME/.local then the items disappear from the launcher menu and the NotShowIn and OnlyShowIn keys are recognized.

Is this a bug or am (hopefully) missing something obvious?

Thanks. :)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If you run "kbuildsycoca4 --noincremental" with the options in question set, do you see any references to why KDE may consider the options invalid?
Make sure you enable all debug output first, using kdebugdialog.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
woodsman
Registered Member
Posts
63
Karma
0
Thanks for replying. I suspect I stumbled across a corner case type bug. I'm not an XDG guru therefore I won't speculate how the whole chain is supposed to work.

The short answer to your question is I haven't tried your test --- yet. :)

Since I posted I did some more investigating. I believe the problem is related to the way XDG_DATA_DIRS is created in startkde.

I start X from the command line (run level 3, Slackware 14.0). At that point the XDG_DATA_DIRS variable is not defined. Therefore a snippet at about line 265 in startkde creates the variable:

XDG_DATA_DIRS="`kde4-config --prefix`/share:/usr/share:/usr/local/share"

Incidentially, this results in the variable looking like this:

XDG_DATA_DIRS="/usr/share:/usr/share:/usr/local/share"

Seems there should be a basic integrity check to ensure /usr/share is not duplicated.

My experience with the XDG_DATA_DIRS variable is not to try to guess how to define that variable. What seems apparent on my system is when the variable gets defined in startkde, the expanded KDEDIRS variable is overriden to some degree but not completely.

I'm not done testing yet but thus far I explicitly tested defining the XDG_DATA_DIRS variable from an /etc/profile.d script, which then prevents the snippet in startkde from executing. That seems to work but I don't know whether that is the optimal solution. I suspect the proper way of creating that variable in startkde includes some sanity tests that include KDEDIRS.

I still need to run a test of commenting out the startkde snippet to see whether KDEDIRS is then observed fully.
woodsman
Registered Member
Posts
63
Karma
0
I tested startkde without the XDG_DATA_DIRS snippet and everything worked according to the KDEDIRS variable, which in my case is KDEDIRS=/usr:/usr/local/kde_mods.

According to this page, if set then XDG_DATA_DIRS should be set to /usr/local/share/:/usr/share. The current snippet in startkde has that backwards, along with the duplicate /usr/share.

However, I know from working on another project that XDG_DATA_DIRS should be explicitly set only when software is installed in a non-standard location, such as /opt. In other words, XDG_DATA_DIRS should not be set at all in startkde when `kde4-config --prefix` == /usr. That way the KDEDIRS variable gets to function correctly.

I propose startkde be updated to something like this:

Code: Select all
# Explicitly set $XDG_DATA_DIRS only when KDE is not installed in /usr.
# Explicitly declaring $XDG_DATA_DIRS will override the default search path of /usr/share.
# Explicitly declaring $XDG_DATA_DIRS will override $KDEDIRS, which must then be
# explicitly identified in the $XDG_DATA_DIRS string to remain useful.
# The $KDEDIR variable is intended to be singular and $KDEDIRS plural. When $KDEDIRS
# exists in the environment then parse that variable into separate directories.
# $KDEDIRS should contain whatever is set in $KDEDIR. Therefore any additional directories
# set in $KDEDIRS are intended to override data files found in $KDEDIR. Those additional
# directories should be placed before $KDEDIR and before /usr/share.
if [ "$KDEDIR" != "/usr" ] && [ -d $KDEDIR/share ]; then
  if [ "$XDG_DATA_DIRS" = "" ]; then
    # Ensure the standard location of /usr/share is included.
    XDG_DATA_DIRS=/usr/share
  else
    if [ "`echo $XDG_DATA_DIRS | grep \"/usr/share\"`" = "" ]; then
      XDG_DATA_DIRS=$XDG_DATA_DIRS:/usr/share
    fi
  fi
  if [ "`echo $XDG_DATA_DIRS | grep \"$KDEDIR/share\"`" = "" ]; then
    XDG_DATA_DIRS=$KDEDIR/share:$XDG_DATA_DIRS
  fi
  if [ "$KDEDIRS" != "" ]; then
    for i in `seq \`echo $KDEDIRS | awk -F : '{print NF}'\` -1 1`; do
      if [ "`echo $XDG_DATA_DIRS | grep \"\`echo $KDEDIRS | cut -d: -f${i}\`\"`" = "" ]; then
        XDG_DATA_DIRS=`echo $KDEDIRS | cut -d: -f${i}`/share:$XDG_DATA_DIRS
      fi
    done
  fi
  export XDG_DATA_DIRS
fi
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Patches to improve parts of KDE are always welcome. I suggest cloning KDE Workspace from KDE anongit, and then submitting a patch for this on Reviewboard at https://git.reviewboard.kde.org/

In regards to XDG_DATA_DIRS - If you have multiple directories in KDEDIRS, then you need to make sure each of them is accounted for in XDG_DATA_DIRS. You therefore need to add /usr/local/kde_mods/share into it.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
woodsman
Registered Member
Posts
63
Karma
0
In regards to XDG_DATA_DIRS - If you have multiple directories in KDEDIRS, then you need to make sure each of them is accounted for in XDG_DATA_DIRS. You therefore need to add /usr/local/kde_mods/share into it.

I believe the opposite is required. :) As I mentioned, XDG_DATA_DIRS should be explicitly declared in startkde only when KDE is installed to a non standard location.

I'm running my system under these same conditions. That is, I applied the changes I mentioned above to startkde, and left my KDEDIRS variable as originally assigned with the additional directory. Everything works with no fiddling at all.

I would like to submit a patch at the URL you provided, but am unable to login. I tried both my forum handle and my forum email address and neither work. I can login to the forum and bug tracker. Edit: I finally logged in. :)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
In this case, any path where KDE plugins, applications or other items which use *.desktop files are stored should be included in both XDG_DATA_DIRS and KDEDIRS.

When making your review, please make sure to include either the kde-workspace or kde-core-devel groups.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kde-naveen, Sogou [Bot], Yahoo [Bot]