Bug 98562

Summary: cannot set default browser with xdg-settings
Product: Portland Reporter: Simon Lees (SUSE) <sflees>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: The superficial patch for KDE 5 support

Description Simon Lees (SUSE) 2016-11-03 00:44:14 UTC
From any desktop / window manager using the fallback mechanisms (enlightenment, XMonad tested) 

$ xdg-settings get default-web-browser 
firefox.desktop
$ xdg-settings set default-web-browser chromium-browser.desktop
$ xdg-settings get default-web-browser 
firefox.desktop

-rw-r--r-- 1 root root 414 Oct  1 22:16 /usr/share/applications/chromium-browser.desktop

openSUSE Bug report: https://bugzilla.suse.com/show_bug.cgi?id=1004321 

This issue is sitting somewhere on my todo list, but probably won't be looked at this week.
Comment 1 Martin Schulze 2016-11-04 17:30:14 UTC
I am not sure if this should go here as well (please tell me whether I should open another bug for that). 

I am running KDE5 on Arch Linux and cannot xdg-settings set default-web-browser either.

Running with XDG_UTILS_DEBUG_LEVEL=3 I obtained:

> $ xdg-settings set default-web-browser chromium-browser.desktop
> Running KDE trader query "text/html" mimetype and "Application" servicetype
> make_default_kde: No kde runtime detected
> make_default_generic chromium-browser.desktop text/html
> Updating /home/username/.local/share/applications/mimeapps.list
> Running KDE trader query "text/html" mimetype and "Application" servicetype
> make_default_kde: No kde runtime detected
> make_default_generic userapp-Firefox-65I9HY.desktop text/html
> Updating /home/username/.local/share/applications/mimeapps.list

I dug a bit deeper into this and noticed, that xdg-mime still has some parts which are not aware of KDE 5. I attached a patch which does some superficial fixes but it is not working although the output changed:

> $ xdg-settings set default-web-browser chromium.desktop
> Running KDE trader query "text/html" mimetype and "Application" servicetype
> make_default_kde chromium.desktop text/html
> Updating /home/username/.local/share/applications//mimeapps.list
> kbuildsycoca5 running...
> Reusing existing ksycoca
> Recreating ksycoca file ("/home/username/.cache/ksycoca5_de_<redacted>", version 303)
> Still in the time dict (i.e. deleted files) ("apps")
> Menu "applications-kmenuedit.menu" not found.
> Saving
> make_default_generic chromium.desktop text/html
> Updating /home/username/.local/share/applications/mimeapps.list
> Running KDE trader query "text/html" mimetype and "Application" servicetype
> make_default_kde userapp-Firefox-65I9HY.desktop text/html
> Updating /home/username/.local/share/applications//mimeapps.list
> kbuildsycoca5 running...
> Reusing existing ksycoca
> Recreating ksycoca file ("/home/username/.cache/ksycoca5_de_<redacted>", version 303)
> Still in the time dict (i.e. deleted files) ("apps")
> Menu "applications-kmenuedit.menu" not found.
> Saving
> make_default_generic userapp-Firefox-65I9HY.desktop text/html
> Updating /home/username/.local/share/applications/mimeapps.list
Comment 2 Martin Schulze 2016-11-04 17:31:51 UTC
Created attachment 127764 [details] [review]
The superficial patch for KDE 5 support
Comment 3 Martin Schulze 2016-11-04 18:22:39 UTC
After having read https://wiki.archlinux.org/index.php/Default_applications#XDG_standard I symlinked as follows:

> $ ln -s ~/.local/share/applications/mimeapps.list ~/.config/mimeapps.list

And it seems to work now. As can be seen from the logs, xdg-settings changed ~/.local/share/applications/mimeapps.list while xdg-mime query reads ~/.config/mimeapps.list via ktraderclient5.
Comment 4 Simon Lees (SUSE) 2016-11-07 03:35:38 UTC
I've tracked down the issue, not sure how to solve it yet, desktop_file_to_binary treats filenames with a - in the format vendor-app.desktop so it is searching for browser.desktop in the chromium directory and failing. If "-" shouldn't be allowed in the desktop file filename there is a large number of broken files on this openSUSE Tumbleweed system, if they are allowed then desktop_file_to_binary needs fixing, i'll raise this on the xdg mailing list

find -iname "*-*"                                                                [Mon Nov  7 14:01:25 ACDT 2016|0]
./YaST2/samba-server.desktop
./YaST2/services-manager.desktop
./YaST2/iscsi-client.desktop
./YaST2/relocation-server.desktop
./YaST2/virtualization-config.desktop
./YaST2/add-on.desktop
./YaST2/yast-language.desktop
./YaST2/samba-client.desktop
./YaST2/auth-client.desktop
./YaST2/ntp-client.desktop
./YaST2/http-server.desktop
./kde4/active-documentviewer_chm.desktop
./kde4/active-documentviewer_comicbook.desktop
./kde4/active-documentviewer_djvu.desktop
./kde4/active-documentviewer_dvi.desktop
./kde4/active-documentviewer_epub.desktop
./kde4/active-documentviewer_fax.desktop
./kde4/active-documentviewer_fb.desktop
./kde4/active-documentviewer_ghostview.desktop
./kde4/active-documentviewer_ooo.desktop
./kde4/active-documentviewer_pdf.desktop
./kde4/active-documentviewer_plucker.desktop
./kde4/active-documentviewer_tiff.desktop
./kde4/active-documentviewer_txt.desktop
./kde4/active-documentviewer_xps.desktop
./textmaker-free.desktop
./planmaker-free.desktop
./presentations-free.desktop
./gtk-recordmydesktop.desktop
./yast2-metapackage-handler-ymu.desktop
./yast2-metapackage-handler.desktop
./claudia-launcher.desktop
./projectM-jack.desktop
./git-gui.desktop
./simple-scan.desktop
./vivaldi-stable.desktop
./lxqt-config-powermanagement.desktop
./lxqt-config-session.desktop
./lxqt-hibernate.desktop
./lxqt-leave.desktop
./lxqt-lockscreen.desktop
./lxqt-logout.desktop
./lxqt-reboot.desktop
./lxqt-shutdown.desktop
./lxqt-suspend.desktop
./lxqt-config-notificationd.desktop
./lxqt-about.desktop
./lxqt-config-appearance.desktop
./lxqt-config-brightness.desktop
./lxqt-config-file-associations.desktop
./lxqt-config-input.desktop
./lxqt-config-locale.desktop
./lxqt-config-monitor.desktop
./lxqt-config.desktop
./lxqt-config-globalkeyshortcuts.desktop
./pcmanfm-qt-desktop-pref.desktop
./pcmanfm-qt.desktop
./chromium-bsu.desktop
./gnome-mimeapps.list
./pavucontrol-qt.desktop
./notification-daemon.desktop
./gnome-calculator.desktop
./geoclue-where-am-i.desktop
./gpk-prefs.desktop
./bluetooth-sendto.desktop
./uget-gtk.desktop
./gcr-prompter.desktop
./mount-archive.desktop
./nautilus-autorun-software.desktop
./nautilus-classic.desktop
./gcm-calibrate.desktop
./gcm-import.desktop
./gcm-picker.desktop
./gcr-viewer.desktop
./lximage-qt-screenshot.desktop
./lximage-qt.desktop
./ibus-setup.desktop
./xscreensaver-properties.desktop
./exo-file-manager.desktop
./exo-mail-reader.desktop
./exo-preferred-applications.desktop
./exo-terminal-emulator.desktop
./exo-web-browser.desktop
./itweb-settings.desktop
./xfce4-power-manager-settings.desktop
./xfce4-about.desktop
./xfce4-screenshooter.desktop
./claws-mail.desktop
./system-config-printer.desktop
./gnome-background-panel.desktop
./gnome-bluetooth-panel.desktop
./gnome-control-center.desktop
./gnome-datetime-panel.desktop
./gnome-display-panel.desktop
./gnome-info-panel.desktop
./gnome-keyboard-panel.desktop
./gnome-mouse-panel.desktop
./gnome-network-panel.desktop
./gnome-notifications-panel.desktop
./gnome-power-panel.desktop
./gnome-printers-panel.desktop
./gnome-privacy-panel.desktop
./gnome-region-panel.desktop
./gnome-search-panel.desktop
./gnome-sharing-panel.desktop
./gnome-sound-panel.desktop
./gnome-universal-access-panel.desktop
./gnome-user-accounts-panel.desktop
./gnome-wacom-panel.desktop
./gnome-online-accounts-panel.desktop
./gnome-color-panel.desktop
./gnome-shell-extension-prefs.desktop
./evolution-calendar.desktop
./chromium-browser.desktop
./org.kde.krusader.root-mode.desktop
./yast2-packager.desktop
./audio-assistant.desktop
./gtk3-icon-browser.desktop
./gtk3-demo.desktop
./gtk3-widget-factory.desktop
./gkbd-keyboard-display.desktop
./nm-connection-editor.desktop
./nm-applet.desktop
./vivaldi-snapshot.desktop
Comment 5 Rex Dieter 2016-11-07 16:39:50 UTC
According to the xdg specs (and my understanding), use of the vendor prefix means that

foo/bar.desktop
foo-bar.desktop

should be treated as equivalent.  This code probably should too.
Comment 6 Rex Dieter 2016-11-07 16:41:02 UTC
Sorry, so .... in short , use of - in filenames *should* be ok (and allowed)
Comment 7 Simon Lees (SUSE) 2016-11-08 03:14:07 UTC
Ok i'll patch desktop_file_to_binary to search for /usr/share/applications/foo-bar.desktop after its searched for /usr/share/applications/foo/bar.desktop (As an example)
Comment 8 Simon Lees (SUSE) 2016-11-09 23:56:21 UTC
Turns out the issue I was seeing was a regression in my fix for https://bugs.freedesktop.org/show_bug.cgi?id=44163 that never got upstreamed, i'll leave this ticket open as the kde patch is separate to this.
Comment 9 Rex Dieter 2017-02-28 15:07:04 UTC
fyi, applied fixes from bug #44163 now, any news/update here?
Comment 10 GitLab Migration User 2019-02-16 13:38:07 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/99.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.