Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Xfvb + VNC + novnc + fluxbox

09 Apr 2022 »
yum -y install Xvfb tigervnc-server-minimal x11vnc
yum -y install fluxbox

install python3-websockify for novnc

wget https://github.com/novnc/websockify/archive/refs/tags/v0.10.0.zip
yum -y install unzip python39
unzip v0.10.0.zip
cd websockify-0.10.0/
# need python3.9
python3.9 setup.py install
yum -y install https://rpmfind.net/linux/epel/9/Everything/x86_64/Packages/p/python3-websockify-0.10.0-1.el9.noarch.rpm
yum -y install novnc

#check if websockify is using python3.9
#sed '1c#!/usr/bin/python3.9' /usr/local/bin/websockify

if screen

yum -y install screen

utils

# yum -y install xorg-x11-apps
# powertools repo
yum -y install https://vault.centos.org/8.5.2111/PowerTools/x86_64/os/Packages/xorg-x11-apps-7.7-21.el8.x86_64.rpm

1 Create Screen

Xvfb :1 -screen 0, 1024x720x24
screen -dmS xvfb bash -c "Xvfb :1 -screen 0, 1024x720x24"

2 Display to rfbport

x11vnc -display :1 -noxdamage -rfbport 4900
screen -dmS x11 bash -c "x11vnc -display :1 -noxdamage -rfbport 4900 -shared -loop"

3 NoVNC from rfbport to web

novnc_server --listen 7900 --vnc localhost:4900
screen -dmS novnc bash -c "novnc_server --listen 7900 --vnc localhost:4900"

Start fluxbox

DISPLAY=:1 fluxbox

Start GUI

DISPLAY=:1 firefox
DISPLAY=:1 jmeter.sh

apps

screen -dmS firefox bash -c "DISPLAY=:1 firefox"
screen -dmS xclock bash -c "DISPLAY=:1 xclock"
screen -dmS xeyes bash -c "DISPLAY=:1 xeyes"
screen -dmS fluxbox bash -c "DISPLAY=:1 fluxbox"
upvnc(){
    [ ! -t $(screen -ls | grep -q xvfb ) ] || screen -dmS xvfb bash -c "Xvfb :1 -screen 0, 1024x720x24"
    [ ! -t $(screen -ls | grep -q x11 ) ] || screen -dmS x11 bash -c "x11vnc -display :1 -noxdamage -rfbport 4900 -shared -loop"
    [ ! -t $(screen -ls | grep -q novnc ) ] || screen -dmS novnc bash -c "novnc_server --listen 7900 --vnc localhost:4900"
}
startfirefox(){
    [ ! -t $(screen -ls | grep -q firefox ) ] || screen -dmS firefox bash -c "DISPLAY=:1 firefox"
}

Xterm

yum -y install xterm

screen -dmS xterm bash -c "DISPLAY=:1 xterm -bg black -fg white"


https://stackoverflow.com/questions/12050021/how-to-make-xvfb-display-visible

Run x11vnc in shell

Then to setup access to Xvfb for remote control, you can use X11 over SSH or VNC over SSH, e.g.

export DISPLAY=:1
Xvfb $DISPLAY -screen 0 1024x768x16 &
fluxbox &
x11vnc -display $DISPLAY -bg -forever -nopw -quiet -listen localhost -xkb

Run x11vnc using one-liner

$ x11vnc -create -env FD_PROG=/usr/bin/fluxbox \
    -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 \
        -env X11VNC_CREATE_GEOM=${1:-1024x768x16} \
        -gone 'killall Xvfb' \
        -bg -nopw

https://board.jdownloader.org/showthread.php?t=64399

JDSTART="sudo DISPLAY=:1 /usr/local/jdownloader/jd.sh"
XVFBSTART="sudo Xvfb :1"
BBSTART="sudo blackbox -display :1"
case "$1" in
 start)
  echo "Starting Xvfb ..."
  screen -AmdS xvfb $XVFBSTART
  echo "Starting Jdownloader ..."
  screen -AmdS jdownloader $JDSTART
  echo "Starting BlackBox ..."
  screen -AmdS jdownloader $BBSTART
  echo "done ..."
 ;;