Teams-for-linux: Multiple Teams icons in dock (fix proposed)

Created on 18 Jul 2019  路  4Comments  路  Source: IsmaelMartinez/teams-for-linux

Describe the bug
After opening Teams for Linux in elementary OS, with its default dock (an elementary-patched version of Plank), a second, low-resolution icon appears in the dock in addition to the main high-resolution icon (which remains if pinned, and disappears after a few seconds if not).

To Reproduce
Steps to reproduce the behavior:

  • Install Teams for Linux (snap or deb) in elementary OS
  • Launch it from the dock or Applications Menu

Expected behavior
One (high resolution) icon that hosts all Teams for Linux windows.

Screenshots
2019-07-18 at 00 21 27 am

Desktop (please complete the following information):

  • OS: elementary OS "Juno" (based on Ubuntu 18.04+Gnome)
  • Installation package: I've tried both deb and snap
  • Version 0.3.0

Additional context
I've identified the following issues / solutions:

  • The .desktop file distributed with Teams for Linux includes StartupWMClass=teams-for-linux, but according to xprop the WM_CLASS of each window is actually "teams for linux" "Teams for Linux" (note the spaces instead of hyphens).
  • Manually updating the .desktop file with StartupWMClass="teams for linux" doesn't work (not with Plank, anyway--I'm not sure if other docks / window managers work better with spaces in WM_CLASS).
  • After investigating further, the incorrect WM_CLASS is being emitted as a result of the "productName": "Teams for Linux" entry in package.json. I confirmed this by removing the productName and rebuilding; the "name": "teams-for-linux" entry took precedence, WM_CLASS was set to to "teams-for-linux" "teams-for-linux", and the dock's window matching issue was resolved.
  • The downside of this is side-effects like $HOME/.config/Teams for Linux becoming $HOME/.config/teams-for-linux (meaning users will lose their configuration). It may be preferable to set WM_CLASS manually in some other way.

Locally, I've returned to stock 0.3.0 and worked around the problem by creating a user-specific desktop file (at ~/.local/share/applications):

[Desktop Entry]
Name=Microsoft Teams for Linux
Comment=Unofficial client for Microsoft Teams for Linux
Exec=/bin/bash /home/lina/Code/random-scripts/linux/start-teams-for-linux.sh %U
Terminal=false
Type=Application
Icon=teams-for-linux
StartupWMClass=teams-for-linux
MimeType=application/sip;
Categories=Chat;Network;Office;

And here's the Bash script:

#!/bin/bash

set -euo pipefail

"/opt/Teams for Linux/teams-for-linux" "$@" &

TEAMS_PID=$!

while ps -p "$TEAMS_PID" >/dev/null; do

    sleep 5

    TEAMS_WINDOWS=($(xwininfo -tree -root | grep -E '\("teams for linux" "Teams for Linux"\)[ 0-9+x-]*$' | grep -Eio '\b0x[0-9a-f]+\b')) || continue

    for TEAMS_WINDOW in "${TEAMS_WINDOWS[@]}"; do

        xprop -id "$TEAMS_WINDOW" -f WM_CLASS 8u -set WM_CLASS "teams-for-linux"

    done

done

Even this is imperfect, as Plank still associates the app's windows with the system-wide .desktop file, so you can't "pin" your user-specific launcher. Always launch from the Applications Menu.

bug

Most helpful comment

Hi, it will be great to add a pr with the fix (just removing the product name). Needing to log in again and copy a couple of files across should not be much of a problem for people using Linux. Thanks!!

All 4 comments

Hi, it will be great to add a pr with the fix (just removing the product name). Needing to log in again and copy a couple of files across should not be much of a problem for people using Linux. Thanks!!

Thanks @IsmaelMartinez. The one-line PR is in.

Thanks a lot!! Now, lets see how much it breaks ! (it should not break anything but you will be surprise of how different each packaging system is...)

I will close but might re-open if the snap people starts reporting issues. The snap edge channel is the 1st to get any stuff... for the good or the bad :) Thanks again for finding the issue and, even better, fixing it!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IsmaelMartinez picture IsmaelMartinez  路  7Comments

Bican007 picture Bican007  路  8Comments

tulanian picture tulanian  路  6Comments

jpiautinity picture jpiautinity  路  8Comments

theangryangel picture theangryangel  路  4Comments