Working AppleScript for Toggling Light/Dark Mode seems to affect SystemConfiguration - How to rewrite?

Hey Folks,

here is a little AppleScript I wrote these days for toggling between Light/Darkmode for a MacroSet I am working on ....


tell application "System Events"
	tell appearance preferences
		set dark mode to not dark mode
	end tell
end tell

While I am always in Dark Mode (Yosemite Dark Mode) I want to use this Script for switching between Light and Dark Mode for Screencapturing Purposes.

it works fine... - toggling between Light/Dark Mode is performing like a charm - BUT ...

Here is my Problem with it ....

IT IS AFFECTING MY SYSTEMCONFIGURATION.....

It has changed the System to be In Light Mode until its dark outside..... During nights my System is in the Dark mode...

I want:

  1. the system to be set to Dark mode like before using this script

    • maybe help with the corresponding plist
  2. A working AppleScript which does NOT affect the system again...

Hopefully someone out here who can help me with that ? Since I am NOT very good in writing Scrips it can help me a lot to comment every step which is absolutely needed .....

even in manipulating the plist

Thank You

Problem solved by my self .... there was nothing with the AppleScript it self .... there was something wrong with the Flux.app . everything is fine like it should be....