Community
    • Login

    Toggling dark mode programmatically

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    dark theme
    3 Posts 2 Posters 836 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ZippoLagZ
      ZippoLag
      last edited by ZippoLag

      Hi!

      So, after suffering from the fact that there’s no way to automatically toggle darkmode on/off in Windows 10 I made a simple Scheduled Task that runs this powershell script and that takes care of most things, however there are a few programs that don’t pick up on this OS setting yet.

      So, is there a way to alter the Dark Mode setting in N++ programmatically so I don’t need to go into the settings menu and do a couple of clicks to keep it in sync with the OS setting?

      (If you know there’re plans to pick up the OS value automatically then I’ll just live with it until it’s implemented, though :D )

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @ZippoLag
        last edited by PeterJones

        @ZippoLag ,

        On program load, Notepad++ decides on Dark Mode based on a setting in config.xml (%AppData%\Notepad++\config.xml in a normal installation). Specifically, the line that is something like,

                <GUIConfig name="DarkMode" enable="yes" colorTone="0" customColorTop="2105376" customColorMenuHotTrack="4210752" customColorActive="4210752" customColorMain="2105376" customColorError="176" customColorText="14737632" customColorDarkText="12632256" customColorDisabledText="8421504" customColorLinkText="65535" customColorEdge="6579300" customColorHotEdge="10197915" customColorDisabledEdge="4737096" />
        

        So in your script that runs to change Windows 10 mode, you could have that script edit that line in the config.xml from no to yes and back

        Actually, there is a second associated line

        <GUIConfig name="stylerTheme" path="...\AppData\Roaming\Notepad++\stylers.xml" />
        

        When you switch to Dark Mode, that automaticallyg gets changed to

        <GUIConfig name="stylerTheme" path="...\AppData\Roaming\Notepad++\themes\DarkModeDefault.xml" />
        

        … so you will probably want to change both those lines, so it changes the mode and sets the theme.

        Note: I used ellipses … in my paths in the example config.xml lines, but you will need to make sure that everything up to Notepad++\ stays the same when you make the change.

        Addenda: In case it wasn’t clear, you can only make that change to config.xml when Notepad++ is not running. If Notepad++ is running, it won’t see the change to config.xml, and when it exits, it will overwrite the change you made to config.xml. (And other than programmatically sending the keystrokes or mouse-clicks to the Notepad++ GUI – which is possible but maybe complicated depending on what libraries you use in your coding language of choice – I do not know of a way to tell a “live” instance of Notepad++ to change modes from the outside world.)

        ZippoLagZ 1 Reply Last reply Reply Quote 2
        • ZippoLagZ
          ZippoLag @PeterJones
          last edited by

          @PeterJones thank you for the reply!

          Sadly, I’m trying to make Npp change themes even while it’s running, so I’m leaning towards developing a plugin or a macro or something that will let me do that. I just need a Saturday off or something :D

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors