GithubHelp home page GithubHelp logo

arun-goud / wintermelon Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 5.0 560 KB

C# workaround that emulates dual/multi monitor lockscreen feature in Windows 10/11

License: GNU General Public License v2.0

C# 82.92% PowerShell 17.08%
windows10 windows11 dotnet powershell csharp lockscreen multi-monitor-setup dual-monitors dual-screen schedule-tasks

wintermelon's Introduction

Wintermelon

Wintermelon is a C# console app-based workaround that emulates dual/multi monitor lockscreen feature in Windows 10/11. The ability to duplicate lockscreen existed until Windows 7 but Windows 10 & 11 have chosen to forgo this feature by displaying the lockscreen only on primary (or main) display while the secondary (or non-main) displays go black.

The name Wintermelon is an acronym with 2 possible expansions:

  • WINdows Ten & Eleven Rendering of Mirrored Event-triggered Lockscreens On Non-main displays

  • WINdows Ten & Eleven Restorer of Multiple Equivalent Lockscreens On Non-main displays

Here's a demo showing Wintermelon in action on Windows 11: Dual lockscreen on laptop screen and external display implemented on a Win11 machine using Wintermelon

How it works

In Windows 10 & 11, lockscreen will appear on multiple displays only if the display projection mode (accessed by pressing Win+P hotkey) is set to "Duplicate". Most users will typically use primary/secondary (main/non-main) monitors in "Extend" mode to multitask between various opened application windows. Wintermelon sets up a scheduled task that monitors for lock/unlock events. When a lock event is detected the projection mode is switched to "Duplicate" which will replicate the main display's lockscreen across all non-main displays and when an unlock event is triggered the projection mode will revert to "Extend" mode. Before switching to "Duplicate" mode the position of opened application windows on the desktop are recorded since the duplication of displays will cause all windows to move over to the primary/main display. When reverting to "Extend" mode following the unlock event the recorded positions are retrieved and used to reposition/restore the application windows to their original state.

Requirements

Wintermelon is a C# project relying on .NET Core 3.1 and it was originally developed on & for Windows 10 using Visual Studio 2019.

To build Wintermelon executable you'll need:

  1. .NET Core SDK 3.1

  2. Visual Studio IDE

  3. Windows PC

To test and install Wintermelon you'll need:

  1. Windows 10 or Windows 11 PC

  2. .NET Core Runtime 3.1

  3. PowerShell

  4. Lockscreen enabled via Personalize settings menu

The installer for the C# executable is a PowerShell script which will need to be executed by running it within a PowerShell terminal launched using administrator mode.

Lockscreen personalization settings

To enable lockscreen for primary display in Windows 10 & 11:

  1. Right click on desktop and choose Personalize.

  2. Search for Lock screen setting. Choose appropriate lockscreen background. Pick Windows spotlight for background if you want Windows to dynamically update lockscreen background.

  3. In Windows 11, turn on the option Show the lock screen background picture on the sign-in screen.

  4. Go to Screen timeout settings and set the sleep setting When plugged in, turn off after to Never if you don't want the lockscreen to timeout.

  5. When doing a sign-in the lockscreen background typically becomes blurred. Follow these instructions to turn off this acrylic blur effect.

Building the executable

  1. Open the solution file Wintermelon.sln in Visual Studio. The C# source code resides in Program.cs.

  2. Build the solution by choosing Build --> Build Solution (Ctrl+Shift+B) from the menu bar.

  3. If there are no build errors then select Build --> Publish Wintermelon and pass the following publish information:

    Target location=bin\Release\netcoreapp3.1\publish\

    Configuration=Release

    Delete existing files=false

    Target Framework=netcoreapp3.1

    Target Runtime=win-x64

    Expand "Show all" and set the options under it to following values:

    Configuration=Release | Any CPU

    Target framework=netcoreapp3.1

    Deployment mode=Framework-dependent

    Target runtime=win-x64

    Target location=bin\Release\netcoreapp3.1\publish\

    Expand "File publish options", set Produce single file as checked and leave Enable ReadyToRun compilation unchecked.

  4. Press Publish button which will generate the executable Wintermelon.exe at the path bin\Release\netcoreapp3.1\publish\Wintermelon.exe relative to the C# solution folder.

This executable handles the switching of projection mode between Duplicate and Extend modes during lock/unlock events and does recording, retrieval of window positions from a text file saved at C:\Users\Your_Username\AppData\Local\Wintermelon\winpos.txt.

Using Wintermelon

To monitor lock/unlock event and switch the projection mode two separate scheduled tasks will need to be registered with the Windows Task Scheduler. These tasks are:

  • Task 1 : Wintermelon screen lock save window position clone display
  • Task 2 : Wintermelon screen unlock extend display restore window

The PowerShell scripts install_wintermelon.ps1 and uninstall_wintermelon.ps1 will need to be executed to register or unregister the aforementioned tasks, respectively.

Registering the Scheduled tasks

  • Open PowerShell by going to Start Menu, searching for Windows PowerShell and choosing "Run As Administrator" from right click context menu.

  • To register the tasks run the following command

    powershell -File install_wintermelon.ps1

  • Open Task Scheduler from Start Menu and you should see 2 new tasks under Task Scheduler Library with names beginning with Wintermelon. The Actions tab for these 2 scheduled tasks will list Wintermelon.exe as the program that should start when these tasks are triggered. Task 1 will invoke Wintermelon.exe by passing the argument 'save' while task 2 will invoke Wintermelon.exe by passing the argument 'restore'.

  • Lock the display by pressing Win+L keys and the lockscreen will appear on all displays.

  • Enter your login credentials to unlock the displays. When the displays are unlocked they are all in duplicate mode momentarily and then the C# app fetches the positions of active application windows and relocates them to the appropriate positions. This requires a 3 second wait and is a limitation of this workaround.

Unregistering the Scheduled tasks

  • To unregister the tasks run the following command

    powershell -File uninstall_wintermelon.ps1

  • Open Task Scheduler from Start Menu and you should no longer see the 2 tasks with names beginning with Wintermelon under Task Scheduler Library.

wintermelon's People

Contributors

arun-goud avatar dani20000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wintermelon's Issues

3 screens setup, duplicating only 2

I've been able to setup and run the application but found out that it is limited to only main and second screen, on a 3-screens setup it will only duplicate the main on the second one. I found this stackoverflow thread where the OP is having similar issues and had to change SetDisplayConfig parameters to actually factor in the extra monitor.

https://stackoverflow.com/questions/57136638/how-to-properly-use-setdisplayconfig-with-multiple-monitors

Edit: after unistalling all gpu drivers and removing all related registry keys and proceeding with a clean install with just the main monitor plugged everything worked as expected without any code change once the 2nd and 3rd monitors got plugged back in.

Doesn't seem to work after a reboot?

I've been able to install this program and it works great! However, when I reboot, it doesn't continue to work. The lock and unlock tasks are in the task scheduler and in a ready state. I can even run them from the task scheduler by hand and they fire off, but when i hit the windows key + L it just locks my screen and doesn't mirror on the other monitors.

I can run the uninstall and reinstall and it starts working again...

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.