www-client/firefox: use wrapper
authorThomas Deutschmann <whissi@gentoo.org>
Mon, 30 Mar 2020 12:17:39 +0000 (14:17 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Mon, 30 Mar 2020 12:18:40 +0000 (14:18 +0200)
Backport of commit de3255e329bf23cd3e8247e475e75b374e53aec9.

Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
www-client/firefox/firefox-68.6.0-r2.ebuild

index 8aedb7bf41cb0768efe5914d4afc1d2eb7b8b7ba..a10f2faf8a77c23eaf02e17f2780c9c13acf91f1 100644 (file)
@@ -738,7 +738,6 @@ PROFILE_EOF
        done
        # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
        newicon "${icon_path}/default48.png" "${icon}.png"
-       newmenu "${FILESDIR}/icon/${PN}-r1.desktop" "${PN}.desktop"
 
        # Add StartupNotify=true bug 237317
        local startup_notify="false"
@@ -746,12 +745,61 @@ PROFILE_EOF
                startup_notify="true"
        fi
 
-       sed -i \
-               -e "s:@NAME@:${name}:" \
-               -e "s:@EXEC@:firefox:" \
-               -e "s:@ICON@:${icon}:" \
-               -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
-               "${ED%/}/usr/share/applications/${PN}.desktop" || die
+       local display_protocols="auto X11" use_wayland="false"
+       if use wayland ; then
+               display_protocols+=" Wayland"
+               use_wayland="true"
+       fi
+
+       local app_name desktop_filename display_protocol exec_command
+       for display_protocol in ${display_protocols} ; do
+               app_name="${name} on ${display_protocol}"
+               desktop_filename="${PN}-${display_protocol,,}.desktop"
+
+               case ${display_protocol} in
+                       Wayland)
+                               exec_command='firefox-wayland --name firefox-wayland'
+                               newbin "${FILESDIR}"/firefox-wayland.sh firefox-wayland
+                               ;;
+                       X11)
+                               exec_command='firefox-x11 --name firefox-x11'
+                               if use wayland ; then
+                                       # Only needed when there's actually a choice
+                                       newbin "${FILESDIR}"/firefox-x11.sh firefox-x11
+                               fi
+                               ;;
+                       *)
+                               app_name="${name}"
+                               desktop_filename="${PN}.desktop"
+                               exec_command='firefox'
+                               ;;
+               esac
+
+               newmenu "${FILESDIR}/icon/${PN}-r1.desktop" "${desktop_filename}"
+               sed -i \
+                       -e "s:@NAME@:${app_name}:" \
+                       -e "s:@EXEC@:${exec_command}:" \
+                       -e "s:@ICON@:${icon}:" \
+                       -e "s:@STARTUP_NOTIFY@:${startup_notify}:" \
+                       "${ED%/}/usr/share/applications/${desktop_filename}" || die
+       done
+
+       rm "${ED%/}"/usr/bin/firefox || die
+       newbin "${FILESDIR}"/firefox.sh firefox
+
+       local wrapper
+       for wrapper in \
+               "${ED%/}"/usr/bin/firefox \
+               "${ED%/}"/usr/bin/firefox-x11 \
+               "${ED%/}"/usr/bin/firefox-wayland \
+       ; do
+               [[ ! -f "${wrapper}" ]] && continue
+
+               sed -i \
+                       -e "s:@PREFIX@:${EPREFIX%/}/usr:" \
+                       -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \
+                       "${wrapper}" || die
+       done
 
        # Don't install llvm-symbolizer from sys-devel/llvm package
        [[ -f "${ED%/}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] && \