11

I am trying to make a script file. Everything works fine, but it only starts from the terminal.

I already made it executable using chmod +x filename.sh, but it won't run.

I saw a solution:

xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default \ 
             --create --type bool --set true '

But even this doesn't work.

lmcanavals
  • 2,339
  • 1
  • 24
  • 35
Seymour B
  • 123
  • 1
  • 5
  • double clicking where in xfce, in thunar ? – ctac_ May 21 '19 at 17:06
  • Yes, for example in Documents, Pictures, and so on. – Seymour B May 21 '19 at 17:16
  • You must tell more. What do you want to do ? What is you script ? [ask] – ctac_ May 21 '19 at 17:46
  • Nothing big, just a file that executes "sudo service network-manager restart" (I have #!/bin/bash at the top) . The computer has a wireless adapter problem (randomly disconnecting from Wi-Fi and it works again only by restarting the network-manager), and the user isn't familiar with command prompt usage, so I decided to make this script. Every time it disconnects, the user will double click it to resolve the problem. – Seymour B May 21 '19 at 18:38
  • There is nothing to do with thunar. Try to add it in the application menu. – ctac_ May 21 '19 at 19:34
  • A simple script with `#!/bin/bash notify-send foo` works for me (Thunar 1.8.6). And yes, `misc-exec-shell-scripts-by-default` is enabled here. Try to run thunar from terminal (first finish the daemon with `thunar -q`) and watch for error messages. – AndreLDM Jun 06 '19 at 17:30
  • Thanks, everything mentioned helped! – Seymour B Jun 09 '19 at 16:15

3 Answers3

9

Ran into the same problem tonight, took a lot of digging but I got it! (on mobile so formatting might be wack)

  1. make sure you have the proper #!/bin/bash/ shebang

  2. right click file-> permissions-> check "allow to run as program"

  3. in terminal run: xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true

this last step is what makes the difference in xfce. Thunar (The xfce file manager) doesn't by default have this setting so you need to add it yourself.

If you are more comfortable in a gui: do steps 1-2 above, then:

1)get into xfce4-settings-editor (You can find it by searching with alt+F2)

2)click thunar on the menu in the right

3)hit "new", set the type to boolean set to true and the property to /misc-exec-shell-scripts-by-default

either way make sure you don't have a file manager/thunar window open

If you want to read more about these "Hidden settings" in thunar, check out the docs! https://docs.xfce.org/xfce/thunar/hidden-settings

Spatrico
  • 129
  • 2
  • 10
2

Resolved problem by right-click on executable file, then "open with" -> "open with other application", in "Use a custom command" wrote "/bin/sh" and check "Use as default..."

0

You need to add a shebang to your script. The first line should be something line this

#!/bin/bash

That is all I needed to do to make a script work with double click from Thunar like you mentioned.

lmcanavals
  • 2,339
  • 1
  • 24
  • 35