.desktop files with [Desktop Entry]: MimeType etc.

Post tutorials, HOWTO's and other useful resources here.
rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#1 by rych » 19 Sep 2022, 10:59

We sometimes need to make a .desktop file to integrate an App into a Start menu and so on. Or, to edit an existing one.

For example, right now I'm trying to make VLC player to open a whole folder by editing the /usr/share/applications/vlc.desktop I've prepended a inode/directory; on the appropriate (?) line as follows:

Code: Select all

MimeType=inode/directory;application/ogg...
However VLC does not show in the right click context menu in SpaceFM for a folder. Interestingly, the "mpv Media Player" is there, yet if we look at the mpv.desktop there is no mentioning of the word "directory" -- it's a mystery how it appears in the list then.

Once I figure this out (help appreciated) I'll add the instruction here and it'd make a nice "tutorial" :)

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4290
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#2 by ncmprhnsbl » 19 Sep 2022, 12:00

rych wrote:
19 Sep 2022, 10:59
However VLC does not show in the right click context menu in SpaceFM for a folder. Interestingly, the "mpv Media Player" is there, yet if we look at the mpv.desktop there is no mentioning of the word "directory" -- it's a mystery how it appears in the list then.
couple of things: after editing a /usr/share/applications/*.desktop, run (as root) update-desktop-database to update /usr/share/applications/mimeinfo.cache

alternatively, take a look at ~/.config/mimeapps.list ..for openbox/spacefm, it looks like this:

Code: Select all

[Default Applications]
inode/directory=spacefm.desktop;mpv.desktop;pcmanfm-create-module.desktop;pcmanfm-create-zstd-module.desktop;

[Added Associations]
inode/directory=spacefm.desktop;mpv.desktop;pcmanfm-create-module.desktop;pcmanfm-create-zstd-module.desktop;
adding vlc.desktop should work , as presumably it works for mpv.. this can be done from spacefm's rclick menu too under Open with>choose(or smthing like) ...other filemanagers are similar.. give or take.. sometimes under properties..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#3 by rych » 20 Sep 2022, 09:08

ncmprhnsbl wrote:
19 Sep 2022, 12:00
couple of things
Fantastic. It actually appeared after reboot -- but no need, as we can update-desktop-database. (I tried running update-mime-database /root/.local/share/mime; update-mime-database /usr/share/mime without success before)
ncmprhnsbl wrote:
19 Sep 2022, 12:00
alternatively, take a look at ~/.config/mimeapps.list
-- an interesting alternative, right now vlc.desktop doesn't appear there, indeed it seems to be a separate special list and explains why mpv.desktop has been included for folders without claiming the corresponding MimeType (exactly inode/directory and not x-directory/normal or anything else) inherently.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4290
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#4 by ncmprhnsbl » 20 Sep 2022, 10:10

rych wrote:
20 Sep 2022, 09:08
Fantastic. It actually appeared after reboot -- but no need, as we can update-desktop-database.
yeah, update-desktop-database also gets run when activating(and deactivating) modules too..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#5 by rych » 11 Jun 2024, 12:33

ncmprhnsbl, I think I need your help again about this topic please

When in SpaceFm, under root, I double-click on a binary executable ( application/x-executable ), or a shell script ( application/x-shellscript )... it prompts me to choose an Application or Command from a list. That list doesn't simply doesn't contain the Execute command so can't set it as a default for these files from now on

I have to right-click and choose the first entry from the context menu which is precisely the Execute command I want with the 2 cogs icon -- and it runs.

How do I make that a default action on a double-click?


I've looked at
ncmprhnsbl wrote:
19 Sep 2022, 12:00
take a look at ~/.config/mimeapps.list ..for openbox/spacefm
but it does not mention any application/x-executable or application/x-shellscript

Perhaps, such a convenience is forbidden for root?!

tome
Contributor
Contributor
Posts: 686
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#6 by tome » 11 Jun 2024, 16:15

hello rych, add executable permissions to these files.

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#7 by rych » 12 Jun 2024, 10:34

tome wrote:
11 Jun 2024, 16:15
executable permissions
are already set of course. That's what I mean by
rych wrote:
11 Jun 2024, 12:33
and it runs
-- eventually runs when I choose the "Execute" entry from the context menu. In fact, I've just removed the "executable permissions" from the file, and now the entry "Execute" isn't even in the context menu. So, SpaceFM does recognize the file as executable. It just doesn't offer a way to set "Execute" as a default action. For years now I've had to right clikc and choose "Execute" from there, and I'm tired of this extra step. Want to just run on a double-click, would be more natural.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4290
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#8 by ncmprhnsbl » 14 Jun 2024, 01:33

rych wrote:
12 Jun 2024, 10:34
It just doesn't offer a way to set "Execute" as a default action.
:D > spacefm > view > preferences > interface > "clicks run executable" > :tick:
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#9 by rych » 14 Jun 2024, 10:17

ncmprhnsbl wrote:
14 Jun 2024, 01:33
> spacefm > view > preferences > interface > "clicks run executable" > :tick:
Wow! So simple and so ...GUI, indeed other File managers were actually working, and now with that tick SpaceFm does too. Thanks :) (Maybe I'm getting old)

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#10 by rych » 14 Jul 2024, 07:39

Another issue about .desktop files is that SpaceFM and probably some other FMs don't know how to handle Type=Link .desktop files (anymore?)

For example, make a simple google.desktop file as follows:
[Desktop Entry]
Encoding=UTF-8
Icon=text-html
Type=Link
Name=Google
URL=https://www.google.com
Double click and instead of bringing up the browser and opening the URL, it says:
Error: Command not found
That's a standard way to make url file links and it used to work in the past. I have Firefox extensions creating links of that type. SpaceFM is just expected to:

Code: Select all

xdg-open https://www.google.com
Why not?

Same error if one wanted to make local Windows-style shortcut with the Type=Link .desktop file with a URL=file:///home. Nope. I could only make it work to explicitly include Exec filed. So, if we want to jump to /home folder, the only way so far is to make a home.desktop file as follows:
[Desktop Entry]
Exec=xdg-open /home
Icon=emblem-symbolic-link
On double-click SpaceFM opens that folder in a new tab. But I wish it understood Type=Link .desktop shortcuts, both local and internet.

User avatar
Ed_P
Contributor
Contributor
Posts: 8956
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

.desktop files with [Desktop Entry]: MimeType etc.

Post#11 by Ed_P » 14 Jul 2024, 14:53

Apparently Link is not a valid Porteus category, use Type=Application.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4290
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#12 by ncmprhnsbl » 15 Jul 2024, 01:19

yeah, according to this, (although it seems to be incomplete) https://wiki.archlinux.org/title/Desktop_entries#Usage only kde plasma supports Type=Link
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#13 by rych » 16 Apr 2025, 12:16

ncmprhnsbl, once again I need your expert advice. I use Obsidian (AppImage) and when asked to open files or folders in external default system Apps, it either opens wrong Apps or does nothing. I'm reporting it at the Obsidian community but there no answer from them: https://forum.obsidian.md/t/open-in-sys ... es-vscode/ :

Code: Select all

oot@porteus:~# xdg-mime query default inode/directory
spacefm.desktop
root@porteus:~# /I/Obsidian.AppImage --no-sandbox
Setting $HOME to /I/Obsidian.AppImage.home
Setting $XDG_CONFIG_HOME to /I/Obsidian.AppImage.config
2025-04-14 12:15:37 Loading main app package /tmp/.mount_Obsidi4WLtOM/resources/obsidian.asar
[5230:0415/001538.202733:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.StartServiceByName: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.portal.Desktop exited with status 127
MESA-INTEL: warning: Haswell Vulkan support is incomplete
2025-04-14 12:15:38 Checking for update using Github
libva error: /usr/lib64/dri/iHD_drv_video.so init failed
2025-04-14 12:15:38 Success.
2025-04-14 12:15:38 Latest version is 1.8.9
2025-04-14 12:15:38 App is up to date.
[5230:0415/001541.338416:ERROR:atom_cache.cc(229)] Add WM_CHANGE_STATE to kAtomsToCache
[5230:0415/001635.935695:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.portal.OpenURI.OpenDirectory: object_path= /org/freedesktop/portal/desktop: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.portal.Desktop exited with status 127
[5230:0415/001635.935710:ERROR:platform_util_linux.cc(242)] Error calling OpenDirectory
[5504:0415/001636.496723:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.StartServiceByName: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.portal.Desktop exited with status 127
Warning: 'unity-launch' is not in the list of known options, but still passed to Electron/Chromium.
This behavior of Obsidian maybe exposing some unorthodox ways of (my setup of) Porteus. For example, right clicking on a pdf file in the vault, “Open in default app” opens it in Xournal++. Granted, it can display PDFs and maybe once I set it up as a default, but now I have other pdf viewers as default. And so on. The funniest external App being launched by Obsidian is VS Code as a "System explorer" :) Maybe because VS Code and Obsidian use the same chromium/Electron or whatever.

All this only if you use Obsidian yourself -- if not maybe it's too irrelevant for you to take a look.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4290
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#14 by ncmprhnsbl » 18 Apr 2025, 01:45

rych wrote:
16 Apr 2025, 12:16
your expert advice.
:D not sure i have any of that
so.. obsidian i haven't used (maybe i should, to be better organized), but from a quick look, i see some possible issues...
1. being an electron app ; 2. also being an appimage ...one of or both of those relying on xdg-desktop-portal to do the dbus/xdg stuff to connect with the system..
and with appimages, sometimes relying on some peculiarity of the build host (generally ubuntu)
what might be interesting, would be to see how it behaves in a "proper desktop environment" like gnome or plasma (or even cinnamon or xfce4)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

.desktop files with [Desktop Entry]: MimeType etc.

Post#15 by rych » 19 Apr 2025, 11:32

ncmprhnsbl, Thanks, indeed the solution is to use their .deb package, and NOT the .AppImage: now Obsidian correctly opens external system default apps.

Post Reply