commit:     47d6aa9a9b0f1005f4fd592e6d6372c6f18b606d
Author:     Artemis Everfree <artemis <AT> artemis <DOT> sh>
AuthorDate: Wed Jan  3 06:29:40 2024 +0000
Commit:     David Roman <davidroman96 <AT> gmail <DOT> com>
CommitDate: Wed Jan  3 06:29:40 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=47d6aa9a

app-office/obsidian: Provide X11 and Wayland .desktop files together

For some users, Obsidian works fine with native wayland. For others, it
crashes. See https://bugs.gentoo.org/915899

To make this easier for users to deal with, provide both .desktop files
in the installation so they can switch between them to see what works.
Warn during install that they should try this if they see crashes.

Signed-off-by: Artemis Everfree <artemis <AT> artemis.sh>

 ...ian-1.4.16.ebuild => obsidian-1.4.16-r1.ebuild} | 50 +++++++++++++++++++---
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/app-office/obsidian/obsidian-1.4.16.ebuild 
b/app-office/obsidian/obsidian-1.4.16-r1.ebuild
similarity index 67%
rename from app-office/obsidian/obsidian-1.4.16.ebuild
rename to app-office/obsidian/obsidian-1.4.16-r1.ebuild
index b07d924ffa..8baafd637c 100644
--- a/app-office/obsidian/obsidian-1.4.16.ebuild
+++ b/app-office/obsidian/obsidian-1.4.16-r1.ebuild
@@ -31,7 +31,7 @@ LICENSE="Obsidian-EULA"
 
 SLOT="0"
 KEYWORDS="~amd64 ~arm64"
-IUSE="appindicator wayland"
+IUSE="appindicator"
 
 RDEPEND="
        >=app-accessibility/at-spi2-core-2.46.0:2
@@ -97,11 +97,38 @@ src_prepare() {
        pushd "${S_OBSIDIAN}/locales/" >/dev/null || die "location change for 
language cleanup failed"
        chromium_remove_language_paks
        popd >/dev/null || die "location reset for language cleanup failed"
-       if use wayland; then
-               sed -i '/Exec/s/obsidian/obsidian --ozone-platform-hint=auto 
--enable-features=UseOzonePlatform,WaylandWindowDecorations/' \
-                       "usr/share/applications/obsidian.desktop" ||
-                       die "sed failed for wayland"
-       fi
+
+       # Create separate .desktop file for launching Obsidian with native 
wayland
+       # support.
+       #
+       # Obsidian is an Electron app, and Electron can be instructed to run in
+       # native-wayland mode by turning on the Ozone platform. However, doing 
this
+       # causes Obsidian to crash on some users' systems, while it works fine 
for
+       # others. (see https://bugs.gentoo.org/915899)
+       #
+       # It appears VSCode may have encountered a similar issue, because VSCode
+       # installs two separate .desktop files, one for launching with wayland
+       # support and one for launching without. We will do the same here.
+
+       # Create a copy of upstream's .desktop
+       cp usr/share/applications/obsidian.desktop \
+               usr/share/applications/obsidian-wayland.desktop \
+               || die "failed to create obsidian-wayland.desktop file"
+
+       # Edit the Exec & Name
+       sed -i \
+               '
+                       # Add Electron ozone enable flags to obsidian execution
+                       /Exec/s/obsidian /obsidian --ozone-platform-hint=auto 
--enable-features=UseOzonePlatform,WaylandWindowDecorations /
+
+                       # Give this .desktop file a new name/desc of "Obsidian 
Wayland"
+                       /^Name/s/$/ Wayland/
+
+                       # comment field
+                       /^Comment/s/$/ with Wayland support enabled/
+               ' \
+               'usr/share/applications/obsidian-wayland.desktop' ||
+               die "sed failed for obsidian-wayland.desktop file"
 }
 
 src_install() {
@@ -133,8 +160,19 @@ src_install() {
        fi
 
        domenu usr/share/applications/obsidian.desktop
+       domenu usr/share/applications/obsidian-wayland.desktop
 
        for size in 16 32 48 64 128 256 512; do
                doicon --size ${size} 
usr/share/icons/hicolor/${size}x${size}/apps/${PN}.png
        done
 }
+
+pkg_postinst() {
+       ewarn "Some users have reported that running Obsidian with native 
Wayland"
+       ewarn "support causes the software to crash. Others have it working"
+       ewarn "without issue. See https://bugs.gentoo.org/915899";
+       ewarn ""
+       ewarn "This package now provides application entries for both Obsidian 
and"
+       ewarn "Obsidian Wayland. If Obsidian Wayland breaks for you under 
Wayland,"
+       ewarn "try the other Obsidian entry to launch with XWayland"
+}

Reply via email to