Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 用yocto启动Raspberry Pi 3上的Electron应用程序_Linux_Raspberry Pi3_X11_Yocto - Fatal编程技术网

Linux 用yocto启动Raspberry Pi 3上的Electron应用程序

Linux 用yocto启动Raspberry Pi 3上的Electron应用程序,linux,raspberry-pi3,x11,yocto,Linux,Raspberry Pi3,X11,Yocto,我用X11构建了一个图像,使用yocto制作了一个树莓皮3和一个触摸屏。我可以通过在串行会话中手动运行命令来启动使用Electron(chromium)构建的应用程序: export DISPLAY=:0 /usr/lib/node/electron/dist/electron --no-sandbox /home/root/app 我想使用init.d脚本在启动时自动执行,但我希望使用正确的方法。我试着用上面的命令在我的用户目录中创建一个.Xsession文件,但它不起作用,我不知道是否可以

我用X11构建了一个图像,使用yocto制作了一个树莓皮3和一个触摸屏。我可以通过在串行会话中手动运行命令来启动使用Electron(chromium)构建的应用程序:

export DISPLAY=:0
/usr/lib/node/electron/dist/electron --no-sandbox /home/root/app
我想使用init.d脚本在启动时自动执行,但我希望使用正确的方法。我试着用上面的命令在我的用户目录中创建一个
.Xsession
文件,但它不起作用,我不知道是否可以获得所发生事件的日志

据介绍,X11启动时有很多步骤。目前,我只看到一个终端(我猜是从火柴盒中看到的)和一个鼠标光标

使用系统启动应用程序的“标准”方式是什么?有没有办法移除触摸屏上的光标

编辑

以下是我的
/etc/X11
目录的内容:

  • X会话
  • Xsession.d/
  • 西尼特/
  • xorg.conf
X会话:

90XWindowManager.sh:

还有一个文件
/etc/xserver nodm/xserver

#!/bin/sh

# This script is only needed to make sure /etc/X11/xserver-common
# can affect XSERVER, ARGS & DPI: otherwise systemd could just use
# /etc/default/xserver-nodm as EnvironmentFile and sysvinit could just
# source the same file

. /etc/profile

# load default values for XSERVER, ARGS, DISPLAY...
. /etc/default/xserver-nodm

# Allow xserver-common to override ARGS, XSERVER, DPI
if [ -e /etc/X11/xserver-common ] ; then
    . /etc/X11/xserver-common
    if [ ! -e $XSERVER ] ; then
        XSERVER=$(which $XSERVER)
    fi
fi

if [ -n "$DPI" ] ; then
    ARGS="$ARGS -dpi $DPI"
fi

exec xinit /etc/X11/Xsession -- $XSERVER $DISPLAY $ARGS $*
和一个文件
/etc/rc5.d/S09xserver nodm

#!/bin/sh
#
### BEGIN INIT INFO
# Provides: xserver
# Required-Start: $local_fs $remote_fs dbus
# Required-Stop: $local_fs $remote_fs
# Default-Start:     5
# Default-Stop:      0 1 2 3 6
### END INIT INFO

killproc() {            # kill the named process(es)
        pid=`/bin/pidof $1`
        [ "$pid" != "" ] && kill $pid
}

read CMDLINE < /proc/cmdline
for x in $CMDLINE; do
        case $x in
        x11=false)
        echo "X Server disabled" 
        exit 0;
                ;;
        esac
done

case "$1" in
  start)
       . /etc/profile

       #default for USER
       . /etc/default/xserver-nodm
       echo "Starting Xserver"
       if [ "$USER" != "root" ]; then
           # setting for rootless X
           chmod o+w /var/log
           chmod g+r /dev/tty[0-3]
           # hidraw device is probably needed
           if [ -e /dev/hidraw0 ]; then
               chmod o+rw /dev/hidraw*
           fi
       fi

       # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
       su -l -c '/etc/xserver-nodm/Xserver &' $USER
       # Wait for the desktop to say its finished loading
       # before loading the rest of the system
       # dbus-wait org.matchbox_project.desktop Loaded
  ;;

  stop)
        echo "Stopping XServer"
        killproc xinit
        sleep 1
        chvt 1 &
  ;;

  restart)
    $0 stop
        $0 start
  ;;

  *)
        echo "usage: $0 { start | stop | restart }"
  ;;
esac

exit 0
#/垃圾箱/垃圾箱
#
###开始初始化信息
#提供:xserver
#必需的开始:$local_fs$remote_fs dbus
#所需停止:$local\u fs$remote\u fs
#默认开始:5
#默认停止:0 1 2 3 6
###结束初始化信息
killproc(){#终止指定进程
pid=`/bin/pidof$1`
[“$pid”!=”]&&kill$pid
}
读取CMDLINE
定义完整X会话的正确方法取决于会话管理器:在Yocto上,通常是火柴盒会话或迷你X会话。根据您的描述,我猜您使用的是mini-x-session(如果找不到会话文件,则会启动终端和窗口管理器)

引述:

因此,添加/etc/mini_x/会话脚本应该是可行的

顺便说一句,在会话文件中,您可能还需要启动一个窗口管理器(没有它,X可以做一些奇怪的事情):


我没有
/etc/mini_x
目录。我将
/etc
目录中可能最相关的文件的内容添加到我的问题中。如果您使用mini-x-session,您只需创建目录和文件…我创建了一个新的
.Xsession
文件,而不是
/bin/bash
我已经写了
/bin/sh
一开始就可以了!谢谢
if [ -x $HOME/.Xsession ]; then
    exec $HOME/.Xsession
elif [ -x /usr/bin/x-session-manager ]; then
    exec /usr/bin/x-session-manager
else
    exec /usr/bin/x-window-manager
fi
#!/bin/sh

# This script is only needed to make sure /etc/X11/xserver-common
# can affect XSERVER, ARGS & DPI: otherwise systemd could just use
# /etc/default/xserver-nodm as EnvironmentFile and sysvinit could just
# source the same file

. /etc/profile

# load default values for XSERVER, ARGS, DISPLAY...
. /etc/default/xserver-nodm

# Allow xserver-common to override ARGS, XSERVER, DPI
if [ -e /etc/X11/xserver-common ] ; then
    . /etc/X11/xserver-common
    if [ ! -e $XSERVER ] ; then
        XSERVER=$(which $XSERVER)
    fi
fi

if [ -n "$DPI" ] ; then
    ARGS="$ARGS -dpi $DPI"
fi

exec xinit /etc/X11/Xsession -- $XSERVER $DISPLAY $ARGS $*
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: xserver
# Required-Start: $local_fs $remote_fs dbus
# Required-Stop: $local_fs $remote_fs
# Default-Start:     5
# Default-Stop:      0 1 2 3 6
### END INIT INFO

killproc() {            # kill the named process(es)
        pid=`/bin/pidof $1`
        [ "$pid" != "" ] && kill $pid
}

read CMDLINE < /proc/cmdline
for x in $CMDLINE; do
        case $x in
        x11=false)
        echo "X Server disabled" 
        exit 0;
                ;;
        esac
done

case "$1" in
  start)
       . /etc/profile

       #default for USER
       . /etc/default/xserver-nodm
       echo "Starting Xserver"
       if [ "$USER" != "root" ]; then
           # setting for rootless X
           chmod o+w /var/log
           chmod g+r /dev/tty[0-3]
           # hidraw device is probably needed
           if [ -e /dev/hidraw0 ]; then
               chmod o+rw /dev/hidraw*
           fi
       fi

       # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
       su -l -c '/etc/xserver-nodm/Xserver &' $USER
       # Wait for the desktop to say its finished loading
       # before loading the rest of the system
       # dbus-wait org.matchbox_project.desktop Loaded
  ;;

  stop)
        echo "Stopping XServer"
        killproc xinit
        sleep 1
        chvt 1 &
  ;;

  restart)
    $0 stop
        $0 start
  ;;

  *)
        echo "usage: $0 { start | stop | restart }"
  ;;
esac

exit 0
if [ -e $HOME/.mini_x/session ]
then
exec $HOME/.mini_x/session
fi

if [ -e /etc/mini_x/session ]
then
exec /etc/mini_x/session
fi
your-app-here &
exec matchbox-window-manager