2

Before, I was using Linux Mint and I can run bash script directly from desktop just with chmod the script to executable. For example, I have a script like this:

#!/bin/bash
VBoxSDL --startvm virtualmachine

then:

chmod +x myscript

In desktop. I just need to double click the script that I've created.

Now, I'm using Arch Linux with gnome-shell. The same way doesn't work. Instead, double clicking only runs text editor. Right click, too, show only gvim editor to launch the script and open with other applications option which doesn't have run script directly. So, how can I launch the script directly from desktop environtment without terminal?

3
  • You probably need to have an entry in your right click context menu that runs the script. In XFCE that is fairly easy, you just create an action, but I don't know about GNOME.
    – TomTom
    Apr 28, 2015 at 13:41
  • 2
    This has nothing to do with gnome-shell or your text editor (or archlinux), it's a file manager feature. In nautilus Preferences > Behavior > check Run executable text files when they are opened. Apr 28, 2015 at 14:19
  • If you're using GNOME 3, see the solutions on this question: askubuntu.com/questions/138908/…
    – Matthias
    Jun 18, 2019 at 16:03

2 Answers 2

4

If that isn't working then you can create a .desktop file for your script. It would look something like this:

# $Id: vbox-starter.desktop 22 $
[Desktop Entry]
Name=Custom Virtualbox Starter
GenericName=VBox
Comment=VBox
Exec=VBoxSDL --startvm virtualmachine
Terminal=true
Type=Application
Icon=Virtualbox
Categories=GNOME;GTK;Utility;

Note that since your script contains only one single line, you can put that directly in the Exec value:

Exec=VBoxSDL --startvm virtualmachine

In case you, your script was very long with multiple lines of code, then just put it this way:

Exec=~/Desktop/myscript
6
  • But, what I'm asking is about launching script, not desktop entry.
    – Mas Bagol
    Apr 28, 2015 at 14:03
  • Perhaps Arch Linux doesn't support running scripts by double clicking. I don't really know. Never used it. But this solution does solve your problem. Moreover, your script is just one line of code, you can just put it in Exec part above.
    – shivams
    Apr 28, 2015 at 14:06
  • Which windows manager and desktop manager are you running, btw?
    – shivams
    Apr 28, 2015 at 14:12
  • gdm and gnome3
    – Mas Bagol
    Apr 28, 2015 at 14:20
  • Well, did this solution work for you? : askubuntu.com/questions/138908/…
    – shivams
    Apr 28, 2015 at 14:23
0

Looks like the text editor thinks that any file without an extension is a text file for it to open. Try to rename it, say myscript.sh and see if that works.

1
  • doesn't work. I've tried that
    – Mas Bagol
    Apr 28, 2015 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .