buildFHSEnvBubblewrap: allow more varied $DISPLAY syntax

The $DISPLAY variable has a format of [host]:num[.screen]. Previously,
the number would only be extracted properly if it had the form :num.
Allow all forms but correctly discard the unused parts.
This commit is contained in:
Thomas Watson 2024-05-16 10:14:07 -05:00
parent b3edf80d96
commit dd99084843

View File

@ -196,8 +196,10 @@ let
x11_args+=(--tmpfs /tmp/.X11-unix)
# Try to guess X socket path. This doesn't cover _everything_, but it covers some things.
if [[ "$DISPLAY" == :* ]]; then
display_nr=''${DISPLAY#?}
if [[ "$DISPLAY" == *:* ]]; then
# recover display number from $DISPLAY formatted [host]:num[.screen]
display_nr=''${DISPLAY/#*:} # strip host
display_nr=''${display_nr/%.*} # strip screen
local_socket=/tmp/.X11-unix/X$display_nr
x11_args+=(--ro-bind-try "$local_socket" "$local_socket")
fi