创建一个在终端中打开并执行命令的 .desktop 文件

Par*_*aub 47 command-line scripts .desktop

我想知道如何编写Exec.desktop 文件的命令来打开一个新终端并在其中执行一个 shell 脚本。shell 脚本正在运行,所有用户都可以访问。从终端启动脚本时一切正常,但在尝试从 .desktop 文件启动脚本时却没有。

以下是我已经尝试过的一些组合:

Exec=gnome-terminal -x sh -c 'echo hello'
Exec=sh -c 'gnome-terminal echo hello'
Exec=sh -c 'echo hello'
Exec=echo hello
Run Code Online (Sandbox Code Playgroud)

.desktop 终端选项设置为 true。

Rad*_*anu 56

桌面文件的内容应如下所示(请参阅如何使用文本编辑器创建 .desktop 文件):

[Desktop Entry]
Version=1.0
Name=Test        
Comment=Test the terminal running a command inside it
Exec=gnome-terminal -e "bash -c 'echo hello;$SHELL'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;
Run Code Online (Sandbox Code Playgroud)

或者:

[Desktop Entry]
Version=1.0
Name=Test        
Comment=Test the terminal running a command inside it
Exec=bash -c 'echo hello;$SHELL'
Icon=utilities-terminal
Terminal=true 
Type=Application
Categories=Application;
Run Code Online (Sandbox Code Playgroud)

在第一种情况下,该Terminal字段设置为false(可能与您的预期相反),在第二种情况下设置为true,但结果在两种情况下都相同。

  • 我认为问题是:如何确保终端出现,以便终端不会消失,以便我们可以输入凭据 (2认同)