Dvlv / BoxBuddyRS

A Graphical Interface for Distrobox
MIT License
243 stars 24 forks source link

View Applications needs rewriting (Distrobox 1.7) #72

Closed Dvlv closed 6 months ago

Dvlv commented 6 months ago

https://cubiclenate.com/2024/03/02/distrobox-with-boxbuddy-on-opensuse/

VortexAcherontic commented 6 months ago

This once worked. I am not sure if an update in Tumbleweed broke it, distrobox or boxbuddy. Did not yet wrap my head around it 😄 Happens with podman as container runtime as well.
I'll try to figure out what actually is broken.

VortexAcherontic commented 6 months ago

Just found another issue which is totally up to distrobox. Since it's latest release and their "improvements" to the nvidia driver integration distrobox will get stuck at "Setting up host's nvidia integration..." and never proceed. You have to enter the container a 2nd time for it to actually enter the container.

As fetching installed apps is done using distrobox enter tumbleweed -- bash -c grep -L "NoDisplay=true" /usr/share/applications/*.desktop this feature is partially broken as of distrobox 1.7.0 on nvidia distroboxes.
Unless the user closes the dialog and re-run it.

I think for nvidia boxes we unfortunate need to hide the menu as of now.

VortexAcherontic commented 6 months ago

Hm, looking further into the matter I found the follwoing:

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

/usr/bin/distrobox-enter: eval: line 614: unexpected EOF while looking for matching `"'

Which is what get_pieces_cmd actually contains after:

        let get_pieces_cmd = get_command_output(
            String::from("distrobox"),
            Some(&[
                "enter",
                &box_name,
                "--",
                "bash",
                "-c",
                &format!(
                    "NAME=$(grep -m 1 \"^Name=\" {} 
            | sed 's/^Name=//'); 
            EXEC=$(grep -m 1 \"^Exec=\" {} 
            | sed 's/^Exec=//' | tr -d '\n'); 
            ICON=$(grep -m 1 \"^Icon=\" {} 
            | sed 's/^Icon=//' | tr -d '\n'); 
            echo \"${{NAME}} | ${{EXEC}} | ${{ICON}}\"",
                    line, line, line
                ),
            ]),
        );

Which version of distrobox do you run and does this still work for you?
Tumbleweed (and Aeon as well as Kalpa therefore) does ship with distrobox: 1.7.0

Dvlv commented 6 months ago

Yeah, I traced it back to that same place. Updates to Distrobox have changed how the shelling-out is handled, so now the stuff in $() is being executed on the host, when it was previously being done in the container.

This means if I have geany in the container but not on the host, it's doing:

$(grep -m 1 \"^Name=\" /usr/share/applications/geany.desktop | sed 's/^Name=//')

on the host, which has no /usr/share/geany.desktop.

I'm gonna have to redo this to do all the parsing in Rust, which is a pain. When I was doing it in python it was unusably slow; of course Rust is faster than Python but I'll need to see if it's acceptable.

I assume shelling-out to distrobox is fairly slow, so I'm wondering if I can be clever and do something like

for df in desktopFiles do
    cat df
    echo "---BoxBuddy---"
end

(not real bash syntax)

Then get one big string, which I can split on the ---BoxBuddy--- into a Vec, so I'm only shelling out once.

Dvlv commented 6 months ago

Fix pushed to master

VortexAcherontic commented 6 months ago

You are a true magician. It works very well. Many thanks. ❤️

Dvlv commented 6 months ago

2.1.4 now on flathub