You are not logged in.

#1 2023-12-27 09:52:18

EugeneS
Member
Registered: 2023-12-19
Posts: 10

[SOLVED] Monitor brightness

I'm trying to control monitor brightness from hotkeys. I have tryed to use brightnessctl package, but it has only printed current and max brightness without actually changing them.
I have tried to run it with and without sudo, and it hasn't worked:

brightnessctl -s 50%

So, i have written a simple script, that modifies the brightness, which is working, but requires sudo:

#!/bin/zsh

delta=$1

brightness=$(cat /sys/class/backlight/intel_backlight/brightness)
max_brightness=$(cat /sys/class/backlight/intel_backlight/max_brightness)
new_brightness=${$((max_brightness*(delta/100.0) + brightness))%i}
limited_brightness=$(( new_brightness < 0 ? 0 : (new_brightness > max_brightness ? max_brightness : new_brightness) ))

echo $brightness $max_brightness $new_brightness $limited_brightness >> ~/scripts.log
printf "%.0f" $limited_brightness | sudo tee /sys/class/backlight/intel_backlight/brightness &

Can I either modify my script to run it without needing sudo privileges, or somehow run this script from hyprland config with sudo privileges?

P.S.

I have tried to install xorg-xbacklight package, wich hasn't worked either, and then acpilight package, which did worked at least. But it still requires sudo to execute:

sudo xbacklight -10

Last edited by EugeneS (2023-12-27 10:35:55)

Offline

#2 2023-12-27 10:30:33

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Monitor brightness

Please read through https://bbs.archlinux.org/viewtopic.php?id=291364 and post back if you still can't figure things out.


Jin, Jîyan, Azadî

Offline

#3 2023-12-27 10:35:16

EugeneS
Member
Registered: 2023-12-19
Posts: 10

Re: [SOLVED] Monitor brightness

Problem was solved with brightnessctl - I was using it wrong. Proper command is:

 brightnessctl set 50%+ 

Offline

Board footer

Powered by FluxBB