Shell脚本桌面快捷方式
所以我尝试制作一个桌面快捷方式,它执行一个非常简单的shell脚本。 但是,当我双击/右键单击 – >执行它时,它什么都不做。 (或者至少我认为它什么都不做)
inheritance人我的快捷方式和shell脚本看起来如何:注意快捷方式将“终端”设置为1,我希望这意味着它在新的终端窗口中打开shell脚本..(我已经打开了几个终端,它们还没有准备好用法(运行脚本))
捷径:
[Desktop Entry] Version=1.0 Type=Application Name=Test Comment=Test Exec=/home/(myusername)/test/test.sh Icon=utilities-terminal Terminal=true StartupNotify=false GenericName=Test
Shell脚本:
#!/bin/sh # (I tried both, /bin/bash and /bin/sh) echo "hi"
桌面条目和shell脚本都应具有可执行权限。 做:
$ chmod +x path_to_shortcut/shortcut.desktop $ chmod +x path_to_script/test.sh
更改脚本权限的另一种方法是右键单击它,转到“ 属性”>“预置”,然后选中“ 允许将文件作为程序执行” 。
以防万一有人从谷歌搜索来到这里…在14.04,执行shell脚本后面的一个痛苦,在我安装的驱动器上为我启动Android Studio。 试了很多东西,但没有什么对我有用。 最终不得不写下面的代码并编译:
gcc -o studio studio.c
然后从桌面创建“studio”的快捷方式,现在它终于可以正常工作了。
下面是示例代码,您可以在/ bin / sh之后替换该系统调用中的路径(/media/…/studio.sh)。 确保它是一个完整的路径并在前面留下“/ bin / sh”。
#include int main(void) { int ret = system("/bin/sh /media/jeneag/APPS/linux/android-studio/bin/studio.sh"); printf("app ret code: %d\n", ret); return 0; }