Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Lighting Support #893

Open
N8endo opened this issue Nov 30, 2024 · 8 comments
Open

Dynamic Lighting Support #893

N8endo opened this issue Nov 30, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@N8endo
Copy link

N8endo commented Nov 30, 2024

Windows Personalization settings includes Dynamic Lighting, which controls your computer's RGB lights. Unfortunately, it doesn't link these settings to Themes, so theme switching can't change Dynamic Lighting settings.

I was wondering if Windows-Auto-Night-Mode could change Dynamic Lighting settings. For my use case, I just want the setting disabled during the day and enabled at night. Could that be added to your app?

Thanks!

@N8endo N8endo added the enhancement New feature or request label Nov 30, 2024
@ThioJoe
Copy link

ThioJoe commented Dec 1, 2024

You can do it manually with scripts and powershell in the mean time, I have one like this for example below. The registry location for the devices is in HKEY_CURRENT_USER\Software\Microsoft\Lighting\Devices\ .

The names of the devices aren't listed anywhere in the entries, and it seems that device entries stick around even if they're not active or they change or something, so you'll need to do some trial and error to figure out which is which. You can just do that by setting some specific brightness per device in the Dynamic Lighting menu and see which registry entry updates to that 'Brightness' property value. My script just purely changes the brightness but you could also have other commands that change color and stuff.

Also since the YAML apparently can't have variables the best I could do to make it easier to edit the script was powershell variables, but that requires setting the variables twice, in both ArgsLight and ArgsDark, but it's just an extra copy paste.

Maybe the devs could add support for creating custom variables in the yaml itself that get expanded before the commands are run, so they could be set in one place.

Enabled: true
Component:
  Scripts:
  - Name: Set Theme
    Command: powershell
    ArgsLight: 
      - -Command
      - |
        # Device-specific registry paths
        $MouseDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&ee39c11&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $PadDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&98cac03&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $KeyboardDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&bc3184a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $MotherboardDevicePath = 'HID#VID_0B05&PID_19AF&MI_03#7&24fc6c75&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 

        # ------------------------------------------------------------------------------------------------------------
        $BasePath = 'HKCU:\Software\Microsoft\Lighting\Devices\'; 
        Set-ItemProperty -Path ($BasePath + $MouseDevicePath) -Name 'Brightness' -Value 100; 
        Set-ItemProperty -Path ($BasePath + $PadDevicePath) -Name 'Brightness' -Value 100; 
        Set-ItemProperty -Path ($BasePath + $KeyboardDevicePath) -Name 'Brightness' -Value 100; 
        Set-ItemProperty -Path ($BasePath + $MotherboardDevicePath) -Name 'Brightness' -Value 100
    ArgsDark: 
      - -Command
      - |
        # Device-specific registry paths
        $MouseDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&ee39c11&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $PadDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&98cac03&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $KeyboardDevicePath = 'HID#HID_DEVICE_SYSTEM_VHF#7&bc3184a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 
        $MotherboardDevicePath = 'HID#VID_0B05&PID_19AF&MI_03#7&24fc6c75&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'; 

        # ------------------------------------------------------------------------------------------------------------
        $BasePath = 'HKCU:\Software\Microsoft\Lighting\Devices\'; 
        Set-ItemProperty -Path ($BasePath + $MouseDevicePath) -Name 'Brightness' -Value 30; 
        Set-ItemProperty -Path ($BasePath + $PadDevicePath) -Name 'Brightness' -Value 30; 
        Set-ItemProperty -Path ($BasePath + $KeyboardDevicePath) -Name 'Brightness' -Value 50; 
        Set-ItemProperty -Path ($BasePath + $MotherboardDevicePath) -Name 'Brightness' -Value 5
    AllowedSources: [Any]

Edit: Optimized the script

@N8endo
Copy link
Author

N8endo commented Dec 1, 2024

@ThioJoe Thank you! That was very helpful! I edited the script to this:
`Enabled: true
Component:
Scripts:

  • Name: Set Theme
    Command: powershell
    ArgsLight:
    • -Command

    • |

      Device-specific registry paths

      $CaseDevicePath = 'HID#VID_048D&PID_5711&MI_00#a&55c13e2&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}';

      ------------------------------------------------------------------------------------------------------------

      $BasePath = 'HKCU:\Software\Microsoft\Lighting\Devices';
      Set-ItemProperty -Path ($BasePath + $CaseDevicePath) -Name 'AmbientLightingEnabled' -Value 0;
      ArgsDark:

    • -Command

    • |

      Device-specific registry paths

      $CaseDevicePath = 'HID#VID_048D&PID_5711&MI_00#a&55c13e2&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}';

      ------------------------------------------------------------------------------------------------------------

      $BasePath = 'HKCU:\Software\Microsoft\Lighting\Devices';
      Set-ItemProperty -Path ($BasePath + $CaseDevicePath) -Name 'AmbientLightingEnabled' -Value 1;
      AllowedSources: [Any]`

That worked perfectly. Can I also add another script to open OpenRGB (it's an app that control's my GPU's RGB) at night and close OpenRGB in the day? I'm a noob when it comes to scripting.

@N8endo
Copy link
Author

N8endo commented Dec 1, 2024

Actually, I'm looking more at how OpenRGB works and I don't think just opening it and closing it will work for what I want. RGB is too complicated.

@N8endo
Copy link
Author

N8endo commented Dec 1, 2024

@ThioJoe Ok. I figured it out. I've got OpenRGB opening at login and loading the rainbow profile for my GPU. WindowsAutoDarkMode can can close OpenRGB at sunset, then it will switch to my orange profile. Could you show me how to add that to my script? Just close the app OpenRGB at sunset. I'd really appreciate it!

@ThioJoe
Copy link

ThioJoe commented Dec 1, 2024

I think you could probably just add a line to the ArgsDark section using this:

Stop-Process -Name "OpenRGB"

So you could put it above the line that sets the registry value so those few lines now look like:

$BasePath = 'HKCU:\Software\Microsoft\Lighting\Devices'; 
Stop-Process -Name "OpenRGB"; 
Set-ItemProperty -Path ($BasePath + $CaseDevicePath) -Name 'AmbientLightingEnabled' -Value 1; 

Basically the way I have the script is each line effectively chains together multiple powershell commands into one. The semicolon and space ; at the end of the lines basically tells it to separate it from the next. So to add any additional powershell command just add a new line and make sure the previous one ended with a semicolon and space (I've found that the space is important). So all the lines beneath ArgsLight and ArgsDark is really just part of one big command (or rather each one is a single command).

All that being said, I would try experimenting with whether you can get everything working purely with dynamic lighting instead of having to use OpenRGB at all.

@N8endo
Copy link
Author

N8endo commented Dec 3, 2024

@ThioJoe Thanks! I tried it and it does indeed close OpenRGB. But for some reason, it doesn't load my orange preset when powershell closes it. If I exit the program myself, it loads my preset. Weird. Not sure there's gonna be any way to automate the GPU's RGB.
Windows Dynamic Lighting only seems to detect the fans plugged into my motherboard's rgb connectors. I don't know of any way to make it detect my graphics card.

@ThioJoe
Copy link

ThioJoe commented Dec 4, 2024

If it's an Nvidia card then yea it doesn't detect mine either, I assume it's not supported yet by the dynamic lighting feature.

As for why the colors aren't loading, it's hard to say for sure without sitting in front of it myself. By 'profile' you mean the windows dynamic lighting colors right? Or that when OpenRGB re-opens it doesn't load the profile? Either way yea seems weird, can't think of a reason for it doing that 🤔, maybe it takes time for OpenRGB to stop and release control.

I would try adding a delay between stopping the process and updating the dynamic lighting like this. (I'd first try a long time like 10 seconds just to be sure it makes a difference, then shorten it as much as you can by trial and error):

Start-Sleep -Seconds 10; 

You could also I would try messing around with different settings in the dynamic lighting like disabling "compatible apps in the foreground always control lighting" maybe.

@N8endo
Copy link
Author

N8endo commented Dec 6, 2024

@ThioJoe I have 2 profiles set up in OpenRGB: rainbow and orange. OpenRGB starts when I boot up and loads rainbow. I've also enabled a setting that loads the orange profile when I close OpenRGB. Stop-Process wasn't correctly loading orange, but I found that taskkill does load the orange profile. Unfortunately, I can't seem to get AutoDarkMode to use taskkill when I restart my PC at night. For some reason, it just doesn't seem to actually do taskkill, whether I tell it to sleep first or not. At this point, I think I just need to hope that AutoDarkMode or OpenRGB will add some functionality for this. Thank you for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants