Here's a one-liner to fix the issue as described in Gabriel's answer:
cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications && sed --in-place --regexp-extended 's/^(\[[A-Za-z ]+\])$/\1\nStartupWMClass=Google-chrome-stable/g' ~/.local/share/applications/google-chrome.desktop
To unpack and explain this command line a bit: first it copies (cp
) the global .desktop file to your user directory, since the latter overrides the former for the current user, and isn't changed by package upgrades.
If that operation succeeds (&&
), it then uses the sed
command to do a find-replace operation, which follows the pattern sed s's/<find>/<replace>/<flags><flags>'
(where s
stands for "substitute"). Step by step, here's what that sed
command says:
find all lines that start with
[
and end with]
(that's the^(\[[A-Za-z ]+\])$
part — RegExr or Regex101 can explain it much better than I could here :))replace them with themselves (
\1
) followed by a newline (\n
) and the string "StartupWMClass=Google-chrome-stable"and do this to all of them, i.e. using the global flag (
/g
), and directly editing the file (--in-place
) rather than outputting to the shell. The last argument is the filename to pass tosed
, which is the file thecp
command has just created.