pop-os / cosmic-applets

WIP applets for cosmic-panel
GNU General Public License v3.0
215 stars 87 forks source link

[App Tray] Some apps don't have proper icons and can't be pinned, notably Chrome #465

Closed VandaLHJ closed 5 months ago

VandaLHJ commented 5 months ago

Steps to reproduce:

Expected outcome:

wiiznokes commented 5 months ago

Brave works fine for me, are you using flatpak?

VandaLHJ commented 5 months ago

screenshot-2024-05-29-16-21-01 I'm using snap Brave, deb Chrome, deb Minecraft Launcher.

Edit: here is the cog icon.

mmstick commented 5 months ago

Needs to be tested with the latest commit

git-f0x commented 5 months ago

On my end, some apps that didn't previously display their icons now do display them (notably gnome-terminal). But some still don't, e.g. Archive Manager (file-roller) or Text Editor (gedit). If Krita is installed, gedit displays the Krita icon in the App Tray when launched and its context menu is also titled Krita. If it's pinned, it launches Krita afterwards. Also, Firefox no longer displays its icon (displays the default gear icon) in the App Tray with the latest commits.

wiiznokes commented 5 months ago

Are you using Snap?

git-f0x commented 5 months ago

No, these are just the default Pop!_OS packages (though Krita is installed as Flatpak for testing the icon for gedit). Edit: While I'm not familiar with how this works, why doesn't the App Tray get the icons the same way that the App Library does, since all icons seem to show up properly there (along with desktop actions)? Yes, something that is launched might not have a desktop entry, but those icons could be fetched in a different way, while the icons for things that do (and can be pinned) can be fetched the same way as the App Library does.

wiiznokes commented 5 months ago

As you say, a runtime windows doesn't have a desktop entry assigned to it. We only have an appid and the title of the windows to find the right entry. The problem is that the certain apps don't have the same appid declared in their desktop entry. Ex: gnome-terminal (gnome-terminal-server), code (code-url-handler), brave web apps, ect...

app library just fetch all desktop files and apply a query to them, so that's not the same problem

wiiznokes commented 5 months ago

@git-f0x Could you check if this branch works for you ?

git clone https://github.com/wiiznokes/cosmic-applets.git --branch fix-app-list
cd cosmic-applets/
just
sudo just install
  1. remove app-list applet from settings
  2. You can then see real time log using journalctl /usr/bin/cosmic-app-list -f
  3. add app list from settings

And report the logs if there are bugs.

For me, firefox works great (perfect match). Kitra, gedit, file-roller, gnome-terminal works fine. Two issue i've noticed

vscode

when launcing vscode from terminal, the appid will be vscode-url-handler. So when we fav this icon, vscode-url-handler will be in the list. When we launch vscode from fav, the appid will be code, so it will duplicate the icon.

Yt music

Youtube music web app on my laptop have the id cinhimbnkkaeohfgghhklpknlkffjgod, while on my other pc, it will be Brave brower (resulting in showing the brave icon, which is not good). Its really weird because they both on Fedora 40, with the same versions.

the command is flatpak 'run' '--command=brave' 'com.brave.Browser' '--profile-directory=Default' '--app-id=cinhimbnkkaeohfgghhklpknlkffjgod'

wiiznokes commented 5 months ago

For reference, this is the log i get for firefox:

juin 07 17:05:57 fedasus cosmic-app-list[8855]: add: "org.mozilla.firefox"
juin 07 17:05:57 fedasus cosmic-app-list[8855]: searching with org.mozilla.firefox
juin 07 17:05:57 fedasus cosmic-app-list[8855]: found: code for org.mozilla.firefox. Score: 0.05263157894736842
juin 07 17:05:57 fedasus cosmic-app-list[8855]: found dev.lapce.lapce for org.mozilla.firefox. Score: 0.10526315789473684
juin 07 17:05:57 fedasus cosmic-app-list[8855]: found org.squidowl.halloy for org.mozilla.firefox. Score: 0.21052631578947367
juin 07 17:05:57 fedasus cosmic-app-list[8855]: found org.mozilla.firefox for org.mozilla.firefox. Score: 1
mmstick commented 5 months ago

@wiiznokes Have you tried using the Firefox build from Mozilla's website? The startup wm class for Firefox is firefox from official Firefox builds.

wiiznokes commented 5 months ago

You mean this ? https://www.mozilla.org/en-US/firefox/download/thanks/ I don't really know how to test it, there is no .desktop file in it

wiiznokes commented 5 months ago

Maybe with the last fde, i added the exec and name field (even if this in not in the spec), so it should match firefox better

git-f0x commented 5 months ago

@git-f0x Could you check if this branch works for you ?

There are no logs printed when executing that command and then adding the App Tray. The Firefox icon is still missing, but gedit and file-roller now do have correct icons. Edit: The GNOME image viewer that was mentioned also displays the correct icon with that branch, while when using the repo version, it uses the OBS (also flatpak) icon on my end.

wiiznokes commented 5 months ago

There are no logs printed when executing that command and then adding the App Tray.

Can you try debugging this ? Maybe by running cargo run directly, it works sometimes

git-f0x commented 5 months ago

cargo run just says running cosmic-applets, but there are no new processes. There are are no logs for cosmic-applets ever. Anything in journalctl that has cosmic-applets somewhere is from cosmic-panel or cosmic-session. So not sure what to do.

VandaLHJ commented 5 months ago

There is some progress, and some loss. First of all, more apps can be pinned (telegram and chrome for example), but icon on firefox get lost, and those apps still don't have their icons.

wiiznokes commented 5 months ago

I made some changes on the fix-app-list branch, could someone test the last commit? (basically just lower the min score from 0.6 to 0.15 to match)

git-f0x commented 5 months ago

That seems to have caused a regression. Firefox still doesn't have an icon and Text Editor, Archive Manager and Image Viewer don't have the correct icon again.

wiiznokes commented 5 months ago

Hey but i just saw why you didn't got any logs lol @mmstick edited my comment. You must install cosmic-app-list separately to init the logs in main.

cd cosmic-applets/cosmic-app-list/
cargo build
sudo install -Dm0755 ../target/debug/cosmic-app-list /usr/bin/cosmic-app-list
wiiznokes commented 5 months ago

Would be helpful to get the logs so i can test on my own with fake desktop entries

mmstick commented 5 months ago

@wiiznokes The desktop entry is here: https://github.com/pop-os/packaging-firefox/blob/master/debian/firefox.desktop Icons from the package are found here:

/usr/share/icons/HighContrast/16x16/apps/firefox.png
/usr/share/icons/HighContrast/22x22/apps/firefox.png
/usr/share/icons/HighContrast/24x24/apps/firefox.png
/usr/share/icons/HighContrast/256x256/apps/firefox.png
/usr/share/icons/HighContrast/32x32/apps/firefox.png
/usr/share/icons/HighContrast/48x48/apps/firefox.png
/usr/share/icons/HighContrast/scalable/apps-extra/firefox-icon.svg
/usr/share/icons/hicolor/128x128/apps/firefox.png
/usr/share/icons/hicolor/16x16/apps/firefox.png
/usr/share/icons/hicolor/32x32/apps/firefox.png
/usr/share/icons/hicolor/48x48/apps/firefox.png
/usr/share/icons/hicolor/64x64/apps/firefox.png
mmstick commented 5 months ago

You can run plugins directly in a terminal like so: env RUST_LOG=debug cosmic-app-list.

These are the logs that I see

024-06-08T13:39:27.386027Z  INFO cosmic_app_list::app: add: "firefox"
2024-06-08T13:39:27.388670Z  WARN freedesktop_desktop_entry::matching: searching with firefox
2024-06-08T13:39:27.388678Z  WARN freedesktop_desktop_entry::matching: found: webapp-Pop!_OSChat5427 for firefox. Score: 0.08333333333333333
2024-06-08T13:39:27.388684Z  WARN freedesktop_desktop_entry::matching: found webapp-Reddit1698 for firefox. Score: 0.2857142857142857
2024-06-08T13:39:27.388691Z  WARN freedesktop_desktop_entry::matching: found userapp-Firefox-BTGEU1 for firefox. Score: 1
2024-06-08T13:39:27.388755Z  INFO cosmic_app_list::app: add: "WebApp-Element3483"
mmstick commented 5 months ago

Removing userapp-Firefox-BTGEU1.desktop seems to fix it. This file was created by Firefox. It lacks an icon entry. Perhaps icon searches should ignore entries lacking an icon, or at least fall back to looking for an icon of the same name.

wiiznokes commented 5 months ago

I assume if the match is 1 for userapp-Firefox-BTGEU1, it is because of the Name field. Maybe by removing it of the search it could fix it. If StartupWMClass is equal to firefox, it will not change anything tho

git-f0x commented 5 months ago

I've got this as the chosen entry for Firefox userapp-Firefox-CBNNI2. When launching Image Viewer (eog) with it using the OBS icon, there's the following log:

2024-06-08T14:10:53.032150Z  INFO cosmic_app_list::app: add: "eog"
2024-06-08T14:10:53.033974Z  WARN freedesktop_desktop_entry::matching: searching with eog
2024-06-08T14:10:53.033984Z  WARN freedesktop_desktop_entry::matching: found: userapp-Firefox-CBNNI2 for eog. Score: 0.14285714285714285
2024-06-08T14:10:53.034010Z  WARN freedesktop_desktop_entry::matching: found org.gnome.gitlab.YaLTeR.VideoTrimmer for eog. Score: 0.15384615384615385
2024-06-08T14:10:53.034020Z  WARN freedesktop_desktop_entry::matching: found com.obsproject.Studio for eog. Score: 0.3333333333333333

And this for gedit using the Krita icon:

2024-06-08T14:14:09.689723Z  INFO cosmic_app_list::app: add: "gedit"
2024-06-08T14:14:09.690992Z  WARN freedesktop_desktop_entry::matching: searching with gedit
2024-06-08T14:14:09.691001Z  WARN freedesktop_desktop_entry::matching: found: userapp-Firefox-CBNNI2 for gedit. Score: 0.14285714285714285  
2024-06-08T14:14:09.691020Z  WARN freedesktop_desktop_entry::matching: found org.kde.krita for gedit. Score: 0.4
wiiznokes commented 5 months ago

Can you cat org.kde.krita? Should be in /usr/share/applications/

git-f0x commented 5 months ago

It's a user installed flatpak (same as OBS), so its desktop entry is in ~/.local/share/flatpak/app/org.kde.krita/current/active/export/share/applications/. Pinning gedit then closing it and clicking on the icon launches Krita afterwards. Contents:

[Desktop Entry]
Name=Krita
Name[af]=Krita
Name[ar]=كريتا
Name[bg]=Krita
Name[br]=Krita
Name[bs]=Krita
Name[ca]=Krita
Name[ca@valencia]=Krita
Name[cs]=Krita
Name[cy]=Krita
Name[da]=Krita
Name[de]=Krita
Name[el]=Krita
Name[en_GB]=Krita
Name[eo]=Krita
Name[es]=Krita
Name[et]=Krita
Name[eu]=Krita
Name[fi]=Krita
Name[fr]=Krita
Name[fy]=Krita
Name[ga]=Krita
Name[gl]=Krita
Name[he]=Krita
Name[hi]=क्रिता
Name[hne]=केरिता
Name[hr]=Krita
Name[hu]=Krita
Name[ia]=Krita
Name[id]=Krita
Name[is]=Krita
Name[it]=Krita
Name[ja]=Krita
Name[ka]=Krita
Name[kk]=Krita
Name[ko]=Krita
Name[lt]=Krita
Name[lv]=Krita
Name[mr]=क्रिटा
Name[ms]=Krita
Name[nds]=Krita
Name[ne]=क्रिता
Name[nl]=Krita
Name[nn]=Krita
Name[pl]=Krita
Name[pt]=Krita
Name[pt_BR]=Krita
Name[ro]=Krita
Name[ru]=Krita
Name[se]=Krita
Name[sk]=Krita
Name[sl]=Krita
Name[sv]=Krita
Name[ta]=கிரிட்டா
Name[tg]=Krita
Name[tr]=Krita
Name[ug]=Krita
Name[uk]=Krita
Name[uz]=Krita
Name[uz@cyrillic]=Krita
Name[wa]=Krita
Name[xh]=Krita
Name[x-test]=xxKritaxx
Name[zh_CN]=Krita
Name[zh_TW]=Krita
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=krita --file-forwarding org.kde.krita @@ %F @@
GenericName=Digital Painting
GenericName[ar]=رسم رقمي
GenericName[bs]=Digitalno Bojenje
GenericName[ca]=Dibuix digital
GenericName[ca@valencia]=Dibuix digital
GenericName[cs]=Digitální malování
GenericName[da]=Digital tegning
GenericName[de]=Digitales Malen
GenericName[el]=Ψηφιακή ζωγραφική
GenericName[en_GB]=Digital Painting
GenericName[eo]=Cifereca Pentrado
GenericName[es]=Pintura digital
GenericName[et]=Digitaalne joonistamine
GenericName[eu]=Margolan digitala
GenericName[fi]=Digitaalimaalaus
GenericName[fr]=Peinture numérique
GenericName[gl]=Pintura dixital
GenericName[hi]=डिजिटल चित्रकारी
GenericName[hu]=Digitális festészet
GenericName[ia]=Pintura Digital
GenericName[id]=Pelukisan Digital
GenericName[is]=Stafræn málun
GenericName[it]=Pittura digitale
GenericName[ja]=デジタルペインティング
GenericName[ka]=ციფრული მხატვრობა
GenericName[kk]=Цифрлық сурет салу
GenericName[ko]=디지털 페인팅
GenericName[lt]=Skaitmeninis piešimas
GenericName[mr]=डिजिटल पेंटिंग
GenericName[nl]=Digitaal schilderen
GenericName[nn]=Digital teikning
GenericName[pl]=Malowanie cyfrowe
GenericName[pt]=Pintura Digital
GenericName[pt_BR]=Pintura digital
GenericName[ro]=Pictură digitală
GenericName[ru]=Цифровая живопись
GenericName[sk]=Digitálne maľovanie
GenericName[sl]=Digitalno slikanje
GenericName[sv]=Digital målning
GenericName[tr]=Sayısal Boyama
GenericName[ug]=سىفىرلىق رەسىم سىزغۇ
GenericName[uk]=Цифрове малювання
GenericName[x-test]=xxDigital Paintingxx
GenericName[zh_CN]=数字绘画程序
GenericName[zh_TW]=數位繪畫
MimeType=application/x-krita;image/openraster;application/x-krita-paintoppreset;
Comment=Digital Painting
Comment[ar]=رسم رقمي
Comment[bs]=Digitalno Bojenje
Comment[ca]=Dibuix digital
Comment[ca@valencia]=Dibuix digital
Comment[cs]=Digitální malování
Comment[da]=Digital tegning
Comment[de]=Digitales Malen
Comment[el]=Ψηφιακή ζωγραφική
Comment[en_GB]=Digital Painting
Comment[eo]=Cifereca Pentrado
Comment[es]=Pintura digital
Comment[et]=Digitaalne joonistamine
Comment[eu]=Margolan digitala
Comment[fi]=Digitaalimaalaus
Comment[fr]=Peinture numérique
Comment[gl]=Pintura dixital.
Comment[hi]=डिजिटल चित्रकारी
Comment[hu]=Digitális festészet
Comment[ia]=Pintura Digital
Comment[id]=Pelukisan Digital
Comment[is]=Stafræn málun
Comment[it]=Pittura digitale
Comment[ja]=デジタルペインティング
Comment[ka]=ციფრული მხატვრობა
Comment[kk]=Цифрлық сурет салу
Comment[ko]=디지털 페인팅
Comment[lt]=Skaitmeninis piešimas
Comment[mr]=डिजिटल पेंटिंग
Comment[nl]=Digitaal schilderen
Comment[nn]=Digital teikning
Comment[pl]=Malowanie cyfrowe
Comment[pt]=Pintura Digital
Comment[pt_BR]=Pintura digital
Comment[ro]=Pictură digitală
Comment[ru]=Цифровая живопись
Comment[sk]=Digitálne maľovanie
Comment[sl]=Digitalno slikanje
Comment[sv]=Digitalt målningsverktyg
Comment[tr]=Sayısal Boyama
Comment[ug]=سىفىرلىق رەسىم سىزغۇ
Comment[uk]=Цифрове малювання
Comment[x-test]=xxDigital Paintingxx
Comment[zh_CN]=自由开源的专业数字绘画程序
Comment[zh_TW]=數位繪畫
Type=Application
Icon=org.kde.krita
Categories=Qt;KDE;Graphics;2DGraphics;RasterGraphics;
X-KDE-NativeMimeType=application/x-krita
X-KDE-ExtraNativeMimeTypes=
StartupNotify=true
X-Krita-Version=28
StartupWMClass=krita
InitialPreference=99
X-Flatpak=org.kde.krita
wiiznokes commented 5 months ago

Yeah, so the it match, and since they both 5 letters, the final score is 2 / 5 = 0.4. And org.gnome.gedit or what ever will be 5 / 15=0.333. This is such a mess lol. I think this could be fixed by splitting the id and provide another match with the final part

wiiznokes commented 5 months ago

Would be handsome if you could also cat userapp-Firefox-CBNNI2

git-f0x commented 5 months ago

That entry is in the home directory in ~/.local/share/applications/ (/usr/share/applications/ has just firefox.desktop).

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/usr/lib/firefox/firefox-bin %u
Name=Firefox
Comment=Custom definition for Firefox
wiiznokes commented 5 months ago

Please retry with last commit

git-f0x commented 5 months ago

Seems to have fixed everything! Edit: Not everything, but most things. The Input Method app in the App Library uses the Krita icon in the App Tray. Desktop entry in /usr/share/applications/:

[Desktop Entry]
Name=Input Method
Comment=Set Keyboard Input Method
Type=Application
Keywords=keyboard;input
Exec=im-config
Terminal=false
Icon=input-keyboard
Categories=Settings
X-AppStream-Ignore=true
OnlyShowIn=KDE;LXQt;
X-Ubuntu-Gettext-Domain=im-config

Edit: GNOME Disks also doesn't have the correct icon, it uses the icon of the display settings page in GNOME Settings.

wiiznokes commented 5 months ago

Can you also provide the log from app-list? And the name of the desktop entry (this is the appid) It also shows that the App Library don't respect OnlyShowIn

git-f0x commented 5 months ago

Yeah, the App Library doesn't respect that option, and e.g. both System Monitor and GNOME System Monitor show up for the same app.

git-f0x commented 5 months ago

When launching Input Method, it shows up as zenity (the name of the desktop entry is im-config):

2024-06-08T15:11:57.664704Z  INFO cosmic_app_list::app: add: "zenity"
2024-06-08T15:11:57.666056Z  WARN freedesktop_desktop_entry::matching: searching with zenity
2024-06-08T15:11:57.666065Z  WARN freedesktop_desktop_entry::matching: found: userapp-Firefox-CBNNI2 for zenity. Score: 0.09090909090909091
2024-06-08T15:11:57.666073Z  WARN freedesktop_desktop_entry::matching: found ELDEN RING for zenity. Score: 0.2
2024-06-08T15:11:57.666088Z  WARN freedesktop_desktop_entry::matching: found org.kde.krita for zenity. Score: 0.3333333333333333

When launching GNOME Disks:

2024-06-08T15:13:38.513244Z  INFO cosmic_app_list::app: add: "gnome-disks"
2024-06-08T15:13:38.514585Z  WARN freedesktop_desktop_entry::matching: searching with gnome-disks
2024-06-08T15:13:38.514597Z  WARN freedesktop_desktop_entry::matching: found: userapp-Firefox-CBNNI2 for gnome-disks. Score: 0.045454545454545456
2024-06-08T15:13:38.514604Z  WARN freedesktop_desktop_entry::matching: found Sid Meier's Civilization VI for gnome-disks. Score: 0.07407407407407407
2024-06-08T15:13:38.514609Z  WARN freedesktop_desktop_entry::matching: found ELDEN RING for gnome-disks. Score: 0.09090909090909091
2024-06-08T15:13:38.514617Z  WARN freedesktop_desktop_entry::matching: found net.nokyan.Resources for gnome-disks. Score: 0.1
2024-06-08T15:13:38.514637Z  WARN freedesktop_desktop_entry::matching: found org.gnome.gitlab.YaLTeR.VideoTrimmer for gnome-disks. Score: 0.16666666666666666
2024-06-08T15:13:38.514643Z  WARN freedesktop_desktop_entry::matching: found io.github.shiftey.Desktop for gnome-disks. Score: 0.18181818181818182
2024-06-08T15:13:38.514672Z  WARN freedesktop_desktop_entry::matching: found gnome-region-panel for gnome-disks. Score: 0.3333333333333333
2024-06-08T15:13:38.514706Z  WARN freedesktop_desktop_entry::matching: found org.gnome.eog for gnome-disks. Score: 0.38461538461538464
2024-06-08T15:13:38.514722Z  WARN freedesktop_desktop_entry::matching: found gnome-display-panel for gnome-disks. Score: 0.47368421052631576

Edit: Those are the only 2 installed apps on my end that don't use correct icons.

wiiznokes commented 5 months ago

When launching Input Method, it shows up as zenity (which is weird):

At this point, idt if there is anything we can do lol (maybe a fall back to the title, but in this case, what is the min score).

For gnome-disk, it display gnome-tweaks on my end:

juin 08 17:18:02 fedasus cosmic-app-list[39024]: add: "gnome-disks"
juin 08 17:18:02 fedasus cosmic-app-list[39024]: searching with gnome-disks
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found: code for gnome-disks. Score: 0.1111111111111111
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found ca.desrt.dconf-editor for gnome-disks. Score: 0.16666666666666666
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found com.obsproject.Studio for gnome-disks. Score: 0.18181818181818182
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found com.discordapp.Discord for gnome-disks. Score: 0.2727272727272727
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found gnome-disk-image-mounter for gnome-disks. Score: 0.4166666666666667
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found gnome-disk-image-writer for gnome-disks. Score: 0.43478260869565216
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found org.gnome.DiskUtility for gnome-disks. Score: 0.45454545454545453
juin 08 17:18:02 fedasus cosmic-app-list[39024]: found org.gnome.tweaks for gnome-disks. Score: 0.5

This could be fixed by replacing all - with .. I will try to make a fix

git-f0x commented 5 months ago

When launching im-config from a terminal, all output is prefixed with (zenity:* E.g.

(zenity:16048): Gtk-WARNING **: 17:25:46.033: Theme parsing error: gtk.css:56:7: 'filter' is not a valid property name
wiiznokes commented 5 months ago

I fixed the gnome-disk pb on my end. I added the Exec field which contains gnome-disk . I hope it will not cause problem. I also added a malus of 0.06 for Exec.