Skip to content

Commit

Permalink
Run Code normally when outside a container
Browse files Browse the repository at this point in the history
This changes to running the flatpak version of VS Code normally when not
inside a container. The install check still works as expected, because
the $flatpak command changes depending on if we are inside a container
or not.
  • Loading branch information
velsinki committed May 24, 2023
1 parent 39e3881 commit 1886024
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,19 @@ if $add_new_window ; then
new_args+=("--new-window")
fi

flatpak="flatpak-spawn --host flatpak"
# shellcheck disable=SC1091,SC2154
container_name="$(. /run/.containerenv && echo "$name")"
### Check if we are inside a container at all

# The install check will proceed as normal. Afterwards we directly run flatpak if we
# are not inside a container.

if [ -f /run/.containerenv ] ; then
flatpak="flatpak-spawn --host flatpak"
# shellcheck disable=SC1091,SC2154
container_name="$(. /run/.containerenv && echo "$name")"
else
flatpak="flatpak"
container_name=""
fi
container_name_encoded=$(echo -n "$container_name" | od -t x1 -A none -v | tr -d ' \n')

### Make sure that we have the Visual Studio Code Flatpak installed
Expand Down Expand Up @@ -246,6 +256,11 @@ else
esac
fi

if [ "$container_name" = "" ] ; then
verbose "Not in a toolbox, running Visual Studio Code directly"
exec $flatpak run com.visualstudio.code "$@"
fi

### Make sure that we have a podman wrapper configured

podman_wrapper="$HOME/.local/bin/podman-host"
Expand Down

0 comments on commit 1886024

Please sign in to comment.