Created
February 20, 2026 17:56
-
-
Save abraham-ny/c014c9eebcd0834ff548144c288c9a5f to your computer and use it in GitHub Desktop.
A simple GUi brightness control for linux systems running xfce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import subprocess | |
| import gi | |
| gi.require_version("Gtk", "3.0") | |
| from gi.repository import Gtk | |
| class BrightnessApp(Gtk.Window): | |
| def __init__(self): | |
| super().__init__(title="Brightness") | |
| self.scale = Gtk.Scale.new_with_range( | |
| Gtk.Orientation.HORIZONTAL, 0, 100, 1 | |
| ) | |
| self.scale.set_value(self.get_current()) | |
| self.scale.connect("value-changed", self.on_change) | |
| self.add(self.scale) | |
| def get_current(self): | |
| out = subprocess.check_output(["brightnessctl", "g"]) | |
| cur = int(out.strip()) | |
| out2 = subprocess.check_output(["brightnessctl", "m"]) | |
| maxv = int(out2.strip()) | |
| return (cur / maxv) * 100 | |
| def on_change(self, widget): | |
| val = int(widget.get_value()) | |
| subprocess.call(["brightnessctl", "set", f"{val}%"]) | |
| app = BrightnessApp() | |
| app.connect("destroy", Gtk.main_quit) | |
| app.show_all() | |
| Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment