Summary
I've built a companion Windows service for DisplayMagician that enables remote display profile switching via a Telegram bot. I'd love to collaborate and contribute this upstream if there's interest.
What it does
- Telegram Bot — Switch display profiles remotely from your phone with inline buttons
- Windows Service — Runs at system level, works even when PC is locked or on the login screen
- Session Lock Auto-Revert — Automatically reverts to a default profile when the PC is locked (event-driven via
ServiceBase.OnSessionChange, zero polling)
- User Session Switching — Switch between Windows user accounts (e.g., a dedicated media/gaming user) alongside display profiles
- App Launching — Launch apps (Steam Big Picture, browsers, etc.) as part of the profile switch
- Graceful App Cleanup — Close running apps when switching modes (WM_CLOSE first, then force kill)
Use Case
My setup has a PC connected to both a monitor and a TV. I needed a way to:
- Switch display profiles remotely (from my phone while on the couch)
- Automatically revert when I'm done (session lock detection)
- Switch to a dedicated TV user account with no password for media/gaming
- Launch Steam Big Picture or other apps as part of the switch
Technical Details
- Built as a .NET 8 Windows service using
DisplayMagicianConsole.exe for profile switching
- Uses
CreateProcessAsUser to run profile changes in the correct user session from Session 0
- Session lock detection via custom
WindowsServiceLifetime subclass (event-driven, not polling)
- User switching via
tscon/tsdiscon (no-password accounts automated, password accounts show login screen)
- Security: Telegram user ID whitelist, rate limiting, silent deny for unauthorized users
- Thread-safe with proper locking and
ConcurrentDictionary
- Configurable via
appsettings.json
Current Implementation
The code is in my fork: https://github.com/TzachiSh/DisplayMagician/tree/develop/DisplayMagicianService
I also made a few fixes to the main DisplayMagician app:
- Fixed crash when Windows notification platform is unavailable (common on Insider builds)
- Fixed
NullReferenceException in profile JSON error handler when InnerException is null
- Added
DISPLAYMAGICIAN_DATA_PATH env var support for shared profiles across users
Collaboration
Would you be interested in integrating this as part of DisplayMagician? I'm happy to:
- Clean up the code further to match project conventions
- Create a proper PR with separate commits for each feature
- Add the service as an optional component
- Work on any changes you'd like to see
Let me know if this is something you'd consider!
Summary
I've built a companion Windows service for DisplayMagician that enables remote display profile switching via a Telegram bot. I'd love to collaborate and contribute this upstream if there's interest.
What it does
ServiceBase.OnSessionChange, zero polling)Use Case
My setup has a PC connected to both a monitor and a TV. I needed a way to:
Technical Details
DisplayMagicianConsole.exefor profile switchingCreateProcessAsUserto run profile changes in the correct user session from Session 0WindowsServiceLifetimesubclass (event-driven, not polling)tscon/tsdiscon(no-password accounts automated, password accounts show login screen)ConcurrentDictionaryappsettings.jsonCurrent Implementation
The code is in my fork: https://github.com/TzachiSh/DisplayMagician/tree/develop/DisplayMagicianService
I also made a few fixes to the main DisplayMagician app:
NullReferenceExceptionin profile JSON error handler whenInnerExceptionis nullDISPLAYMAGICIAN_DATA_PATHenv var support for shared profiles across usersCollaboration
Would you be interested in integrating this as part of DisplayMagician? I'm happy to:
Let me know if this is something you'd consider!