Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 807691 - www-clients/firefox-bin: StartupWMClass missing in desktop file
Summary: www-clients/firefox-bin: StartupWMClass missing in desktop file
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-11 12:48 UTC by Jan Henke
Modified: 2022-02-09 13:35 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Active Firefox window without StartupWMClass in firefox-bin.desktop file (Active Firefox without StartupWMClass set.png,75.09 KB, image/png)
2021-08-17 13:36 UTC, Jan Henke
Details
Active Firefox window with StartupWMClass in firefox-bin.desktop file (Active Firefox with StartupCMClass set.png,71.05 KB, image/png)
2021-08-17 13:37 UTC, Jan Henke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Henke 2021-08-11 12:48:24 UTC
With the change to the desktop files introduced in firefox-bin 91 the old problem returns that GNOME cannot associate a running Firefox instance with the desktop file.

The problem probably comes from the differences between the runtime name (firefox) and the name of the binary (firefox-bin).

To fix it, the desktop file has to include another line telling GNOME the correct runtime name of the application, thereby allowing to focus on an existing instance when clicking the icon. This also gives Firefox the correct icon during runtime (instead of the generic icon).

For the desktop file:

StartupWMClass=firefox

Reproducible: Always




emerge --info 
Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1/desktop/gnome, gcc-10.3.0, glibc-2.33-r1, 5.10.52-gentoo-dist x86_64)
=================================================================
System uname: Linux-5.10.52-gentoo-dist-x86_64-Intel-R-_Core-TM-_i9-8950HK_CPU_@_2.90GHz-with-glibc2.33
KiB Mem:    32627588 total,   4281652 free
KiB Swap:   16777212 total,  16775676 free
Head commit of repository personal-overlay: 01550c3f337d1f67aeb3a309157d97d3bf28148b

Timestamp of repository gentoo: Wed, 11 Aug 2021 07:22:38 +0000
Head commit of repository gentoo: bc5714069983f08137f59159365d1d6293aabca4

Timestamp of repository guru: Mon, 09 Aug 2021 15:36:55 +0000
Head commit of repository guru: 6c1dd70bfe985a0f18b038af6dfefeb094f2111a

sh bash 5.1_p8
ld GNU ld (Gentoo 2.35.2 p1) 2.35.2
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0::gentoo
dev-lang/python:          3.9.6_p1::gentoo
dev-lang/rust-bin:        1.53.0::gentoo
dev-util/cmake:           3.20.5::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1-r1::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.13.4-r2::gentoo, 1.16.3-r1::gentoo
sys-devel/binutils:       2.35.2::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r1::gentoo
Repositories:

personal-overlay
    location: /var/db/repos/personal-overlay
    sync-type: git
    sync-uri: https://github.com/janhenke/personal-overlay
    masters: gentoo
    priority: -1500

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000
    sync-git-verify-commit-signature: true

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-march=native -mvzeroupper -mprefer-avx128 -ftree-vectorize -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.8/conf"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXX="clang++"
CXXFLAGS="-march=native -mvzeroupper -mprefer-avx128 -ftree-vectorize -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --autounmask=y --autounmask-write=n"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -mvzeroupper -mprefer-avx128 -ftree-vectorize -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -mvzeroupper -mprefer-avx128 -ftree-vectorize -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_DE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="de de_DE en en_GB"
MAKEOPTS="-j10"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa amd64 appindicator bluetooth bzip2 cairo cdda cdr clang cli client colord crypt cups dbus dri dts dvd dvdr eds elogind emboss encode evo exif flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk gui iconv icu introspection ipv6 jpeg jumbo-build kerberos lcms ldap libglvnd libnotify libsecret libtirpc llvm-libunwind lto mad mng mp3 mp4 mpeg multilib nautilus ncurses networkmanager nls nptl ogg opencl opengl openmp pam pango pcre pdf pic pie png policykit ppds pulseaudio qt5 readline screencast sdl seccomp spell split-usr ssl ssp startup-notification static-pie svg symlink sysprof system-llvm tcpd threads tiff tracker truetype udev udisks unicode upower usb v4l vaapi vdpau vim-syntax vorbis vulkan wayland wxwidgets x264 xattr xcb xml xv xvid zeroconf zlib zsh-completion zstd" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="de de-DE en en-GB" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="BPF NVPTX WebAssembly" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="i965 intel iris nouveau" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2021-08-11 13:45:33 UTC
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c208118615dc101a5098b4c2c05ac01027cb1dae

You don't need to re-emerge. Just set

> Icon=firefox-bin

in /usr/share/applications/firefox-bin.desktop
Comment 2 Jan Henke 2021-08-11 14:35:24 UTC
Unfortunately I have to reopen this bug. The commit you mentioned fixed the problem with the icon, still GNOME does not recognize the application belonging to the desktop file. For that to work, the line

StartupWMClass=firefox

needs to be present in the desktop file.
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2021-08-11 14:48:24 UTC
I am confused a little bit: How is this related to the change introduced in firefox-bin-91?  Only the wrapper was changed:

> --- firefox-bin.sh	2020-10-03 20:09:18.402975189 +0200
> +++ firefox-bin-r1.sh	2021-08-11 03:38:17.272732590 +0200
> @@ -29,18 +29,14 @@
>  MOZ_EXTENSIONS_PROFILE_DIR="${HOME}/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
>  MOZ_PROGRAM="${MOZILLA_FIVE_HOME}/${MOZ_FIREFOX_FILE}"
>  APULSELIB_DIR="@APULSELIB_DIR@"
> -DESKTOP_FILE="firefox-bin"
>  
>  ##
>  ## Enable Wayland backend?
>  ##
>  if @DEFAULT_WAYLAND@ && [[ -z ${MOZ_DISABLE_WAYLAND} ]]; then
> -	if [[ -n "$WAYLAND_DISPLAY" ]]; then
> -		DESKTOP_FILE="firefox-bin-wayland"
> +	if [[ -n "${WAYLAND_DISPLAY}" ]]; then
>  		export MOZ_ENABLE_WAYLAND=1
>  	fi
> -elif [[ -n ${MOZ_DISABLE_WAYLAND} ]]; then
> -	DESKTOP_FILE="firefox-bin-x11"
>  fi
>  
>  ##
> @@ -75,7 +71,7 @@
>  ##
>  ## Disable the GNOME crash dialog, Mozilla has its own
>  ##
> -if [[ "$XDG_CURRENT_DESKTOP" == "GNOME" ]]; then
> +if [[ "${XDG_CURRENT_DESKTOP}" == "GNOME" ]]; then
>  	GNOME_DISABLE_CRASH_DIALOG=1
>  	export GNOME_DISABLE_CRASH_DIALOG
>  fi
> @@ -111,13 +107,5 @@
>  export LD_LIBRARY_PATH="${APULSELIB_DIR:+${APULSELIB_DIR}:}${MOZILLA_FIVE_HOME}"
>  export GTK_PATH="${MOZ_LIB_DIR}/gtk-3.0"
>  
> -##
> -## Route to the correct .desktop file to get proper
> -## name and actions
> -##
> -if [[ $@ != *"--name "* ]]; then
> -	set -- --name "${DESKTOP_FILE}" "$@"
> -fi
> -
>  # Run the browser
> -exec ${MOZ_PROGRAM} "$@"
> +exec ${MOZ_PROGRAM} "${@}"
Comment 4 Jan Henke 2021-08-11 16:23:30 UTC
I am not sure either. I am just observing the behaviour stated above. There seems to be some heuristic in GNOME trying to match running applications with their desktop files. For some reason it worked before, but not any longer.

I have observed the same problem in the past before the X11/Wayland wrapper scripts were added. In any way, setting the StartupWMClass in the desktop file fixes the problem.

By the way the same problem also happened with thunderbird-bin.
Comment 5 Stefan Radermacher 2021-08-13 08:44:21 UTC
The missing icon issue also applies to www-client/firefox-91.0.
Comment 6 Thomas Deutschmann (RETIRED) gentoo-dev 2021-08-13 12:35:39 UTC
(In reply to Stefan Radermacher from comment #5)
> The missing icon issue also applies to www-client/firefox-91.0.

This has already been addressed via https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6daee8e9bcf380a5e83d80578f0146c1bfff59c0 but without a rev bump to avoid rebuilding such a large package. Just set

> Icon=firefox


in /usr/share/applications/firefox.desktop (or rebuild package with up-to-date repo).
Comment 7 Thomas Deutschmann (RETIRED) gentoo-dev 2021-08-17 13:13:18 UTC
Ah, I found https://forums.gentoo.org/viewtopic-t-1129209-start-0.html

I still believe this is not necessary and wrong because it would clash with www-client/firefox.

Could you please double check your icons? It could be possible that this showed up on your system, because you used wayland or x11 shortcut in previous releases (note that the wrapper routed you to these desktop files). But when you re-create/re-pin current shortcut, it should work again. Even without StartupWMClass.
Comment 8 Jan Henke 2021-08-17 13:36:52 UTC
Created attachment 733577 [details]
Active Firefox window without StartupWMClass in firefox-bin.desktop file
Comment 9 Jan Henke 2021-08-17 13:37:16 UTC
Created attachment 733579 [details]
Active Firefox window with StartupWMClass in firefox-bin.desktop file
Comment 10 Jan Henke 2021-08-17 13:41:30 UTC
I have taken two screen shots to illustrate the difference. In both cases the same applications are running. Notice that without the StartupWMClass in the desktop file, the currently running Firefox window has no icon and hitting the shortcut for the application starts a new instance.

While when it is defined, the running instance is associated with the favourite (first icon on the bar) and hitting the shortcut brings the focus back to the running window (as intended).

Yes, there could be a collision between the -bin and non-bin in that regard, but I see no real use case in having both. On the other hand, right now it is broken in regards to the interaction between the desktop environment and a running instance (if I wouldn't add StartupWMClass manually right now)
Comment 11 Leho Kraav (:macmaN @lkraav) 2021-09-06 11:12:09 UTC
So this is why my Alt-TAB switcher lost Firefox icon.

Confirmed, adding "StartupWMClass=firefox" worked well to restore it for www-client/firefox-bin.
Comment 12 Maxim Britov 2022-01-20 16:46:22 UTC
metoo

Works fine in Xorg session, but not under Wayland session.
Both firefox-bin and thunderbird-bin
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-01-20 16:46:49 UTC
This was driving me mad for ages, and adding that sorts it for me.
Comment 14 Larry the Git Cow gentoo-dev 2022-02-08 09:11:18 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=12e24437c4f01511acebb8fdcb717d5c4bdbccd6

commit 12e24437c4f01511acebb8fdcb717d5c4bdbccd6
Author:     Joonas Niilola <juippis@gentoo.org>
AuthorDate: 2022-02-08 08:54:49 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2022-02-08 09:10:58 +0000

    www-client/firefox-bin: add 91.6.0
    
    Bug: https://bugs.gentoo.org/807691
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 www-client/firefox-bin/Manifest                    |  97 ++++++
 .../firefox-bin/files/firefox-bin-r3.desktop       |   1 +
 www-client/firefox-bin/firefox-bin-91.6.0.ebuild   | 387 +++++++++++++++++++++
 3 files changed, 485 insertions(+)
Comment 15 Jan Henke 2022-02-08 10:15:24 UTC
Thanks for fixing this annoying behaviour for Firefox. Thunderbird-bin has the same problem, where it needs the line StartupWMClass=thunderbird in the desktop file. Can you fix that too, or does it need a new bug?
Comment 16 Joonas Niilola gentoo-dev 2022-02-08 10:19:51 UTC
Hey, 

I will when thunderbird-91.6.0 comes out (tomorrow most likely). To _close_ this bug I'd like to know how this can be fixed with wayland?
Comment 17 Jan Henke 2022-02-08 10:40:53 UTC
For me, adding this line also fixed the problem with GNOME under wayland. Others have commented that it would not work with wayland, but I cannot reproduce.
Comment 18 Leho Kraav (:macmaN @lkraav) 2022-02-08 11:32:48 UTC
(In reply to Jan Henke from comment #17)
> For me, adding this line also fixed the problem with GNOME under wayland.
> Others have commented that it would not work with wayland, but I cannot
> reproduce.

It works fine with Wayland. Have been doing this months.
Comment 19 Larry the Git Cow gentoo-dev 2022-02-09 13:35:21 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=50183945adf00b222451a8bdd141d40a685ce79a

commit 50183945adf00b222451a8bdd141d40a685ce79a
Author:     Joonas Niilola <juippis@gentoo.org>
AuthorDate: 2022-02-09 11:22:03 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2022-02-09 13:35:14 +0000

    mail-client/thunderbird-bin: add 91.6.0
    
    Closes: https://bugs.gentoo.org/807691
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 mail-client/thunderbird-bin/Manifest               |  65 ++++
 .../files/icon/thunderbird-bin-r2.desktop          |   1 +
 .../thunderbird-bin/thunderbird-bin-91.6.0.ebuild  | 335 +++++++++++++++++++++
 3 files changed, 401 insertions(+)