flathub / com.prusa3d.PrusaSlicer

https://flathub.org/apps/details/com.prusa3d.PrusaSlicer
7 stars 14 forks source link

add dark theme and workaround for locale bug #33

Closed xarbit closed 2 years ago

xarbit commented 2 years ago

added entrypoint script to workaround some things and issues between flatpak and upstream prusaslicer.

There is now a sorta fallback to LC_ALL=en_US.UTF-8 when the default execution fails and not detecting the locale, this workaround should prevent the application from crashing and from not starting up when that mixed locale issue gets screwed up. Note: running the flatpak application from the terminal with flatpak run com.prusa.... can still fail as it does not use the entrypoint script, but this known and will be adressed in the future.

So basicly this workaround solves the following issue (at least I hope for the time beeing, on the 2.4.x release until we can find a better solution).

https://github.com/flathub/com.prusa3d.PrusaSlicer/issues/27

The dark variant/theme is set being default and it can be controlled by the custom environment variable:

--env=PRUSA_SLICER_DARK_THEME=true

If the dark theme is not wanted and totally hated, dont worry you can override the PRUSA_SLICER_DARK_THEME to any other value other then true overriding with Command-line or flatseal.

This implementation of the dark variant uses GTK_THEME=Adwaita:dark and some hacky little script I borrowed from flathub/com.spotify.Client and adjusted a bit to work here, it changes the window border to dark under X11.

image
flathubbot commented 2 years ago

Started test build 68713

flathubbot commented 2 years ago

Build 68713 failed

flathubbot commented 2 years ago

Started test build 68715

flathubbot commented 2 years ago

Build 68715 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66549/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68722

flathubbot commented 2 years ago

Started test build 68723

flathubbot commented 2 years ago

Build 68722 failed

flathubbot commented 2 years ago

Build 68723 failed

flathubbot commented 2 years ago

Started test build 68724

flathubbot commented 2 years ago

Build 68724 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66558/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68732

flathubbot commented 2 years ago

Build 68732 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66566/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68739

flathubbot commented 2 years ago

Started test build 68740

flathubbot commented 2 years ago

Started test build 68741

flathubbot commented 2 years ago

Build 68739 failed

flathubbot commented 2 years ago

Started test build 68743

flathubbot commented 2 years ago

Started test build 68744

flathubbot commented 2 years ago

Started test build 68745

flathubbot commented 2 years ago

Build 68744 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66578/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Build 68743 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66577/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Build 68745 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66579/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68749

flathubbot commented 2 years ago

Started test build 68756

flathubbot commented 2 years ago

Build 68749 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66584/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68757

flathubbot commented 2 years ago

Build 68756 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66591/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Build 68757 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66592/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68775

flathubbot commented 2 years ago

Build 68775 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66610/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68859

flathubbot commented 2 years ago

Build 68859 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66694/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 68929

flathubbot commented 2 years ago

Build 68929 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66764/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 69614

flathubbot commented 2 years ago

Build 69614 failed

flathubbot commented 2 years ago

Started test build 69623

flathubbot commented 2 years ago

Build 69623 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/67463/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 69669

flathubbot commented 2 years ago

Build 69669 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/67510/com.prusa3d.PrusaSlicer.flatpakref
flathubbot commented 2 years ago

Started test build 69680

flathubbot commented 2 years ago

Build 69680 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/67520/com.prusa3d.PrusaSlicer.flatpakref
tamasmeszaros commented 2 years ago

Hello @xarbit ! I see that you've put some effort into forcing the adwaita-dark theme. Finding the env var will take some time for an average user who wants the light theme back. This is also a different policy from what the upstream implements. Is there a good reason for this workaround other than personal preference?

I'm also looking into the locale issue to find out if I can do something on our side. Thank you for your work in maintaining the Flatpak, you are doing a great job anyways!

tamasmeszaros commented 2 years ago

I don't know if this has been observed yet, but if you do flatpak install --reinstall org.freedesktop.Platform.Locale, the crashes will go away. All the platform locales will be installed in Flatpak land.

I don't know what policy is used during org.freedesktop.Platform.Locale installation to select the subset of locales. Also com.prusa3d.PrusaSlicer.Locale is installed with only a subset of languages. I also don't know how the subset is actually selected. The result is that when you want to select translations in PS, you don't have all the available translations from upstream. flatpak install --reinstall com.prusa3d.PrusaSlicer.Locale will make all the translations available.

xarbit commented 2 years ago

@tamasmeszaros thanks.. the reason for the dark theme was because of the default font color and the better appealing. And because windows and macOS have it too :). Don't worry, the default will be reverted when official released and made optional. I was planning to work on the code and push upstream to get it official including the support for gcode and 3mf mime files with icons.

For the languages, you need to change it in gnome settings and do a flatpak update. It will then download the language files that are missing.

I am also getting some documentation ready for prusa upstream wiki.

xarbit commented 2 years ago

To note.. the language was never the reason for the crashes. Before they where not split and always there. I only reworked it the flatpak way. The crashes mostly appeared when using mixed locale for language and measurements.

xarbit commented 2 years ago

@tamasmeszaros I set it optional https://github.com/flathub/com.prusa3d.PrusaSlicer/pull/38/commits/3ef949ba5ddd5c42e452387287011905fce0c086

xarbit commented 2 years ago

@tamasmeszaros see this issue for more information: https://github.com/flathub/com.prusa3d.PrusaSlicer/issues/27

tamasmeszaros commented 2 years ago

Hi @xarbit, ok with the dark theme, I trust your judgement :) .

That is strange, if the crashes were present when all the locales were installed. Just for the record, what I've found is that the crash (well it is a handled exception and a manual exit() call) is due to a boost::nowide::nowide_filesystem() call in PrusaSlicer.cpp which in turn calls boost::filesystem::path::imbue(). I've looked into the boost source code, and the function comments state the possibility of throwing an exception on Linux if the system locales are screwed up. For some reason, it needs to initialize the complete system locale only on Linux. So there is not much you can do other than catch the exception and exit the app. If I tried to ignore that exception, the app crashed at some point in the initialization. So at this point, I think your workaround is a good way to solve the problem.