#!/bin/bash # # 2023.01.13 Version 1.0 # #WindowSize=1920x1080 WindowSize=1024x768 # if [ ! -f /etc/X11/headless.conf ] then BUSID=`nvidia-xconfig --query-gpu-info|grep BusID|awk '{print $4}'` nvidia-xconfig -a --allow-empty-initial-configuration --use-display-device=None --virtual=$WindowSize --busid $BUSID -o /etc/X11/headless.conf cat >> /etc/X11/headless.conf << EOL # # The following definitions are mandatory for Headless VNC connections # do not delete # Section "InputClass" Identifier "Ignore libinput" Driver "libinput" Option "Ignore" "True" EndSection # EOL fi #################################################### TARGET=$1 # func_signal() { kill -0 $2 > /dev/null 2>&1 if [ $? -eq 0 ] then kill -$1 $2 return $? fi return 1 } # trap ' if [ -n $XSERVER ] then func_signal TERM $XSERVER echo -e "\nXorg $XSERVER exited!" fi ' 2 3 15 # export GDM_LANG=$LANG #XLOG=/tmp/Xorg.$TARGET.log XLOG=/dev/null #VLOG=/tmp/x11vnc.$TARGET.log VLOG=/dev/null # # #################################################### # Xorg -ardelay 300 -arinterval 25 $TARGET -sharevts -auth $XAUTHORITY -config /etc/X11/headless.conf > $XLOG 2>&1 & XSERVER=$! # echo "Xorg PID $XSERVER" # # -noncache スクロールバーが無くなる # -repeat key auto repeat on x11vnc -repeat -noxdamage -noscr -clip $WindowSize+0+0 -geometry $WindowSize -forever -shared -noncache -auth $XAUTHORITY -N -display $TARGET > $VLOG 2>&1 & XVNC=$! echo "x11vnc PID $XVNC" # sleep 3 # Window Manager # gnome-session:gnome-flachback以外は(xrandrのlogical displayが存在しないため)動作しない # Open Motif :動作するが、タイトルの漢字コードは化ける # kde plasma :動作する # MATE :動作する # # if [ "$LANG" = "ja_JP.UTF-8" ] then DISPLAY=$TARGET setxkbmap -model pc105 -layout jp,us fi # # if [ -n $XSERVER ] then wait $XSERVER func_signal KILL $XSERVER fi if [ -n $XVNC ] then func_signal KILL $XVNC echo "x11vnc $XVNC exited!" fi