How do I add a shortcut to run a program to my DE?
My DE has a bunch of programs in the start/applications menu. How can I add my own in there? For example, say I found a terminal command foo --bar --baz
that does something I want. But I don't want to run it from the terminal every time, I want to make a shortcut that I can click on.
1 answer
On Linux, the basic way to run every program is to invoke it through a terminal.
The shortcuts in DEs come from ".desktop" files. On a Linux system, there are a couple of directories (system wide, per user, ...) for these files. If you put a file in these directories, with the extension .desktop
, and the correct syntax inside, a new shortcut will show up.
Briefly, .desktop
files will have an Exec
field which is the terminal-style command that will be executed when you click the shortcut. This is the most important part. The rest is explained in https://wiki.archlinux.org/title/Desktop_entries and other places. However, I think the easier thing is to find another shortcut, copy it, and edit the parts you want rather than starting from scratch.
IMO the best place to put your own .desktop files is ~/.local/share/applications/
. This way you won't need sudo and when you backup your home dir, the shortcuts will also be backed up.
Another option is to create a shell script (normally with .sh
extension) by putting something like #!/bin/bash
on the first line (so that the OS knows it's a script) and the command below. You then have to make the script executable (chmod +x my_script.sh
or right click/properties). After this, if you double click on the script in your file manager, it should launch just like any other program. This way you don't have to create a desktop file.
0 comment threads