Jump to content

Feature request: native minimize client to tray


Recommended Posts

Posted

Hi Emby team,

First, thanks for Emby. I run it as the media hub for my living-room HTPC and it has been rock solid.

## What I am trying to solve

On a dedicated HTPC, I want the Emby client to get out of the way when I am not actively watching, and come back when I am:

- Start with windows minimized to tray - so that I can use my phone to select the htpc as play on target.
- Pause playback -> hide the client to the system tray.
- Resume -> bring it back to the foreground.
- Playback starts -> show it; playback stops/ends -> hide it.

This is a really nice "appliance" experience on a TV-connected PC: the client is there when you need it and invisible when you do not, without ever landing on the desktop or taskbar.

## What I built as a stopgap

Because I could not do this from within Emby, I wrote a small standalone Windows tray agent, "Emby Tray":

https://github.com/vdb86/Emby-Tray

It polls the server's `GET /Sessions` endpoint, filters to this machine's own session (by local network address / client name / device name), reads `PlayState.IsPaused` and the now-playing item, and then uses Win32 (`EnumWindows` + `ShowWindow`) to hide/restore the client window. It runs entirely outside the client install so client updates never touch it.

It works well, but it is fundamentally a workaround, and I would much rather this behavior lived in Emby itself so nobody needs a side-car process.

## Why this cannot be done as a normal plugin today

I looked hard at doing this "properly" first, and hit a wall that I think only you can remove:

1. A server-side catalog plugin can subscribe to `ISessionManager` playback events and read `PlayState.IsPaused`, so it can perfectly DETECT pause/resume. But it runs on the server and has no way to touch a client's OS window or tray.
2. A client-side (Theater web/JS) plugin knows the play/pause state directly via the web `playbackManager` events, but it runs in the web sandbox and cannot reach the OS tray or minimize the native window.
3. The server-to-client `GeneralCommand` path is the natural bridge, but `GeneralCommandType` has no command for this. It has `ToggleFullscreen`, `SetVolume`, `Mute`, `GoHome`, `DisplayMessage`, `SendKey`, `SendString`, and so on, but nothing like `MinimizeToTray` / `RestoreWindow` / `Minimize`.

So detection is fully supported, but the "hide/restore the native window" half is not exposed to any plugin surface. That gap is why an external agent is currently the only option.

## What would be needed from your end

Any one of these would let this be done natively (roughly in order of how self-contained they are):

1. Best: build it into the desktop client directly. Add a tray icon plus a "minimize to tray on pause / restore on resume" option (and a "start minimized to tray" option) in the client's settings. Nothing external needed, and it would be a great HTPC feature out of the box.
2. Or: add `GeneralCommandType` values such as `MinimizeToTray` / `RestoreWindow` (and ideally `Minimize` / `Restore`) that the desktop client honors. Then even a small server plugin could drive the behavior on pause/resume.
3. Or: expose a minimal NativeShell API to Theater client plugins (for example `nativeShell.window.hideToTray()` / `show()`), so a client plugin reacting to `playbackManager` pause/unpause events could do the window/tray control itself.

Option 1 is what I would love most, since it removes the need for any plugin at all. Options 2 or 3 would let the community build it cleanly.

## Offer

The full working implementation, including the session-matching logic and the Win32 hide/restore handling, is open source at the link above under GPLv3, so please feel free to reference it for the detection/behavior model. Happy to answer questions, test builds, or help however is useful.

Thanks for considering it.

 

P.s. I'm also open to trying to help with optimizing the windows app code (start faster, etc.)
 

Posted

Hi, we'll take a look at this. Thanks.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...