Kron4ek / Conty

Easy to use unprivileged Linux container packed into a single portable executable
MIT License
776 stars 45 forks source link

Create a way to export conty's .desktop files so that conty apps can appear and be run from graphical app launcher #70

Closed bayazidbh closed 1 year ago

bayazidbh commented 1 year ago
          2. Exporting of generated .desktop files in conty's `/usr/share/applications` (currently I just `cp` them, and then edit them manually replacing `/usr/bin/` with `$HOME/.local/bin/conty.sh` and then move them to `~/.local/share/applications/conty/`)

Originally posted by @bayazidbh in https://github.com/Kron4ek/Conty/issues/68#issuecomment-1477421971

          As for 2 and 3, maybe in the future.

Originally posted by @Kron4ek in https://github.com/Kron4ek/Conty/issues/68#issuecomment-1479510127

Might be worth it to reference how distrobox does distrobox-export for comparison.

bayazidbh commented 1 year ago

Currently, what I do is :

$ conty.sh cp -r /usr/share/applications ./applications/   # copy .desktop files in conty
$ cd ./applications
$ for f in *.desktop; do mv -- "$f" "${f%.desktop}-conty.desktop"; done    # rename .desktop files in the folder to have the '-conty' suffix
$ for file in *.desktop; do sed -i -r 's/^Name=(.+)$/Name=\1 (Conty)/' "$file"; done   # append " (Conty)" to app's menu display name
$ find . -type f -name '*.desktop' -exec sed -i 's/Exec=/Exec=$HOME\/.local\/bin\/conty.sh/g' {} +   # replace string "Exec=" with "Exec=$HOME/.local/bin/conty.sh" 

There's probably a better way of doing it, this is my first time using sed, that can be incorporated with the utils zip (tho some apps like lutris-wine (not lutris) have a folder of its own at /usr/share/applications/LutrisWine)

Kron4ek commented 1 year ago

Implemented in feaefe2014b242ca53677ac665da3977cf2225e2. For those who use prebuilt releases the feature will be available in the next release.

bayazidbh commented 1 year ago

Will try soon during weekend, thanks!

Sidenote, I know that you have to run ./create-arch-bootstrap.sh with sudo, but does it matter if ./create-conty.sh is run with or without sudo? In either case, I managed to build the conty.sh, so I don't think it matters?

Kron4ek commented 1 year ago

but does it matter if ./create-conty.sh is run with or without sudo?

It does not matter. You can run it with root rights if you want, but it is not required.

bayazidbh commented 1 year ago

I can confirm that it does work, but it seems that the command skips commands inside a folder. Everything inside conty's /usr/share/applications was exported correctly, but it skips the entire /usr/share/applications/LutrisWine/ folder.

Kron4ek commented 1 year ago

Should be fixed now in 850b0571e4452658c6533014b38cb4dc6ca597c1.

bayazidbh commented 1 year ago

I feel awkward for asking so much, but is it possible for the desktop export to inherit the launch options that conty has? For example, I tried:

HOME_DIR=~/Documents/Conty conty.sh --bind ~/.steam ~/.steam --bind ~/.local/share/Steam ~/.local/share/Steam --bind ~/Games ~/Games --bind ~/.local/share ~/.local/share --bind ~/.config ~/.config --bind ~/.local/state ~/.local/state --bind ~/.cache ~/.cache -d

and


HOME_DIR=~/Documents/Conty conty.sh -d --bind ~/.steam ~/.steam --bind ~/.local/share/Steam ~/.local/share/Steam --bind ~/Games ~/Games --bind ~/.local/share ~/.local/share --bind ~/.config ~/.config --bind ~/.local/state ~/.local/state --bind ~/.cache ~/.cache

In the former, the -d wasn't recognize, but that's fine, just need a note. But in the latter, it exported successfully,, but it doesn't inherit both the HOME_DIR env var nor the bind options.

Really sorry for keeping commenting on this; if this is going to be a limitation, then I'm fine with just a note on it. Personally, it'd be neat if the utility could pick up the text before the conty.sh command as env var to be appended to exports (so that it'd inherit the HOME_DIR and SANDBOX levels) and everything after the -d as default args for all entries.

Kron4ek commented 1 year ago

Personally, it'd be neat if the utility could pick up the text before the conty.sh command as env var to be appended to exports (so that it'd inherit the HOME_DIR and SANDBOX levels) and everything after the -d as default args for all entries.

No problem, the latest revision now preserves environment variables and arguments passed after -d.

https://github.com/Kron4ek/Conty/commit/a68c21884bfc0cbb07a1a3d509f781f9f6a9df88 https://github.com/Kron4ek/Conty/commit/14e606729fe8be4dd66ef70d28f5438b0e44177f

VHSgunzo commented 1 year ago

Currently, what I do is :

$ conty.sh cp -r /usr/share/applications ./applications/   # copy .desktop files in conty
$ cd ./applications
$ for f in *.desktop; do mv -- "$f" "${f%.desktop}-conty.desktop"; done    # rename .desktop files in the folder to have the '-conty' suffix
$ for file in *.desktop; do sed -i -r 's/^Name=(.+)$/Name=\1 (Conty)/' "$file"; done   # append " (Conty)" to app's menu display name
$ find . -type f -name '*.desktop' -exec sed -i 's/Exec=/Exec=$HOME\/.local\/bin\/conty.sh/g' {} +   # replace string "Exec=" with "Exec=$HOME/.local/bin/conty.sh" 

There's probably a better way of doing it, this is my first time using sed, that can be incorporated with the utils zip (tho some apps like lutris-wine (not lutris) have a folder of its own at /usr/share/applications/LutrisWine)

@bayazidbh Hi, lutris-wine now has its own container implementation, in which it works more correctly, because it additionally has a special wrapper, its own update system and the necessary container functions, as well as the container version of LW is automatically installed in HOME, at the same time, additional categories are created in the application menu and and mime types, as when installing into the system

The installation of the container version of LW is shown in the video in the project repository (one command with curl or wget)

bayazidbh commented 1 year ago

@VHSgunzo thanks, I'll have to try that method out.

@Kron4ek Sorry, I know that you have this closed already, but there's two things that kinda bugs me:

1.) Icons not exported:

Is it is, right now, if the icons don't already exist in the user's files, the .desktop shortcuts also don't have icons. I think just exporting to $XDG_DATA_HOME/icons/conty should be good enough? Distrobox also does that for its containers (though the exported apps' icons are in the parent ~/.local/share/icons/ folder). Not sure about the cache though, GNOME seems to have gtk-update-icon-cache but I don't know about KDE/Qt.

2.) Conty could make its own folders/categories for application launchers/menu:

For KDE, that would make listing and finding things easier. For GNOME, it might be very useful, since I think GNOME just spreads everything, without categorization, so foldering them might be convenient (though, I don't use GNOME right now, so for all I know, Conty might already be foldering itself). Not sure about the mechanisms for these, but Wine, CrossOver, and LutrisWine also seems to have an implementation of it?

Honestly, I can deal with it, it's not a big deal, but it kinda bugs me.

Kron4ek commented 1 year ago

@bayazidbh I added icons export. As for 2, I don't know how to implement that without root rights and make it work for every application menu.

bayazidbh commented 1 year ago

Tested and it works, thanks! Though, I don't think it does a update-desktop-database ~/.local/share/applications/Conty so it might not appear for a while until cache was refreshed.