信创麒麟系统deb安装包安装后自动启动带图形界面的程序
麒麟系统2203/2503桌面版实现deb安装包安装完成后自动启动程序, postinst脚本需要一些特殊的操作如下:
username=`getent passwd \`who\` | head -n 1 | cut -d : -f 1`
echo "username=" $username
uid1=$(id -u "$username")
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid1/bus;
export XDG_RUNTIME_DIR=/run/user/$uid1;
export PULSE_SERVER=unix:/run/user/$uid1/pulse/native;
su $username -c "export DISPLAY=:0; echo $XDG_RUNTIME_DIR >> /tmp/xdg1.log; /opt/apps/com.channelsoft.qnsr/files/QNSightRec >> /tmp/qnsightrec.log 2>&1 &"
除了su指定用户启动,还需要export DISPLAY=:0; 并设置DBUS_SESSION_BUS_ADDRESS、XDG_RUNTIME_DIR环境变量,如果程序需要用到音频服务,还需要设置PULSE_SERVER环境变量

浙公网安备 33010602011771号