Comments on How do I tweak the start parameters of GUI apps?
Parent
How do I tweak the start parameters of GUI apps?
There are many GUI apps on my computer that show up as eg. items in the start menu. When I launch these, what if I want to control how exactly they are launched, such as setting environment variables or adding additional parameters?
For example, I can of course type SOME_ENVAR=foo gedit --some-argument
in the console. But I don't normally launch gedit from the console, I click on its menu item or it opens automatically when I double click on text files.
Post
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
matthewsnyder | (no comment) | Sep 8, 2023 at 21:34 |
tl;dr:
-
Find the
.desktop
file that you are currently running - It is probably in a system location, so copy it to a user location
- Modify the file contents
The normal way to create icons for GUI apps on Linux is to create .desktop
files. These are files describing the shell-style command used to start the program, any additional parameters (such as command line arguments and environment variables specific to the program) as well as some metadata (such as a description, localized names, the actual icon of the program) that graphical desktop environments can use to display icons for the program in their GUI.
Generally speaking, if you create a correct .desktop
file in the correct location, the program will show up in the various GUI menus, and when you click it it will run whatever you put under Exec
. The easiest way to create a "correct" file is to copy an existing working one and modify it. There are many "locations" that these files can go in, but the important distinction is system vs. user files (aka "entries"):
- System entries will affect all users on that computer. You will typically need
sudo
to edit them. They are usually put there by the package manager, so if you edit the system file and also later update the package and the upstream modifies the.desktop
file, there will be a conflict between changes you made and the new version from upstream. Your package manager will have to resolve this conflict somehow, but it's always much easier to avoid the conflict to begin with and instead edit the user file. - User entries will be under you home directory (
~
) in locations such as~/.local/share/applications/
. If the same program has both a system and a user entry, the user entry will override the system one. Packages do not normally put stuff in~/.local/share/applications
(although the programs themselves might, when run) so this is a safer place to put modified files. You can start by copying the system file to the user location and modifying from there. User files will only apply to you, other users will not see entries you put there.
For details, see:
- https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
- https://wiki.archlinux.org/title/Desktop_entries
1 comment thread