From b4a5e28bdfc5c4346a29531d6bdf81ba76681bbb Mon Sep 17 00:00:00 2001 From: bobslept <38557801+bobslept@users.noreply.github.com> Date: Sat, 26 Aug 2023 22:02:09 +0200 Subject: [PATCH] fix(dx): use distrobox-enter wrapper for non default images (#439) --- dx/etc/dconf/db/local.d/01-ublue-dx | 2 +- dx/usr/bin/bluefinbox-enter | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 dx/usr/bin/bluefinbox-enter diff --git a/dx/etc/dconf/db/local.d/01-ublue-dx b/dx/etc/dconf/db/local.d/01-ublue-dx index 995c2de63fe..d0e00e71afe 100644 --- a/dx/etc/dconf/db/local.d/01-ublue-dx +++ b/dx/etc/dconf/db/local.d/01-ublue-dx @@ -1,6 +1,6 @@ [org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2] binding='f' -command='flatpak run com.raggesilver.BlackBox --command "distrobox enter fedora"' +command='flatpak run com.raggesilver.BlackBox --command "bluefinbox-enter fedora"' name='blackbox fedora' [org/gnome/settings-daemon/plugins/media-keys] diff --git a/dx/usr/bin/bluefinbox-enter b/dx/usr/bin/bluefinbox-enter new file mode 100755 index 00000000000..688e1dc9e38 --- /dev/null +++ b/dx/usr/bin/bluefinbox-enter @@ -0,0 +1,30 @@ +#!/bin/sh + +# Little helper script to launch other than default (ubuntu) distroboxes without manually +# having to assemble them. + +container_name=$1 +if [ "${container_name}" == "" ]; then + echo "Please specify the container name you want to enter." + echo "For example: ${0} fedora" + exit 1 +fi + +# Inspect if the container is already present +inspect_cmd="podman inspect --type container "${container_name}" --format {{.State.Status}} > /dev/null" +eval "${inspect_cmd}" +container_exists=$? + +if [ "$container_exists" -eq 0 ]; then + # No need to assemble, enjoy your stay + exec distrobox enter "${container_name}" +else + # We don't have the container so we assemble it first. With distrobox version 1.5.0.2 + # or below we need to assemble all the entries that occur in the `distrobox.ini` manifest. + # In future versions of distrobox we will be able to specify `--name $container_name` to + # only assemble the box we want to enter. + distrobox assemble create --replace --file /etc/distrobox/distrobox.ini + + # All done, good to go + exec distrobox enter "${container_name}" +fi