mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 14:40:25 +01:00
[BUG]: Bar cannot display UWP Icons (PR with fix already exists) #561
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @davor-skontra on GitHub (Jan 11, 2025).
Summary
UWP -> Universal Windows Platform
I created a PR in LGUG2>/window-icons repo that merges upstream changes with a fix.
Thought I'd also create this bug report so the PR doesn't go unnoticed.
Version Information
Any version since bar was introduced.
Komorebi Configuration
Hotkey Configuration
#Requires AutoHotkey v2.0.2
#SingleInstance Force
Komorebic(cmd) {
RunWait(format("komorebic.exe {}", cmd), , "Hide")
}
!q::Komorebic("close")
!m::Komorebic("minimize")
; Focus windows
!h::Komorebic("focus left")
!j::Komorebic("focus down")
!k::Komorebic("focus up")
!l::Komorebic("focus right")
!+[::Komorebic("cycle-focus previous")
!+]::Komorebic("cycle-focus next")
; Move windows
!+h::Komorebic("move left")
!+j::Komorebic("move down")
!+k::Komorebic("move up")
!+l::Komorebic("move right")
; Stack windows
#Left::Komorebic("stack left")
#Down::Komorebic("stack down")
#Up::Komorebic("stack up")
#Right::Komorebic("stack right")
!#Down::Komorebic("unstack")
#,::Komorebic("cycle-stack previous")
#.::Komorebic("cycle-stack next")
; Resize
#^Right::Komorebic("resize-axis horizontal increase")
#^Left::Komorebic("resize-axis horizontal decrease")
#^Up::Komorebic("resize-axis vertical increase")
#^Down::Komorebic("resize-axis vertical decrease")
; Manipulate windows
!t::Komorebic("toggle-float")
!f::Komorebic("toggle-monocle")
; Window manager options
!+r::Komorebic("retile")
!p::Komorebic("toggle-pause")
; Layouts
!x::Komorebic("flip-layout horizontal")
!y::Komorebic("flip-layout vertical")
; Workspaces
#1::Komorebic("focus-workspace 0")
#2::Komorebic("focus-workspace 1")
#3::Komorebic("focus-workspace 2")
#4::Komorebic("focus-workspace 3")
#5::Komorebic("focus-workspace 4")
#6::Komorebic("focus-workspace 5")
#7::Komorebic("focus-workspace 6")
#8::Komorebic("focus-workspace 7")
; Move windows across workspaces
#+1::Komorebic("move-to-workspace 0")
#+2::Komorebic("move-to-workspace 1")
#+3::Komorebic("move-to-workspace 2")
#+4::Komorebic("move-to-workspace 3")
#+5::Komorebic("move-to-workspace 4")
#+6::Komorebic("move-to-workspace 5")
#+7::Komorebic("move-to-workspace 6")
#+8::Komorebic("move-to-workspace 7")
; Run shortcuts
#t::Run("wezterm -e", , "Hide")
Output of komorebic check
No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\THEkr
Looking for configuration files in C:\Users\THEkr
Found komorebi.json; this file can be passed to the start command with the --config flag
Found C:\Users\THEkr.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag
@LGUG2Z commented on GitHub (Jan 12, 2025):
Thanks for opening this PR! I actually didn't get notified of the underlying PR to the
windows-iconsrepo, I'll take a look soon 🤞@LGUG2Z commented on GitHub (Jan 12, 2025):
I played with this a little today and the issue with UWP apps is that they are all running as
ApplicationFrameworkHost.exe, and when you pass theprocess_idof these apps to the library to go and look up their icons, they can't be uniquely identified 🤔Not sure how to proceed with this, maybe @AmnWeb has some ideas from yasb that we can bring here.
@amnweb commented on GitHub (Jan 12, 2025):
UWP apps might need a moment to start under ApplicationFrameHost, maybe that's the problem?
An example of how I solved this
cd336fa718/src/core/widgets/yasb/active_window.py (L195)@davor-skontra commented on GitHub (Jan 12, 2025):
Thanks for that Amnweb! I'll try the same approach!
@davor-skontra commented on GitHub (Jan 15, 2025):
Ok, I did some debugging and it looks like
window-iconsis actually able to get a path to the windows terminal icon (which exists in the file system, checked).The process fails on the next step when trying to read image to base 64.
I think it has to do with the icon format. Arc Browser uses
.ico, terminal uses.png. Arc Browser icon gets loaded, Terminal does not. Both are UWP apps.I'm not sure how encodings work and what they do. also don't know much about these image formats in general.
I'll try to figure it out over the weekend but advice is welcome. 😁
@LGUG2Z commented on GitHub (Jan 15, 2025):
I think I remember when I looked inside the path given for the file on my system, the file referenced didn't actually exist 👀 Can you check if this is the case for you also?
@davor-skontra commented on GitHub (Jan 18, 2025):
Double checked. Yeah you are right, that exact file does not exist.
window-iconsis making use of theApplicationMaifest.xmlto figure out where the icon is, assuming it is within the<Logo>tags.However Terminal seems to be doing something else with that.
The manifest has this
<Logo>Images\StoreLogo.png</Logo>While the files have info appended to the name like here.
I'm not sure what's happening here or how common this approach is with other uwp applications.
@amnweb commented on GitHub (Jan 18, 2025):
I think you need to find
VisualElementsin the manifest and look forSquare44x44Logo, this should be a png, jpg or jpeg image and this is what you need for the icon.Sorry I don't know about Rust, but here's what I mean, something like example below (Python) to cover all Win11 and Win10
Then, once you get the Square44x44 logo path, you can easily manipulate the image as you wish.
For more complex function see this file https://github.com/amnweb/yasb/blob/main/src/core/utils/win32/app_icons.py
Edit:
@davor-skontra commented on GitHub (Jan 19, 2025):
Thanks a bunch @amnweb !
Looks like there are a quite a few things that would need handling to get this working in a Microsoft way but a quick hack for now seems reasonable
Windows Terminal makes use of icon scaling so to solve I could just grab the closest Icon to 100% scale I can find and if that doesn't work I can search upward for a closest larger scale icon.
Another thing I didn't consider, but you seem to be handling to a degree are localizations, contrast and things like that. I don't have a clear plan there yet.
@davor-skontra commented on GitHub (Jan 20, 2025):
OK, got something working though could be more polished. More info in the original PR.
@LGUG2Z commented on GitHub (Jan 20, 2025):
We are definitely getting closer! I can see the WT icon coming through properly now. The next issue to tackle will be handling the Icons for
ApplicationFrameworkHost.exeapps like Settings, which are still showing what I imagine is a default/fallback icon from where:@davor-skontra commented on GitHub (Jan 20, 2025):
Alrriighty. That ApllicationFrameworkHost is another system then. I'll try to tackle that one as well.
Am also hoping to tackle scaling in such a way that you could pass that down as a param when calling
get_icon_by_*methodsI think this is a better approach then the library trying to figure out what the user wants to do and reading the scale info directly from system.
If needed I can also do that in a non API breaking way by adding a separate method for using the matcher.
Side note, that
IconMatcherstruct would later also pass things like localization data down the line so we can get the correct icon for localized apps.@davor-skontra commented on GitHub (Jan 27, 2025):
Just FYI, I haven't given up on this. 😬
Had a busy weekend, so no progress then but today I managed to add that icon scaling support.
This should also make it easier to support other icon sizes, localizations and accessibility things like high contrast icons in the future.
Anyhow what I did is pretty similar to what Amnweb is doing here
The default function signatures remain as they were for backward compatibility so no API breaking changes but if you want to make use of that with the
komorebi-baryou could.The ApplicationFrameworkHost is next on my To-Do list.
@davor-skontra commented on GitHub (Feb 16, 2025):
After a few weeks of making a hole in the wall with my forehead I got it to work! 🥳
I had to add a new public API function to look up icons with
HWND-s as I couldn't figure out how to do it fromprocess_idI need to clean things up a bit, still, remove unwarps and debug lines that might be lurking etc, but you can try it already if you'd like, just use the
get_icon_by_hwndorget_icon_by_hwnd_matchingmethods instead!Ill let you know when I've cleaned things up for hopefully final round of reviews but meanwhile do let me know if there is something wrong from the API side that would need to be adressed 🙏 !
@davor-skontra commented on GitHub (Mar 2, 2025):
Hello! This should be ready for another review!
I wrote a bit about the implementation details in the PR.
@LGUG2Z commented on GitHub (Mar 3, 2025):
Thank you! I will try to take a look at all of your great work this week 🤞
@davor-skontra commented on GitHub (Mar 22, 2025):
@LGUG2Z commented on GitHub (Mar 22, 2025):
I did look at this! As far as I can tell there are no breakages, but I was still not able to get icons showing for UWP apps like Settings etc.
I'll tag this with 0.1.36 and we can get this into the next nightly after the 0.1.35 release for some wider feedback 🤞
@davor-skontra commented on GitHub (Mar 22, 2025):
Thanks! That's strange, I had settings and other icons working. I'll check what's up with that!
@LGUG2Z commented on GitHub (Mar 23, 2025):
This is what I see when using this commit of windows-icons on komorebi-bar
@LGUG2Z commented on GitHub (Mar 23, 2025):
Nevermind, I just need to read more carefully - I can now see this once I change the fn to the hwnd variant:
@davor-skontra commented on GitHub (Mar 23, 2025):
Awsome! Thanks for the PR!
Komorebi is an awesome piece of software and it makes me happy I was able to contribute to it in a small way! Working with Rust for the first time was interesting as well!