简体   繁体   English

如何在XFCE中双击运行.sh文件?

[英]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.我已经使用chmod +x filename.sh使它可执行,但它不会运行。

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确保你有正确的#!/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在终端运行: 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.最后一步是 xfce 的不同之处。 Thunar (The xfce file manager) doesn't by default have this setting so you need to add it yourself. Thunar(xfce 文件管理器)默认没有这个设置,所以你需要自己添加。

If you are more comfortable in a gui: do steps 1-2 above, then:如果您更喜欢使用 gui:执行上面的步骤 1-2,那么:

1)get into xfce4-settings-editor (You can find it by searching with alt+F2) 1)进入xfce4-settings-editor(你可以通过alt+F2搜索找到它)

2)click thunar on the menu in the right 2)点击右侧菜单中的thunar

3)hit "new", set the type to boolean set to true and the property to /misc-exec-shell-scripts-by-default 3)点击“new”,将类型设置为布尔值,设置为true,将属性设置为/misc-exec-shell-scripts-by-default

either way make sure you don't have a file manager/thunar window open无论哪种方式,请确保您没有打开文件管理器/thunar 窗口

If you want to read more about these "Hidden settings" in thunar, check out the docs!如果您想在 thunar 中阅读有关这些“隐藏设置”的更多信息,请查看文档! https://docs.xfce.org/xfce/thunar/hidden-settings https://docs.xfce.org/xfce/thunar/hidden-settings

You need to add a shebang to your script.您需要在脚本中添加一个shebang。 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.这就是我需要做的所有事情,就像你提到的那样,从 Thunar 双击使脚本工作。

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..."通过右键单击可执行文件解决问题,然后“打开方式”->“使用其他应用程序打开”,在“使用自定义命令”中写入“/bin/sh”并选中“作为默认值使用...”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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