Skip to content

Instantly share code, notes, and snippets.

@vain
Created May 2, 2014 17:37
Show Gist options
  • Save vain/00b3d09bd84f74f12cd5 to your computer and use it in GitHub Desktop.
Save vain/00b3d09bd84f74f12cd5 to your computer and use it in GitHub Desktop.
vnc-box
#!/bin/bash
#launch_screen()
#{
# # Xvfb + x11vnc
#
# (
# screen=$1
#
# Xvfb :$screen -screen 0 1024x768x24 &
# while ! netstat -tulpen | grep ":$((6000 + screen)).*LISTEN.*Xvfb"
# do
# sleep 1
# done
# x11vnc -display :$screen -N -shared -forever
# ) &
#}
launch_screen()
{
# Requires tightvnc or tigervnc but is a lot faster
(
screen=$1
Xvnc :$screen \
-geometry 1024x768 -depth 24 \
-alwaysshared
) &
}
launch_program()
{
# Run a command in the given screen and try to isolate it as much as
# possible by building a new temporary home directory. This is
# necessary for a lot of "modern" software that tries to detect if
# it's already running (yes, it may be, but on another screen!).
(
screen=$1
cmd=$2
new_home=$(mktemp -d)
shopt -s dotglob
cp -av ~/* "$new_home"
env -i HOME="$new_home" DISPLAY=":$screen" \
XDG_DATA_HOME="$new_home/.local/share" \
XDG_CONFIG_HOME="$new_home/.config" \
XDG_CACHE_HOME="$new_home/.cache" \
sh -c "openbox& openbox=\$!; cd; { $cmd; }; kill \$openbox"
rm -Rfv "$new_home"
) &
}
initial_session_and_stuff()
{
for i in {1..20}
do
launch_screen $i
done
launch_program 1 "xterm"
launch_program 2 "chromium-browser --kiosk --disable-translate google.de"
launch_program 3 "chromium-browser --kiosk --disable-translate heise.de"
launch_program 4 "chromium-browser --disable-translate heise.de & xterm"
launch_program 5 "firefox http://github.com/vain"
wait
}
# Run this script with the following argument to get things running (I
# do this in /etc/rc.local). Afterwards, you can simply source it in
# your interactive shell and use launch_program() interactively.
if [[ $1 == initial ]]
then
initial_session_and_stuff
fi
@vain
Copy link
Author

vain commented May 3, 2014

chromium-browser --kiosk is fscked up in Ubuntu 14.04 because Chromium now uses its own "Aura" instead of Gtk. Aura throws errors in a VNC environment:

[14637:14637:0503/120740:ERROR:desktop_window_tree_host_x11.cc(1229)] Not implemented reached in void views::DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState)
[14637:14637:0503/120740:ERROR:fullscreen_aura.cc(15)] Not implemented reached in bool IsFullScreenMode()

Chromium runs, only kiosk mode is broken.

Might be an alternative: dwb -x fullscreen -x bars www.some-url.com (as long as you don't use it interactively... dwb has a keyboard-driven vi-style interface)

@vain
Copy link
Author

vain commented May 3, 2014

An interesting alternative to Xvfb: http://xpra.org/trac/wiki/Xdummy -- stock X with a dummy driver, RANDR works

@vain
Copy link
Author

vain commented May 3, 2014

Got tired of full-blown browsers. They're not made for this job.

vain/bin-pub@abcbab4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment