I have a shell script that I need users to be able to run from a desktop shortcut. I’ve used this on Red Hat and Centos, but it doesn’t seem to work on Rocky 8.10.
I can run the script from a terminal and also from the Files GUI as root , but not the desktop shortcut. I set the permissions to 777 but in the Files GUI it shows read/write selections in the drop down, with the box is checked for "Allow executing file as a program. Is that how its supposed to be? Additionally, it doesn’t show my icon image either.
I’m not able the get anywhere with it while logged in as the user.
I just did a test of launching a bash script from a desktop icon as standard user.
In this case, the script will run in a terminal, so you can see it running.
This is the script
cat /data/dev/scripts/bash_test.sh
#!/bin/bash
set -u
for i in {1..3}; do
echo "Testing $i"
sleep 1.0s
done
This is the desktop shortcut
cat ~/Desktop/bash_test.desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Exec=/data/dev/scripts/bash_test.sh
Name=Bash Test
Comment=Bash Test Script
#Icon=/path/2/icon.png
Once the shortcut appears on the desktop, you have to right-click and “Allow Launch”, then double click to actually run the script.
This is all assuming your desktop is set up for icons in the first place, e.g. on my system I have gnome extension ‘gnome-shell-extension-desktop-icons.noarch’.
The .desktop is 777 and the contained Exec= target is 777. (They shouldn’t be, but I did this to eliminate any possible issue.
I copy and paste the shortcut from the install media.
The .desktop contains:
Name=
Exec=
Icon=
Type=
Terminal=true
Name
Also… I didn’t mention apparently… When I double-click the icon, it opens in Gedit.
Thanks… I did have an issue with prior as nothing appeared on the Desktop. I went to Activities/Software/Explore Tab/Add-ons/Shell extensions and turned on desktop icons. Does that do it?
Good Morning… I made a little progress by accident…
Trying a solution I found elsewhere, I was logged in as root, copied the .desktop file with a new name, added 3 lines to the script and tried launching and failed. However, right-clicking the new icon showed an option to “Allow Launching”. Enabling this gave me a successful launch.
The thing is, this option doesn’t appear on my original. After some investigation, I found that simply copying the file with a new name is what appears to have allowed the “Allow Launching” option to appear. I don’t think the lines I added had any effect.
Not out of the woods yet though. I tried this as a regular user and while the “Allow Launching” menu item did appear, the launch failed. A terminal window pops up and disappears really quick. There’s some red text but I cannot read it in time. Anyway, I think its still progress because at least its trying now and not opening in the editor.
Second issue is that the icon graphic isn’t showing on the desktop in either case. I only see the name on the desktop and I double-click the black space above it.