Improved browser launcher

browser
Vadim vtroshchinskiy 2025-02-18 09:08:44 +01:00
parent eec58ac03a
commit e936178376
1 changed files with 53 additions and 10 deletions

63
includes/usr/bin/launch_browser 100644 → 100755
View File

@ -3,7 +3,7 @@
# Compatibilidad con los argumentos usados con el browser original:
# browser -qws http://google.com
#
while getopts ":qws" opt ; do
while getopts ":qwsDWX" opt ; do
case $opt in
q)
echo "Ignoring option: -q"
@ -14,27 +14,70 @@ case $opt in
s)
echo "Ignoring option: -s"
;;
D)
BROWSER_DEBUG=1
;;
W)
DISABLE_WAYLAND=1
;;
X)
DISABLE_X11=1
;;
esac
done
shift $(expr $OPTIND - 1 )
url="$1"
browser_args="$@"
echo "URL: $url"
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"
rm -rf "/run/sway.started" "/run/x11.started"
mkdir -p $HOME/.config/sway
echo "exec /usr/bin/OGBrowser $url" > $HOME/.config/sway/config
echo "exec touch /run/sway.started" >> $HOME/.config/sway/config
echo "exec /usr/bin/OGBrowser \"$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 OGBrowser $url" > $HOME/.config/i3/configc
echo "exec touch /run/x11.started" >> $HOME/.config/i3/config
echo "exec /usr/bin/OGBrowser \"$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
@ -44,14 +87,14 @@ echo "exec /usr/bin/xterm" >> $HOME/.xinitrc
/usr/bin/udevadm trigger
if [ -x "/usr/bin/sway" ] ; then
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" ] ; then
if [ ! -f "/run/sway.started" -a -z "$DISABLE_X11" ] ; then
if [ -x "/usr/bin/startx" ] ; then
echo "*** Trying to launch X11 ***"
/usr/bin/startx