Skip to content

Commit

Permalink
parse folder /etc/X11/Xsession.d
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Schleizer committed Oct 29, 2020
1 parent 0408cb4 commit 005f453
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions usr/bin/sandbox-app-launcher
Expand Up @@ -144,19 +144,53 @@ setup() {
wrapper_dir="${wrapper_dir_wx}"
fi

## Create wrappers.
if ! [ -e "${wrapper_dir}/${app_name}" ]; then
cat <<EOF > "${wrapper_dir}/${app_name}"
#!/bin/bash
## Create wrapper.

if [ -x /etc/X11/Xsession.d/20torbrowser ]; then
source /etc/X11/Xsession.d/20torbrowser
fi
rm --force "${wrapper_dir}/${app_name}"
touch "${wrapper_dir}/${app_name}"

## dbus-launch is run by /etc/X11/Xsession.d/75dbus_dbus-launch

cat >> "${wrapper_dir}/${app_name}" << 'EOF'
#!/bin/sh
dbus-launch
"${app_path}" "\${@}" 1>/dev/null
## Using sh because /etc/X11/Xsession is written in sh.
## Debugging.
set -x
export sandbox_app_launcher_wrapper_script=true
EOF
chmod 755 "${wrapper_dir}/${app_name}"

## /etc/X11/Xsession.d/99x11-common_start
## Does not work.
## + . /etc/X11/Xsession.d/99x11-common_start
## + exec /home/sandbox-app-launcher-appdata/torbrowser/.tb/tor-browser/Browser/start-tor-browser
## with exit code 139
#echo "STARTUP=\"${app_path}\" \"\${@}\"" | tee --append "${wrapper_dir}/${app_name}" 1>/dev/null

## Copied from /etc/X11/Xsession and adjusted.
cat >> "${wrapper_dir}/${app_name}" << 'EOF'
SYSSESSIONDIR=/etc/X11/Xsession.d
SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
if [ -n "$SESSIONFILES" ]; then
set +e
for SESSIONFILE in $SESSIONFILES; do
if [ "$SESSIONFILE" = "/etc/X11/Xsession.d/99x11-common_start" ]; then
continue
fi
. $SESSIONFILE
done
set -e
fi
EOF

echo "\"${app_path}\" \"\${@}\"" | tee --append "${wrapper_dir}/${app_name}" 1>/dev/null

chmod 755 "${wrapper_dir}/${app_name}"

if [ -o xtrace ]; then
cat "${wrapper_dir}/${app_name}"
fi
}

Expand Down

0 comments on commit 005f453

Please sign in to comment.