oglive-builder/includes/usr/bin/launch_browser

117 lines
3.0 KiB
Bash

#!/bin/bash
# Compatibilidad con los argumentos usados con el browser original:
# browser -qws http://google.com
#
while getopts ":qwsDWX" opt ; do
case $opt in
q)
echo "Ignoring option: -q"
;;
w)
echo "Ignoring option: -w"
;;
s)
echo "Ignoring option: -s"
;;
D)
BROWSER_DEBUG=1
;;
W)
DISABLE_WAYLAND=1
;;
X)
DISABLE_X11=1
;;
esac
done
shift $(expr $OPTIND - 1 )
browser_args="$@"
echo "Browser args: $browser_args"
[ -n "$DISABLE_WAYLAND" ] && echo "WAYLAND DISABLED"
[ -n "$DISABLE_X11" ] && echo "X11 DISABLED"
if [ -n "BROWSER_DEBUG" ] ; then
echo "DEBUG MODE ENABLED"
echo "* Terminal available via Win+Enter"
echo "* Session may be killed with Ctrl+Alt+Backspace"
echo ""
fi
[ -x "/usr/bin/kitty" ] && wl_terminal=/usr/bin/kitty
[ -x "/usr/bin/foot" ] && wl_terminal=/usr/bin/foot
[ -x "/usr/bin/xterm" ] && x11_terminal=/usr/bin/kitty
[ -x "/usr/bin/i3-sensible-terminal" ] && x11_terminal=/usr/bin/i3-sensible-terminal
# The admin page is hosted remotely but executes things on localhost
QTWEBENGINE_CHROMIUM_FLAGS="--disable-web-security"
[ "$UID" -eq "0" ] && QTWEBENGINE_CHROMIUM_FLAGS="${QTWEBENGINE_CHROMIUM_FLAGS} --no-sandbox"
export QTWEBENGINE_CHROMIUM_FLAGS
rm -rf "/run/sway.started" "/run/x11.started"
mkdir -p $HOME/.config/sway
echo "exec /usr/bin/OGBrowser --ignore-ssl-errors \"$browser_args\" || /usr/bin/browser -qws \"$browser_args\"" > $HOME/.config/sway/config
if [ -n "BROWSER_DEBUG" ] ; then
echo "bindsym Mod4+Return exec $wl_terminal" >> $HOME/.config/sway/config
echo "bindsym Control+Alt+Backspace exit" >> $HOME/.config/sway/config
fi
echo "exec touch /run/sway.started" >> $HOME/.config/sway/config
mkdir -p $HOME/.config/i3
echo "exec /usr/bin/OGBrowser --ignore-ssl-errors \"$browser_args\" || /usr/bin/browser -qws \"$browser_args\"" > $HOME/.config/i3/config
if [ -n "BROWSER_DEBUG" ] ; then
echo "bindsym Mod4+Return exec i3-sensible-terminal" >> $HOME/.config/i3/config
echo "bindsym Control+Mod1+BackSpace exit" >> $HOME/.config/i3/config
fi
echo "exec touch /run/x11.started" >> $HOME/.config/i3/config
echo "exec /usr/bin/i3" > $HOME/.xinitrc
echo "exec /usr/bin/xterm" >> $HOME/.xinitrc
# Make sure libinput works
/usr/bin/udevadm trigger
if [ -x "/usr/bin/sway" -a -z "$DISABLE_WAYLAND" ] ; then
echo "*** Trying to launch Sway ***"
/usr/bin/sway
else
echo Sway not installed in this image, skipping.
fi
if [ ! -f "/run/sway.started" -a -z "$DISABLE_X11" ] ; then
if [ -x "/usr/bin/startx" ] ; then
echo "*** Trying to launch X11 ***"
/usr/bin/startx
else
echo X11 not installed in this image, skipping.
fi
else
echo "Sway was run before, not starting X11".
fi
if [ ! -f "/run/sway.started" -a ! -f "/run/x11.started" ] ; then
echo "Everything failed, dropping into a shell."
exec /usr/bin/bash
else
echo "All done."
fi