Answers:
尝试
su -c 'startx openbox -- :1' user
编辑:也尝试运行
X :1 &
su -c 'DISPLAY=:1 openbox &' user
/usr/bin/Xorg
setuid-root。
似乎唯一的方法是创建临时.xinitrc
文件。这是脚本:
#!/usr/bin/env bash
username="$USER"
let xdisplay=${DISPLAY:1}+1
# Temporary xinitrc
temp_xinit="$(tempfile -p '.xinit' -s 'rc')" || exit
trap "rm -f -- '$temp_xinit'" EXIT
# Launch X
echo "sudo -u $username $@" > "$temp_xinit"
sudo xinit "$temp_xinit" -- :$xdisplay
用法示例:
$ Xnew.sh /usr/local/games/braid [..options...]
mktemp
一部分而不是。tempfile