[Linux] Generalize brightness manager to work for nvidia
This commit is contained in:
parent
e66a48a311
commit
1aaeeaedf0
@ -6,6 +6,12 @@ import sys
|
|||||||
|
|
||||||
class BrightnessManager(object):
|
class BrightnessManager(object):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def find_brightness(cls):
|
||||||
|
return cls.from_path(
|
||||||
|
os.path.join("/sys/class/backlight", os.listdir("/sys/class/backlight")[0])
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_path(cls, path):
|
def from_path(cls, path):
|
||||||
return cls(
|
return cls(
|
||||||
@ -46,11 +52,6 @@ class BrightnessManager(object):
|
|||||||
return float(self.current_brightness) / self.max_brightness
|
return float(self.current_brightness) / self.max_brightness
|
||||||
|
|
||||||
|
|
||||||
IntelBrightnessManager = BrightnessManager.from_path(
|
|
||||||
"/sys/class/backlight/intel_backlight",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def build_parser():
|
def build_parser():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Interact with macbook brightness',
|
description='Interact with macbook brightness',
|
||||||
@ -70,6 +71,6 @@ def build_parser():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = build_parser().parse_args()
|
args = build_parser().parse_args()
|
||||||
IntelBrightnessManager.increment_by_proportion(float(args.change) / 100)
|
BrightnessManager.find_brightness().increment_by_proportion(float(args.change) / 100)
|
||||||
if args.do_print:
|
if args.do_print:
|
||||||
print(int(IntelBrightnessManager.current_proportion * 100))
|
print(int(IntelBrightnessManager.current_proportion * 100))
|
||||||
|
Loading…
Reference in New Issue
Block a user