-
Notifications
You must be signed in to change notification settings - Fork 0
/
darkmode.py
31 lines (25 loc) · 906 Bytes
/
darkmode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import os
location = os.getenv('LOCALAPPDATA') + "\Scribo\dark.npy"
def get_current_mode():
# create %localappdata% folder (to store dark mode data)
# (First time) if there is no file here, create it and intitialize with light mode
if not os.path.exists(location):
# print('file doesnt exist, gonna create')
os.makedirs(os.path.dirname(location), exist_ok=True)
np.save(location, np.array(['light']))
return 'light'
else:
# print('file exists')
# file exists, read what mode the app is currently on
file = open(location, "rb") # reading in binary
array = np.load(file, allow_pickle=True)
file.close()
# print(array[0])
return array[0]
def set_mode(str):
file = open(location, "wb")
new_arr = [str]
np.save(file, new_arr)
file.close()
get_current_mode()