-    if (kdedir)
-    {
-       wxFileName configFile( kdedir, wxEmptyString );
-       configFile.AppendDir( wxT("share") );
-#if 0  
-       configFile.AppendDir( wxT("config") );
-       configFile.SetName( wxT("kdeglobals") );
-
-       wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
-       wxString theme;
-       config.SetPath( wxT("Icons") );
-       config.Read( wxT("Theme"), theme );
-       
-       configFile.RemoveDir( configFile.GetDirCount()-1 );
-       configFile.AppendDir( wxT("icons") );
-       configFile.AppendDir( theme );
-#else
-       configFile.AppendDir( wxT("icons") );
-        configFile.AppendDir( wxT("crystalsvg") );
-#endif
-       
-       if (!wxDir::Exists(configFile.GetPath()))
-       {
-           configFile.RemoveDir( configFile.GetDirCount()-1 );
-           configFile.AppendDir( wxT("crystal") );
-       }
-           
-       if (!wxDir::Exists(configFile.GetPath()))
-       {
-           configFile.RemoveDir( configFile.GetDirCount()-1 );
-           configFile.AppendDir( wxT("default.kde") );
-       }
-       
-       if (wxDir::Exists(configFile.GetPath()))
-       {
-           configFile.AppendDir( wxT("32x32") );
-           configFile.AppendDir( wxT("mimetypes") );
-           icondirs.Add( configFile.GetFullPath() );
-       }
+    if (!kdedir.empty())
+    {
+        // $(KDEDIR)/share/config/kdeglobals holds info
+        // the current icons theme
+        wxFileName configFile( kdedir, wxEmptyString );
+        configFile.AppendDir( wxT("share") );
+        configFile.AppendDir( wxT("config") );
+        configFile.SetName( wxT("kdeglobals") );
+           
+        wxTextFile config;
+        if (configFile.FileExists() && config.Open(configFile.GetFullPath()))
+        {
+            // $(KDEDIR)/share/config -> $(KDEDIR)/share
+            configFile.RemoveDir( configFile.GetDirCount()-1 );
+            // $(KDEDIR)/share/ -> $(KDEDIR)/share/icons
+            configFile.AppendDir( wxT("icons") );
+
+            // Check for entry
+            wxString theme(wxT("default.kde"));
+            size_t cnt = config.GetLineCount();
+            for (size_t i = 0; i < cnt; i++)
+            {
+                if (config[i].StartsWith(wxT("Theme="), &theme/*rest*/))
+                    break;
+            }
+            configFile.AppendDir(theme);
+        }
+        else
+        {
+            // $(KDEDIR)/share/config -> $(KDEDIR)/share
+            configFile.RemoveDir( configFile.GetDirCount()-1 );
+            // $(KDEDIR)/share/ -> $(KDEDIR)/share/icons
+            configFile.AppendDir( wxT("icons") );
+            // $(KDEDIR)/share/icons -> $(KDEDIR)/share/icons/default.kde
+            configFile.AppendDir( wxT("default.kde") );
+        }
+        
+        configFile.SetName( wxEmptyString );
+        configFile.AppendDir( wxT("32x32") );
+        configFile.AppendDir( wxT("mimetypes") );
+        
+        // Just try a few likely icons theme names
+        
+        int pos = configFile.GetDirCount()-3;
+        
+        if (!wxDir::Exists(configFile.GetPath()))
+        {
+            configFile.RemoveDir( pos );
+            configFile.InsertDir( pos, wxT("default.kde") );
+        }
+        
+        if (!wxDir::Exists(configFile.GetPath()))
+        {
+            configFile.RemoveDir( pos );
+            configFile.InsertDir( pos, wxT("default") );
+        }
+        
+        if (!wxDir::Exists(configFile.GetPath()))
+        {
+            configFile.RemoveDir( pos );
+            configFile.InsertDir( pos, wxT("crystalsvg") );
+        }
+        
+        if (!wxDir::Exists(configFile.GetPath()))
+        {
+            configFile.RemoveDir( pos );
+            configFile.InsertDir( pos, wxT("crystal") );
+        }
+        
+        if (wxDir::Exists(configFile.GetPath()))
+            icondirs.Add( configFile.GetFullPath() );