Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- from tkinter import Button, Tk
- from tkinter.ttk import Scale
- BASE = Path("/sys/class/backlight/intel_backlight")
- BRIGHTNESS = BASE / "brightness"
- MAX_BRIGHTNESS = int(BASE.joinpath("max_brightness").read_text())
- def set(percent: float):
- value = MAX_BRIGHTNESS / 100 * float(percent)
- BRIGHTNESS.write_text(str(int(value)))
- def get() -> float:
- return int(BRIGHTNESS.read_text()) / MAX_BRIGHTNESS * 100
- def gui() -> Tk:
- root = Tk()
- Scale(root, value=get(), from_=0, to=100, command=set).pack()
- Button(root, text="Close", command=root.destroy).pack()
- return root
- if __name__ == "__main__":
- gui().mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement