创建一个新的桌面文件来执行 Python 脚本,你可以按照以下步骤进行操作:
首先,在你的 ~/.local/share/applications/ 目录下创建一个新的桌面文件,比如 python.desktop。
使用文本编辑器打开这个文件,并输入以下内容:
[Desktop Entry]
Name= Python
Comment=Run Python script
Exec=gnome-terminal -- /usr/bin/python3 %f
Terminal=true
Type=Application
Icon=/var/lib/swcatalog/icons/ubuntu-plucky-backports-main/48x48/python.png
Categories=Development;
MimeType=text/x-python;
在上述的桌面文件中,我们使用 gnome-terminal 来打开一个终端窗口,并在其中执行 Python 脚本。/usr/bin/python3 %f 中的 %f 表示当前选中的文件。
保存文件并关闭文本编辑器。
更新图标缓存
update-desktop-database ~/.local/share/applications/