Version: (using KDE 4.3.1) Compiler: orig openSUSE 11.2 RPM, i586 OS: Linux Installed from: openSUSE RPMs when working with default values and the execute [$e] modifier in KDE Desktop files, KConfig delivers different results.
Created attachment 40457 [details] test program for the describted behaviour
how to reproduce: download test environment from Comment 1 tar -xvzf kreadconfig.tgz cd kreadconfig ./kread-desktopfile-test.sh Result on my system is: filename: testdir/test.desktop readName(): TEST root readEntry( "Name" ): TEST root readEntry( "Name", "default" ): $(echo TEST $USER) icon: xmag noDisplay(): True readEntry( "NoDisplay" ): False readEntry( "NoDisplay", True ): true readEntry( "NoDisplay", False ): true dump: [Desktop Entry] Categories = X-SuSE-DesktopUtility; Encoding = UTF-8 Exec = xmag GenericName = Desktop Magnifier Icon = xmag Name = TEST root NoDisplay = False Type = Application X-KDE-StartupNotify = false X-SuSE-Unimportant = true X-SuSE-translate = true Explanation: The test program sets KDEDIRS=$PWD/test/profile1 The Desktop-File test/profile1/share/applnk/testdir/test.desktop is evaluated. The important entries are: Name[$e]=$(echo TEST $USER) NoDisplay[$e]=$(echo "X" >> /tmp/kde.log; echo False) Name should result in "TEST root" (when called as root) and (more important) NoDisplay should result into "False". I've used this (with Hidden instead of NoDisplay) in KDE3, to make an applications only visible if a specific file exists (eg. show application only in start menu if its config file exists) Maybe, this bug is also related to https://bugs.kde.org/show_bug.cgi?id=197523 which have been solved on the application site instead of KConfig.
it would be helpful if you provided a minimal sample, without all the python indirections (i.e., a c++ program, preferably in form of a new testcase in the kconfig autotest. or alternatively a shell script which just uses kreadconfig4).
Created attachment 40463 [details] NoDisplay=False
Created attachment 40464 [details] NoDisplay=True
Created attachment 40465 [details] NoDisplay[$e]=$(echo False)
sorry, I'm afraid I'm not able to do this. I'm not very skilled at C++ and KDE programming. And kreadconfig is very limited. It is primarily intended for config, not desktop files. And when I use it with full path filename, it presents the correct results. But I can provide another test case without further dependencies. I'll add three desktop files as attachments. They are identical, except the NoDisplay entry: 1. NoDisplay=False 2. NoDisplay=True 3. NoDisplay[$e]=$(echo False) copy them to your xdg-data-apps path (eg. /usr/share/applications/). 1 and 3 should get visible in the start menu. Unfortunally, this does not happen for test3: test1: is visible (correct) test2. is not visible (correct) test3. is not visible (wrong!)
It seems, that the problem occours in KConfigGroup::readEntry with a boolean default value. This is what KDesktopFile::noDisplay calls. I don't find a way to evalute to a false value if expand [$e] is used in Config files. I've set $foo to "false" in environment and set NoDisplay[$e]=$foo in a test Desktopfile const KConfigGroup group = kdf.group("Desktop Entry"); qDebug() << "readEntry ( \"NoDisplay\", true ): " << group.readEntry("NoDisplay", true); qDebug() << "readEntry ( \"NoDisplay\", false ): " << group.readEntry("NoDisplay", false); qDebug() << "readEntry ( \"NoDisplay\", \"false\" ): " << group.readEntry("NoDisplay", "false"); readEntry ( "NoDisplay", true ): true readEntry ( "NoDisplay", false ): true readEntry ( "NoDisplay", "false" ): "false" So it seems impossible to use the expand feature for boolean values. I consider this as a bug. Regards Holger
Created attachment 40613 [details] TestProgram in C++ specify desktop file via the -f option. # CMakeLists.txt project (kde4profile) find_package(KDE4 REQUIRED) include (KDE4Defaults) include_directories(${KDE4_INCLUDES}) set(kde4profile_SRCS kde4profile.cpp) kde4_add_executable(kde4profile ${kde4profile_SRCS}) target_link_libraries(kde4profile ${KDE4_KDEUI_LIBS}) install(TARGETS kde4profile ${INSTALL_TARGETS_DEFAULT_ARGS}) # test.desktop [Desktop Entry] X-SuSE-translate=true X-SuSE-Unimportant=true Categories=X-SuSE-DesktopUtility; Encoding=UTF-8 Exec=xmag Type=Application Name[$e]=$foo NoDisplay[$e]=$foo GenericName=Desktop Magnifier Icon[$e]=$foo X-KDE-StartupNotify=false
This bug is a result of bug > 226314. But if there is no solution for 226314 it would be possible to change kdesktopfile.cpp: bool KDesktopFile::noDisplay() const { Q_D(const KDesktopFile); if (d->desktopGroup.readEntry("NoDisplay", false)) { return true; } ... to if (QString("false").compare(d->desktopGroup.readEntry("NoDisplay", "false")) == 0)
Created attachment 41291 [details] Patch / Workaround to let DesktopFile NoDisplay setting work with expand feature Workaround checked against OpenSUSE 11.2 Update Sources (4.3.5)
so i had a look at the code and deep into my memory ... the expansion stuff is an utter mess, and fixing it is in fact the first item in the TODO file.