Repository URL to install this package:
|
Version:
0.3.6-1 ▾
|
import os
# STATIC PATHS
SETTINGS_PATH = os.path.expanduser('~/.config/kbd_settings/')
if not os.path.exists(SETTINGS_PATH):
os.makedirs(SETTINGS_PATH)
# RGB
# generic path
DRIVER_PATH = '/sys/class/leds'
TEST_PATH = 'rgb:kbd_backlight_1'
TEST_PATH_FULL = os.path.join(DRIVER_PATH, TEST_PATH)
KEYBOARD_PATH = DRIVER_PATH + '/rgb:kbd_backlight'
BRIGHTNESS_PATH_FILE = KEYBOARD_PATH + '/brightness'
LOCAL_BRIGHTNESS_PATH_FILE = os.path.expanduser('~/.config/kbd_settings/user_brightness')
if not os.path.exists(LOCAL_BRIGHTNESS_PATH_FILE):
with open(LOCAL_BRIGHTNESS_PATH_FILE, 'w') as file:
if not os.path.exists(TEST_PATH_FULL):
file.write('25')
else:
file.write('3')
COLOR_PATH_FILE = KEYBOARD_PATH + '/multi_intensity'
LOCAL_COLOR_PATH_FILE = os.path.expanduser('~/.config/kbd_settings/user_color')
if not os.path.exists(LOCAL_COLOR_PATH_FILE):
with open(LOCAL_COLOR_PATH_FILE, 'w') as file:
file.write('')
# RGB PER KEY
RGB_LOCAL_COLOR_PATH_FILE = os.path.expanduser('~/.config/kbd_settings/user_rgb_color')
if not os.path.exists(RGB_LOCAL_COLOR_PATH_FILE):
with open(RGB_LOCAL_COLOR_PATH_FILE, 'w') as file:
file.write('')
def load_settings():
with open(LOCAL_BRIGHTNESS_PATH_FILE, 'r') as file:
brightness = file.read()
with open(BRIGHTNESS_PATH_FILE, 'w') as file:
file.write(brightness)
if not os.path.exists(TEST_PATH_FULL):
with open(LOCAL_COLOR_PATH_FILE, 'r') as file:
color = str(file.read())
with open(COLOR_PATH_FILE, 'w') as file:
file.write(str(color))
else:
with open(RGB_LOCAL_COLOR_PATH_FILE, 'r') as file:
color = str(file.read())
for folder_name in os.listdir(DRIVER_PATH):
if folder_name.startswith('rgb:kbd_backlight'):
folder_path_kbd = os.path.join(DRIVER_PATH, folder_name)
file_path = os.path.join(folder_path_kbd, 'multi_intensity')
with open(file_path, 'w') as file:
file.write(f'{color}')
load_settings()