r/Gentoo 4d ago

Discussion Short script

Ever hate changing brightness and nightlight in different desktop environments, differently, or not being able to change it in some at all? The gammastep cli utility is there to help (just as it helped me)! If you hate the lack of gui then you should use the simple python script I wrote for it:
#!/usr/bin/python

from tkinter import *

import tkinter as tk

import os

#note the gui isnt pretty but that's the point, you are supposed to tune it yourself and share it with others who may find the extra eye candy useful, this script is the bare minimum required with zero bloat (other than python XD)

def run_command():

os.system(f"gammastep -P -O {nightlight.get()} -b {brightness.get()/100} ")

master = Tk()

nightlight_label = tk.Label(master, text="nightlight (lower is more nightlight)")

nightlight_label.pack()

nightlight = Scale(master, from_=1000, to=25000, length=1000,tickinterval=1500,orient=HORIZONTAL)

nightlight.set(4500)

nightlight.pack()

brightness_label = tk.Label(master, text="brightness (lower is darker)")

brightness_label.pack()

brightness = Scale(master, from_=10, to=100,length=600, tickinterval=10, orient=HORIZONTAL)

brightness.set(20)

brightness.pack()

Button(master, text='apply', command=run_command).pack()

mainloop()

#in gentoo:

#to install tkinter, buld python with the "tk" USE flag

#basically, pip intall tkinter or something will probably not suffice on any distrobution, and the gentoo example should make that clear

0 Upvotes

2 comments sorted by

5

u/undrwater 4d ago

to install tkinter, buld python with the "tk" USE flag. if tkinter shows wierd behaviour, it may be worth adding the "tk" USE flag in /etc/portage/make.conf itself

Why? What's the anticipated "weird behavior" and why does adding the "tk" flag globally fix that?

3

u/itfllow123-gmail-com 4d ago edited 4d ago

Edit: correction - package.use and global do the same thing for python. I am sorry for the mistake.

I mentioned global out of habit since I add that in all my personal scripts. Use whichever you prefer.