在同一窗口中打开终端(Ubuntu)

我遇到问题。我想创建一个.desktop可执行文件,它将在终端中执行一个命令。我使用了下面的代码。在同一窗口中打开终端(Ubuntu)

[Desktop Entry] 

Version=1.0

Type=Application

Terminal=true

Exec=python2 ./main.py

Name=Air Hockey

Comment=This runs Air Hockey in one click

Icon=./logo.png

用此代码打开的终端具有默认目录,因为它的地址。我想在执行此(.desktop)文件的目录中启动它。

我试过使用%k,但它被证明是不好的。

回答:

%k返回带有路径的桌面文件的名称。

假设main.py是你的脚本

的名字你可以试试:

Exec=python2 $(dirname %k)/main.py 

希望这有助于。

回答:

下面的命令用于删除目录名称中的空格。

Exec=bash -c 'cd $(dirname %k) && python2 main.py' 

参考:https://askubuntu.com/questions/47775/how-can-i-set-the-path-variable-in-a-desktop-file-to-be-relative-to-the-locat

以上是 在同一窗口中打开终端(Ubuntu) 的全部内容, 来源链接: utcz.com/qa/257875.html

回到顶部