bash 在 startx 后自动运行脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19916921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:35:38  来源:igfitidea点击:

Running a script after startx automatically

linuxbashshraspberry-pi

提问by Romain Pellerin

With my Raspberry Pi, I managed to login pi user automatically, then start tomcat automatically and then start X server as well.

使用我的树莓派,我设法自动登录 pi 用户,然后自动启动 tomcat,然后也启动 X 服务器。

For those interested, auto login:

对于那些有兴趣的人,自动登录:

1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

instead of

代替

1:2345:respawn:/sbin/getty 115200 tty1

in /etc/inittab

在 /etc/inittab 中

and

sh /home/pi/apache-tomcat-7.0.47/bin/startup.sh
su -l pi -c startx
exit 0

in /etc/rc.local

在 /etc/rc.local

Now, I'd like to launch a java program (jar file) that I made, automatically after server X has started. How could I do that?

现在,我想在服务器 X 启动后自动启动我制作的 java 程序(jar 文件)。我怎么能那样做?

Thank you

谢谢

UPDATE:On my Rapsberry, as LXDE is used, http://wiki.lxde.org/en/Autostartsolved my problem.

更新:在我的 Rapsberry 上,由于使用了 LXDE,http ://wiki.lxde.org/en/Autostart解决了我的问题。

回答by WhyteWolf

startx uses the ~HOME/.xinitrc file to load programs at the startup of X where ~HOME is the home directory of the user running X [ in this case pi]

startx 使用 ~HOME/.xinitrc 文件在 X 启动时加载程序,其中 ~HOME 是运行 X 的用户的主目录 [在这种情况下为 pi]

see http://www.x.org/archive/X11R6.8.1/doc/startx.1.htmlfor an example of .xinitrc

有关 .xinitrc 的示例,请参见http://www.x.org/archive/X11R6.8.1/doc/startx.1.html