openCom-Companion/sbapp/plyer/platforms/linux/brightness.py

30 lines
669 B
Python
Raw Normal View History

2022-09-16 18:07:57 +02:00
'''
Linux Brightness
----------------
'''
2024-06-02 18:31:58 +02:00
from sbapp.plyer.facades import Brightness
2022-09-16 18:07:57 +02:00
import subprocess
import os
class LinuxBrightness(Brightness):
def __init__(self):
if os.system("which xbacklight"):
msg = ("It looks like 'xbacklight' is not installed. Try "
"installing it with your distribution's package manager.")
raise Exception(msg)
def _current_level(self):
cr_level = subprocess.check_output(["xbacklight", "-get"])
return str(cr_level)
def _set_level(self, level):
subprocess.call(["xbacklight", "-set", str(level)])
def instance():
return LinuxBrightness()