Running a bash script from a .desktop file -- desktop icon appearing next to plank dock

Clem_Dye

New Member
Joined
Feb 1, 2026
Messages
4
Reaction score
2
Credits
53
Hi, new forum member here, so apologies if this topic has been covered before.

I want to run a bash script using a .desktop file. To that end, I have been doing some testing and the following test .desktop file works intended:

----- begin -----
[Desktop Entry]
Type=Application
StartupWMClass=Test
Name=Test
Name[en_GB]=Test
GenericName=Test
Comment=Launcher for test bash script.
Icon=/home/clem/Temp/Backup/Icons/external-disk.png
Exec=gnome-terminal --title="Test" -- bash -c '/home/clem/Temp/Backup/Xtest_script.sh dummy-arg;read -p "Press the return key"' --class=Test
Terminal=false
Category=Utility
----- end -----

The script runs as intended, but when it's running I see there terminal window and the associated icon to the right of the entries in my plank dock. If I click that icon it launches a second instance of the script.

I believe that my .desktop file entries are correct, based on what I've read, so the questions are:

1) Is this normal behaviour, in that the icon can't be hidden when running a bash script?
2) If not, how do I hide the icon whilst the script is running please?

The test bash test script is this:

----- begin -----
#!/bin/bash

echo "Hello!"

if [ $# -gt 0 ]; then
echo "Argument #1: $1"
else
echo "No arguments"
fi

echo "Bye!"

sleep 5

exit
----- end -----

The class= option is shown in gnome-terminal --help-gtk, so I think that I'm using the correct option to link everything together. Does what I'm trying to do only work with applications, and not shell scripts?

My goal is to run my rsync backup scripts from the desktop, rather than a terminal, so it's just a case of substituting the correct script in the .desktop file and making the entries more meaningful. I can add code to my scripts to prevent duplicate execution, but I'd still like to be able to not see the icon next to the plank dock if possible.

Cheers.
 


Follow Linux.org

Members online


Top