.desktop file does not appear in gnome-tweak list of apps - why?

Added a .desktop file to ~\.local\share\applications which exec’s a private script. The script runs fine when called from shell. Validated .desktop with desktop-file-validate, no errors.

Executing with gtk-launch gives the error
gtk-launch: no such application <.desktop filename>
(maybe different as I have German installed). Content of .desktop is below - what’s wrong?

And when that’s fixed, will it appear in the gnome-tweak startup application list?

[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Exec=“~/scripts/mount-backup”
Name=Mount USB Backup
Comment=Mount the backup file as nobis folder

I would start by fixing those quotes in the Exec line. Those aren’t double-quotes.

It is always a good idea to run desktop-file-validate against any .desktop you create or edit by hand. Interestingly, I do get errors when I run it against that text. Specifically, I get:

error: value ““~/scripts/mount-backup”” for key “Exec” in group “Desktop Entry” contains a reserved character ‘~’ outside of a quote

I would also consider using an absolute path instead of ~ but I don’t think that is required.

1 Like

Thanks for answering!

Those aren’t double-quotes.

In my emacs they are. Must have been converted when I copied them into this page. As I wrote, desktop-file-validate does not show an error on the original file (and yes, I got an error on an earlier version of the file without quotes).

I would also consider using an absolute path

I read that requirement somewhere else as well. Why is that? Considering this is a private script, I’d rather keep the reference to my home, should it be renamed/moved sometime.

I wonder why gtk-launch gives an error with the .desktop filename,
gtk-launch: no such application <.desktop filename>.

It should look for another file, ~/scripts/mount-backup, and complain about that file’s non-existence (if it really didn’t exist, but as I wrote, it executes fine)… shouldn’t it?

Danke & Grüße von
nobi

EDIT: Changing ~ to my home directory to turn it into an absolute path changes absolutely nothing (no pun intended ;-).

Running update-desktop-database ~/.local/share/applications also does not help.

When using a non-existent filename with gtk-launch, I get the same error - why would gtk-launch not find a file which has been completed by the shell? The .desktop file has -rw-r–r-- permissions for me. Does it have to be executable? (There’s no other file yet to copy from…)

It shouldn’t be required. If you look in /usr/share/applications you should see that many of them are not executable.

1 Like

For future use - if rather than blockquoting like this:

foo = “bar”

you instead use triple-backticks to make a code fence like this:

foo = "bar"

then it should avoid any conversion to curly quotes.

1 Like

Here

I read about $XDG_DATA_DIRS and $XDG_DATA_FILES. Neither of it contains ~/.local/share in my case. $XDG_DATA_FILES is empty.

Should I be worried about this?

That could be a result of copy-pasting when using the new rich text editor mode. That would cause regular quotes to be converted to curly quotes as the looks “nicer”. It may also copy double minus signs to m-dash character which looks like an extra long minus sign.

To avoid that, invoke the Preformatted Text Mode (</>) and copy the text into that.

On my system, they are all executable, either ELF binaries or shell scripts.

Try

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false

Icon=/home/USER/Pictures/IconsPNG/imagename
Exec=bash /home/USER/scripts/mount-backup
Name=Mount USB Backup
Comment=Mount the backup file as nobis folder

I created the the text file with code

echo “Hi”

For the Exec command, no quotes.

When Terminal is true, you are opening a terminal for display: no shell but will display output, in this case, HI.

For Name, since you used space, i named the file that way, therefore:

gtk-launch 'Mount USB Backup.desktop'

... or...

gtk-launch 'Mount USB Backup' 

Edit: Added icon to make visible in menu.

Thanks @ptrck4193 - and to all of you!

The problem was the Exec - adding bash makes or breaks the desktop shortcut. It won’t accept scripts as such, it seems.

If the Icon spec is wrong or missing, a generic icon is displayed (different ones for the desktop application list and the Gnome Tweaks startup program list :frowning:

Danke & Grüße von
nobi

I have scripts and bash in .desktop Exec (iirc it doesn’t pass desktop-file-validate):

Programs with flags:

Exec='/bin/bash' -c "WEBKIT_DISABLE_COMPOSITING_MODE='1' '/usr/libexec/libwebkit2gtk-4_1-0/MiniBrowser' --dark-mode --autoplay-policy 'allow' --private --features='-PreferPageRenderingUpdatesNear60FPS' 'http://localhost:8888/rs2.cgi'"

Scripts through GUI Terminals:

Exec='/bin/bash' -c "xfce4-terminal -T '2004Scape [Updater]' -I ~/'Projects/LostCity-225-EngineTS/ext/favicon.ico' -e ~/'Projects/LostCity-225-EngineTS/scripts/localhost-server-update.sh'"

And just scripts:

Exec='/bin/bash' -c "~/'Projects/LostCity-225-EngineTS/scripts/localhost-save-backup.sh'"

Basically I just tell bash to do everything in desktop launchers and it works GNOME/Plasma/Xfce any OS :smiley: