Score:1

How do I add my script and desktop file so it's configurable as a preferred application?

cn flag

I'm trying to set up a URL router script that looks at urls and opens them with a different browser instance (firefox profile in my case) depending on the result of pattern matching performed against the url.

I've made myself a desktop file, and installed it with desktop-file-install (details below). I'd expect that it should be visible in the main menu, and as an option when running cinnamon-settings default (which appears "Preferred Applications" in the main menu. Neither of these things happens.

cinnamon-settings default, update-alternatives and xdg-settings each has it's own list of options. My script doesn't appear in any of them. Which ones matter? How do I registered my script or desktop file as an available alternative for use by these systems?

My Desktop file:

[Desktop Entry]
Type=Application
Name=Url Router
Comment=Route to browser instances based on URL
# TryExec=url-router
Exec=url-router %u
# X-MultipleArgs=false
StartupNotify=true
Terminal=false
NoDisplay=true
MimeType=x-scheme-handler/http;x-scheme-handler/https
Icon=firefox
Categories=Network;WebBrowser;
# StartupWMClass=Firefox-esr

... which I've installed like so:

    desktop-file-install --dir=$HOME/.local/share/applications/ \
      --mode=755 \
      --rebuild-mime-info-cache \
      url-router.desktop
guiverc avatar
cn flag
Please provide OS & release details
vanadium avatar
cn flag
`NoDisplay=true` will cause the launcher *not* to be shown in the main menu, so you should not expect that.
Score:0
cn flag

It seems that the problem was that url-router is in my ~/bin folder, but when launching desktop files, that isn't in my $PATH, which I set from .bashrc.

Also, @vanadium's comment about NoDisplay=true is important for display in the Main Menu, though not for the Preferred Applications, which was my main concern.

vanadium avatar
cn flag
How does that answer the question on how to include the launcher in the drop down of "Preferred applications"?
cn flag
@vanadium `url-router` appeared there when I entered a full path into Exec in the desktop file.
cn flag
@vanadium rebuildingthe mime info cache is presumably also an important step, but I was already doing that with an option to `desktop-file-install`
vanadium avatar
cn flag
Thank makes a lot of sense. It would be fine to include this background in your answer to clarify everything for future users.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.