Running Scripts from the Linux GUI: A Beginner’s Guide
To run a script without having to open a terminal and type the command manually you need to create a GUI shortcut for the script. The GUI shortcuts are created using .desktop
files.
.desktop
files are a standard way of creating GUI shortcuts in these desktop environments.
Locating .destop files
.destop
config files can be found at the following paths:
- default applications: /usr/share/applications/
- Third party applications: /usr/local/share/applications/
- User specific applications: ~/.local/share/applications/
Creating a shell script
xdg-open 'https://app.slack.com/client/TV310986N/C02K2HJ249'
xdg-open 'https://housekeeping.comp.com/housekeeping/'
xdg-open 'https://webmail.comp.com/zimbra/#1'
xdg-open 'https://comp.atlassian.net/jira/software/c/projects/WBT/boards/75'
xdg-open 'https://docs.google.com/document/u/0/?tgff=d'
The above shell script opens my commonly used URLs in the default browser.
Creating the config file
Open the config files folder.
cd ~/.local/share/applications/
In our case, we will create a file in the user-specific applications folder.
vi work.desktop
add the below configs
[Desktop Entry]
Terminal=false
Type=Application
Name=Work
Exec=/home/badal/work.sh
Icon=/home/badal/Downloads/work.jpg
Name
specifies the application's name.
Exec
specifies the command to run when the application is launched.
Icon
specifies the path to the icon file associated with the application.
Terminal
indicates whether the application should be run in a terminal window. If set to true, the application will be launched in a terminal otherwise, it will run in the background.
Type
parameter specifies the type of the entry. It can be specified as ‘Application’, ‘Link’, ‘Directory’, ‘Service’.
You can also add some other below params
StartupNotify
determines whether the desktop environment should show a startup notification for the application.
Comment
allows you to provide a description or additional information about the application.
Save and exit the file. This will add a shortcut to your Applications Menu.
On clicking it opens all the mentioned URLs in the default browser
Add this to your dock to easily access it.