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

Post tutorials, HOWTO's and other useful resources here.
rych
Warlord
Warlord
Posts: 681
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: 4040
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: 681
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: 4040
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: 681
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: 678
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.
You have mind and feelings. Be wise and clever.

rych
Warlord
Warlord
Posts: 681
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: 4040
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: 681
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: 681
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: 8484
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.
Ed

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 4040
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

Post Reply