feat(media): add open_media_source callback option#684
feat(media): add open_media_source callback option#684stylebending wants to merge 5 commits intoamnweb:mainfrom
Conversation
|
Thanks for the PR! Quickly testing it and it only works for my browser as an audio source. Spotify app and YouTube Music (third party) app does not react to this callback. Edit: it works when the application is on another workspace (komorebi or glazewm) but not when it's minimized to taskbar/tray. I assumed this callback will also open the app, but it just changes the focus for me. |
Thanks for testing and the feedback, much appreciated! I've pushed a fix to handle minimized windows and also to focus the source window to make sure it is able to receive input immediately. This should be ready for another review. |
|
So tried testing multiple apps and some apps are working properly now like web browsers (Edge, Vivaldi), Spotify, Windows Media Player (the modern one) and various PWAs I have. |
|
yasb/src/core/utils/win32/window_actions.py Lines 77 to 105 in 15857a7 @stylebending what about these functions? Or do you still need to define restore if minimized inside AUMID? |
|
Updated! I'm now using Tested with GlazeWM, Brave, Chrome, Firefox, Spotify, Windows Media Player, seems to be working fine for all of them. |
Description
This PR addresses Discussion #683 to add a callback option to the Media Widget to open/activate the application currently playing media by clicking the widget.
Changes
docs/widgets/(Widget)-Media.md: Addedopen_media_sourceto callback documentation.src/core/utils/win32/aumid.py: Addedactivate_app_by_aumid(aumid: str)utility function. This usesEnumWindowsto find the window handle (HWND) associated with a given App User Model ID (AUMID) and brings it to the foreground.src/core/widgets/yasb/media.py:activate_app_by_aumid._open_media_sourcecallback method.open_media_sourceas a valid callback string.Configuration
Users can now configure this action in their
config.yaml:Rationale
While
source_apps.pyexists for mapping AUMIDs to display names, it does not provide window handles. The newactivate_app_by_aumidfunction fills this gap by dynamically finding the window owned by the media source'sAUMID, for activating any media application.If any tweaks are needed, or if I'm taking the wrong approach, I would love to hear the feedback to help out!