Skip to content

Instantly share code, notes, and snippets.

@abraham-ny
Created February 20, 2026 17:56
Show Gist options
  • Select an option

  • Save abraham-ny/c014c9eebcd0834ff548144c288c9a5f to your computer and use it in GitHub Desktop.

Select an option

Save abraham-ny/c014c9eebcd0834ff548144c288c9a5f to your computer and use it in GitHub Desktop.
A simple GUi brightness control for linux systems running xfce
#!/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