Skip to content

Commit

Permalink
Added dark mode!
Browse files Browse the repository at this point in the history
  • Loading branch information
TriLinder committed Sep 29, 2021
1 parent b4eaffc commit fb36a42
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

Icon credit: [https://pixabay.com/vectors/lightbulb-lamp-bulb-light-led-6518548/](https://pixabay.com/vectors/lightbulb-lamp-bulb-light-led-6518548/)



**Screenshots:**

​ <img src="Screenshots/bulbNormal.png" alt="A Yeelight bulb without any RGB or color temperature functionality" style="zoom:75%;" />
​ <img src="Screenshots/bulbNormal.png" alt="Light mode" style="zoom:75%;" />
<img src="Screenshots/bulbNormal_dark.png" alt="Dark mode" style="zoom:75%;" />
Binary file added Screenshots/bulbNormal_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions yeelightControl.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,38 @@ try:
except Exception:
base_path = os.path.abspath(".")

iconPath = os.path.join(base_path, "icon.ico")
iconPath = os.path.join(base_path, "icon.ico") #Made, so that pyinstaller can detect the .ico file

darkMode = False

try : #Tries to detect dark mode on Windows
import winreg
except ImportError :
darkMode = False

registry = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
reg_keypath = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"

try :
reg_key = winreg.OpenKey(registry, reg_keypath)
except :
darkMode = False

for i in range(1024) :
try :
value_name, value, _ = winreg.EnumValue(reg_key, i)
if value_name == 'AppsUseLightTheme' :
darkMode = value == 0
except :
continue

theme = ["LightGrey2", "DarkGrey11"][int(darkMode)]

def ipDialog(forceIPChange) :
#Creates the file if it doesnt exist, if it does, sets the variable "ip" from the file
if forceIPChange or not os.path.isfile(ipFile) :
with open(ipFile, "w") as f :
sg.theme('LightGrey2')
sg.theme(theme)
layout = [ [sg.Text('Enter your Yeelight device IP Address:')],
[sg.InputText()],
[sg.Button('Submit')] ]
Expand Down Expand Up @@ -66,7 +91,7 @@ def ipDialog(forceIPChange) :
return ip

def mainWindow(ip) :
sg.theme('LightGrey2')
sg.theme(theme)
bulb = yeelight.Bulb(ip)

#Fallbacks in case the info cannot be retrived down below
Expand Down

0 comments on commit fb36a42

Please sign in to comment.