Reputation: 321
I have two folders in my /sys/class/backlight:
1> acpi_video0 2> intel_backlight
The intel_backlight is useless because I can use the following command to adjust brightness in acpi_video0 (I'm running Nvidia drivers):
e.g: echo 50 > /sys/class/backlight/acpi_video0/brightness
Problem: Using xbacklight -inc +5 outputs: "No outputs have backlight property" so I need to get it to use acpi_video0
So far, I have tried to rm the intel_backlight folder completely with no luck (using both sudo and changing permission to 777 recursively).
I just wanna be able to hotkey the xbacklight to increment and decrement brightness. I can set brightness in acpi_video0 to a hard value using echo but don't know how to adjust it in increments.
Kindly advise further!
Regards :)
EDIT 1: (POSSIBLE ALTERNATIVE) For anyone with this problem in the future, install xcalib. (Setup: Arch Linux w/ i3 window manager)
yaourt -S xcalib
And the following hotkey assignment (i3 in my case) in the config file:
# Brightness control reset screen (100% brightness)
bindsym Mod1+Up exec xcalib -c
# Brightness control down
bindsym Mod1+Down exec xcalib -co 95 -a
Upvotes: 20
Views: 32869
Reputation: 20554
Update as of December 2023 to add support for percents and automatically add read/write permission if needed.
I've replaced my xbacklight with the following script :
#!/usr/bin/env bash
set -euo pipefail
file="/sys/class/backlight/intel_backlight/brightness"
max_file="${file//brightness/max_brightness}"
if /usr/bin/xbacklight "$@" 2>/dev/null; then
exit 0
fi
add_perm() {
echo "Adding read/write permission (with sudo)"
sudo chmod 766 "$file"
}
if ! [ -r "$file" ]; then
echo "You don't have read permission"
add_perm
fi
if ! [ -w "$file" ]; then
echo "You don't have write permission"
add_perm
fi
MIN=10
MAX="$(cat "$max_file")"
current=$(cat "$file")
new="$current"
cmd="$1"
val="$2"
# Convert percents to number
if grep '%' <<<"$val" --quiet; then
pct="${val//%/""}"
val="$(bc <<<"$pct*$MAX/100")"
fi
if [ "$cmd" = -inc ]; then
new=$(( current + val ))
elif [ "$cmd" = -dec ]; then
new=$(( current - val ))
elif [ "$cmd" = -set ]; then
new=$(( val ))
fi
if [ "$new" -gt "$MAX" ]; then
new="$MAX"
elif [ "$new" -lt "$MIN" ]; then
new="$MIN"
fi
pct_value="$(bc -l <<<"$new/$MAX*100")"
printf "%.0f%%\n" "$pct_value"
echo "$new" > "$file"
you have to replace file by the file that you can find by using :
sudo find /sys/ -type f -iname 'brightness'
and you have to make sure that this file is writable : eg :
sudo chmod a+rw /sys/class/backlight/intel_backlight/brightness
Upvotes: 10
Reputation: 185053
What I've done, added to archwiki:
Usage Brightlight <-|+>
:
#!/bin/bash
# sputnick.fr 2023
devvideo=$(xrandr | awk '$2 == "connected"{print $1;exit}')
if ! val=$(cat ~/.config/xrandr/brightness 2>/dev/null); then
mkdir -p ~/.config/xrandr
echo 0.90 > ~/.config/xrandr/brightness
val=0.90
fi
case $1 in
-) val="0$(bc <<< $val-0.05)" ;;
+) val="0$(bc <<< $val+0.05)" ;;
esac
if ((${val#*.} <= 20 || ${val#*.} >= 100 )); then
echo >&2 ERR
exit 1
fi
Upvotes: 0
Reputation: 1774
After a recent kernel update the xbacklight
stopped working on my laptop. (Kernel version 6.1+ apparently).
I had this message in dmesg:
i915 0000:00:02.0: [drm] Skipping intel_backlight registration
The folder /sys/class/backlight/intel_backlight
was replaced with /sys/class/backlight/acpi_video0
, which didn't work and broke xbacklight
.
There was more info about this issue on Linuxquestions.org: thread1 , thread2
.
The issue was fixed by adding the kernel boot parameter acpi_backlight=native
(this made /sys/class/backlight/intel_backlight
appear again)
Upvotes: 0
Reputation: 251
EDIT: I found this question because I had the same output error: no outputs have backlight property. light
solved this with no further tinkering.
A better alternative to xcalib
(which doesn't adjust backlight; won't save battery power): light
available in community/light.
Usage
light -U 20
decrease backlight 20%light -A 20
increase 20%light -S 50
set backlight to 50%Found here wiki.archlinux.org/index.php/backlight (thanks @icbytes).
Upvotes: 25
Reputation: 749
To solve similar issue on a fresh Arch install I decided to go with acpilight also available in AUR. Advertised as 'backward-compatibile replacement for xbacklight' it does not depend on X11 as such, works just as fine on Wayland and/or virtual console should such need arise.
After installation the regular user needs to be added to the 'video' group and a drop-in file for a very conservative udev rule neeeds to be created:.
**/etc/udev/rules.d/90-backlight.rules**
SUBSYSTEM=="backlight", ACTION=="add", \
RUN+="/bin/chgrp video %S%p/brightness", \
RUN+="/bin/chmod g+w %S%p/brightness"
On some laptops keyboard backlight control is also supported. For more information refer project's github gitlab page linked above.
Hope this helps I found acpilight very handy to setup and use.
NOTE: Python(3) dependent solution.
NOTE 2: At the heart of acpilight lays not much more than a simple python script that can easily be extracted.
Upvotes: 3
Reputation: 361
I finally fixed this and none of the online solutions that the original poster listed worked for me either. What did solve the problem was going to /etc/default/grub and in the line: GRUB_CMDLINE_LINUX_DEFAULT
Adding :
"acpi_osi="
But also do Not use "nomodeset" on it. Ppl added nomodeset originally to fix the software rendering issue, but this actually causes Linux to not recognize the Nvidia drivers.
Lastly make sure you go to the Linux Start Menu Driver Manager and update your Nvidia drivers to 430 or newer.
Upvotes: 0
Reputation: 13
I'm using openSUSE but it helped to get xbacklight working (again) when I installed the xf86-video-intel package. This included the xorg-x11 drivers for intel graphics card and other stuff like command line utilities. After installing it was possible to control the backlight with xbacklight.
Before that, my only option was to control the backlight only with root permissions via /sys/class/backlight/intel_backlight/brightness
Upvotes: 1
Reputation: 499
To add to @edi9999 's great solution, this one works with percentages and it can set the limits
#!/bin/bash
MAX=661
MIN=10
set -e
file="/sys/class/backlight/intel_backlight/brightness"
current=$(cat "$file")
new="$current"
if [ "$2" != "" ]; then
val=$(echo "$2*$MAX/100" | bc)
fi
if [ "$1" = "-inc" ]; then
new=$(( current + $val ))
elif [ "$1" = "-dec" ]; then
new=$(( current - $val ))
fi
if [ $new -gt $MAX ]; then
new=$MAX
elif [ $new -lt $MIN ]; then
new=$MIN
fi
printf "%.0f%%\n" $(echo "$new/$MAX*100" | bc -l)
echo $new > "$file"
Upvotes: 2
Reputation: 61
I've also faced the No outputs have backlight property
issue when using xbacklight but stumbled on a simple fix, at least with Fedora 28 on a MacBook Pro 13,1.
While other solutions appear like they should work, I didn't need to install anything nor use any scripts. Hopefully this is applicable for other distros too given that I used the Arch Wiki to help me along:
https://wiki.archlinux.org/index.php/Backlight#ACPI talks about ls /sys/class/backlight/
and in my case, that shows acpi_video0@
and intel_backlight@
.
With that, I tried intel_backlight
, so I used cat /sys/class/backlight/intel_backlight/brightness
to see what the current value was (39
).
Using echo 50|sudo tee /sys/class/backlight/intel_backlight/brightness
(type info tee
for more details about tee) resulted in the backlight brightening - progress!
Now interestingly after doing this, the xbacklight -inc 10
and xbacklight -dec 10
commands started magically working without me doing anything else so I can now bind my keyboard's brightness keys to xbacklight - no further sudo commands or rules required.
Upvotes: 1