Setting command line options for .desktop files

Is there any documentation / guidance on how to customize .desktop files bundled into a snap?

For example with chromium I need to add the --proxy-pac-url argument to all Exec= lines in /snap/chromium/current/usr/share/applications/chromium.desktop.

You can’t just edit those file directly as the snaps are mounted readonly.

I’ve set the environment variables for http_proxy & https_proxy & auto_proxy (both lowercase and uppercase variants), and confirmed that they are shown if I run snap run --shell chromium and list the current environment variables (env), but chromium appears to ignore them.

I can get chromium to correctly run via chromium --proxy-pac-url=file:///etc/proxy.pac, so i just need to find a way to amend the desktop files accordingly.

I’ve read that you can override desktop files by placing amended copies in ~/.local/share/applications and running update-desktop-database ~/.local/share/applications, but now I have two icons in the launcher (one for the default, and another for the amended version, rather than overriding the original). Obviously I could amend the Name= for the amended version, but it’s still not ideal.

I suspect that the problem with the duplication is because you started with /snap/chromium/current/usr/share/applications/chromium.desktop, which is not the desktop file that is installed. Look instead at /var/lib/snapd/desktop/applications/chromium_chromium.desktop. Starting with that file, copying it to ~/.local/share/applications, editing it, and running update-desktop-database results in only one chromium app.

(Don’t just edit the file in /var/lib/snapd: it will get rewritten every time the snap is refreshed).

1 Like

@chipaca - That worked, thanks!

1 Like