Create a .desktop file that opens and execute a command in a terminal
The content of your desktop file should look like (see how to create a .desktop file using a text editor):
[Desktop Entry]
Version=1.0
Name=Test
Comment=Test the terminal running a command inside it
Exec=gnome-terminal -e "bash -c 'echo hello;$SHELL'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;
Or:
[Desktop Entry]
Version=1.0
Name=Test
Comment=Test the terminal running a command inside it
Exec=bash -c 'echo hello;$SHELL'
Icon=utilities-terminal
Terminal=true
Type=Application
Categories=Application;
In the first case, the Terminal
field is set to false
(perhaps contrary to your expectations) and in second case is set to true
, but the result is in both cases the same.
Simply add
;$SHELL
at the end of your commands.
Like for me snapd
isn't something using full bandwidth of system to refresh snaps anytime almost I work at night.
So this worked for me to create a .sh
file linked to a .desktop
file.
Contents for .sh
file were
echo <your password> | sudo -S systemctl stop snapd.service
sudo systemctl disable snapd.service;$SHELL
-S
in the first line of the .sh
file is used to send STDINPUT
to the sudo
command meaning direct execute without entering password.
Contents for the .desktop
file were:
[Desktop Entry]
Version=1.0
Name=Test
Comment=Test the terminal running a command inside it
Exec=gnome-terminal -e "/scripts/disable_snap.sh"
Icon=terminal
Terminal=true
Type=Application
Categories=Application;
!#/bin/bash
gnome-terminal -e YOUR_COMMANDS
Make the above file. Don't forget to sudo chmod +x filename.sh