boot – 我的ubuntu-server在启动时不执行基于gtk的程序!
作者:互联网
我有Ubuntu-server 16.04.安装gtk3并可以通过以下命令手动执行我的程序:./img当我转到它的目录/ home / m.
但是当我尝试将此行添加到我的/etc/rc.local文件中时:
/home/m/img &
它没用.这是我的rc.local全部内容:
startx
/home/m/img &
exit 0
然后我尝试用这个内容创建〜/ .xinitrc文件:
#!/usr/bin/env bash
/home/m/img &
exec openbox-session
然后通过此命令使其可执行:
chmod x~ / .xinitrc
但我什么也没得到(即使它在重启后没有显示我的openbox),所以我也执行了这个命令:
ln -s ~/.xinitrc ~/.xsession
之后我的openbox回来了,但我的程序在启动后没有启动!或任何其他时间!
My goal is this: when I turned on my board, after boot, it runs my
gtk-based program and shows my image. It’s something like Kiosk but a
c++ program should only show an image!
我该怎么办?
编辑:我添加了这一行:
/ home / m / img&
到我的/ etc / xdg / openbox / autostart文件,它在登录后工作但不显示我的图像,它只显示屏幕中心的文件图标.但是当我去这个地址/ home / m /并运行这个命令./img它会全屏显示我的图像!
为什么会这样?
**我也喜欢隐藏我的鼠标指针和我的窗口边框,但不知道如何?
这是我在尝试此命令后看到的内容(在写入按钮的角落出现一个图标):/ home / m / img&
解决方法:
**Also I like to hide my mouse pointer and my windows borders but don’t know how?
您可以将-nocursor附加到startx以隐藏鼠标指针:
exec startx -- -nocursor
有文件〜/ .config / openbox / rc.xml和/etc/xdg/openbox/rc.xml供您编辑(参考号:http://openbox.org/wiki/Help:Configuration),例如: (文件底部):
...
</menu>
<applications>
<application class="*">
<decor>no</decor>
<position force="yes">
<x>50</x>
<y>50</y>
<monitor>1</monitor>
</position>
<size>
<width>300</width>
<height>300</height>
</size>
<focus>yes</focus>
<desktop>1</desktop>
<layer>normal</layer>
<iconic>no</iconic>
<skip_pager>no</skip_pager>
<skip_taskbar>no</skip_taskbar>
<fullscreen>no</fullscreen>
<maximized>false</maximized>
</application>
</applications>
</openbox_config>
其中< decor> no< / decor>以上将使图像应用程序变得无边框.调整< width>和< height>如果您发现您的图像没有显示完整的尺寸.您还可以调整< x> ;,< y>该应用程序.
还有更多,例如注释掉菜单标签(有多个< context标签有这个< menu>条目):
<mousebind button="Right" action="Press">
<action name="ShowMenu">
<!-- menu>root-menu</menu -->
</action>
</mousebind>
它将禁用右键单击显示菜单(startx – -nocursor隐藏鼠标光标不会阻止您右键单击打开菜单).
还有openbox / menu.xml来自定义右键菜单项,例如:
<item label="Run Image app">
<action name="Execute"><execute>/home/m/img</execute></action>
</item>
您可以选择右键单击菜单项重新配置一次menu.xml或rc.xml编辑即可生效.
我还发布了答案here,解决自动启动问题为非root.
标签:rc,c,boot,x-server,xinit 来源: https://codeday.me/bug/20190816/1665117.html