登录到raspberry pi中的桌面窗口后如何自动运行GUI脚本


0

我正在使用raspberry pi 3,我用两个按钮和一个图像制作了gui脚本,如果我们使用命令运行它运行良好:

sudo python
sudo python gui.py

但我想登录到raspberry pi桌面窗口后自动运行这个gui脚本。我不知道怎么做?请回复。提前致谢。

Answers:


1

在主目录文件夹中创建 ~/.config/autostart 通过运行以下命令:

mkdir -p ~/.config/autostart

并在此目录中创建文本文件 mygui.desktop

touch ~/.config/autostart/mygui.desktop

然后添加到您的程序的此文件描述,类似这样

[Desktop Entry]
Name=MyGUI
Exec=/usr/bin/python gui.py
Type=Application
Hidden=false

更多关于创造 .desktop 文件 这里

如果你真的需要运行GUI程序 root (???)那么你需要使用桌面替换 sudo, 它是 gksu

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.