简体   繁体   中英

How to run .sh file by double clicking in XFCE?

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.

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

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.

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..."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM