Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I was working with xbacklight today. To adjust my brightness, I previously had a really simple script that 'echo'ed a number into /sys/class/backlight/intel_backlight/brightness. But that required root privleges, and I wanted to try to do it using my window manager's keybindings. So I installed xorg-xbacklight and ran this in a teminal emulator:
Code:
xbacklight -set 100
It returned no output, and the backlight didn't change. I tried to set it to 10, and I got the same result.
I opened up tty2 and tried again. This time, it said
Code:
RANDR Query Version returned error -1
but the backlight still didn't change.
Any ideas?
EDIT: on the 2 other laptops I've used Arch on, the hardware buttons for backlight (Fn + F4 and F5) worked out-of-the-box, but on this laptop they don't do a thing.
EDIT 2: I looked up the error, and found a bug report for Ubuntu about xbacklight not working...could that problem apply to Arch, too?
xrandr --verbose lists outputs and shows the main screen has backlight property,
and "xrandr --output LVDS-0 --set backlight 50" changes the backlight
brightness.
And
"cat /sys/class/backlight/psb-bl/actual_brightness" shows the current
brightness, and
"echo 50 >/sys/class/backlight/psb-bl/brightness" changes the brightness.
Though I imagine he's doing that as root....
Your problem might be the D-Buss --session which has to hand that off to the D-Buss --system for that to work, I've tried to fix something similar (system bell) with another user but without root access the best we could manage was intermittent functionality.
Unfortunately, the 'xrandr' command in the bug report fails to work as well. And yes, I checked to see if it was a different display name than the one in the example.
So I guess I'll just have to deal with it until there's a bugfix? Or will one even come, since that bug report is almost 2 years old?
Yes, and I've been using sudo to run it, and it works jsut fine. However, if possible, I'd like to write a backlight-up script and a backlight-down script that I could give a keybinding with xbindkeys. If I'm correctly understanding the question you refrenced, the final script still requires the user to type the password. I'd prefer not to give myself sudo rights without the password prompt. Is there a way around this?
OK, I've written the script (with the exception of the root privleges, I still need to run it with sudo). I've run into a few problems that don't make sense to me.
Code:
#!/bin/bash
#absolute path:
#/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/max_brightness
cd /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/
declare -i max_bright
declare -i current_bright
declare -i new_bright
declare -i ten
max_bright=$(cat max_brightness)
current_bright=$(cat brightness)
new_bright=0
ten=10
function max
{
echo $max_bright > brightness
}
function min
{
echo 10 > brightness
}
function higher
{
new_bright=$(calc $current_bright + 10)
if [ $new_bright > $max_bright ]
then
new_bright=$(echo $max_bright)
fi
echo $new_bright > brightness
}
function lower
{
new_bright=$(calc $current_bright - 10)
if [ $ten > $new_bright ]
then
new_bright=10
fi
echo $new_bright > brightness
}
$1
When I run 'sudo ./backlight max' and 'sudo ./backlight min' I get the results that I'm looking for: a change in the backlight.
When I run 'sudo ./backlight higher' and 'sudo ./backlight lower' the brightness changes, but it returns a "permission denied" error on the line with the "if" statement. As a result, the "if" statement doesn't run, and if my brightness is at 10 and I run 'lower' it turns the backlight off, which I do NOT want to do. Sorry if this is a really basic question, this is one of my first attempts at bash scripting, and I just can't see why I have permission errors with variables.
The sudo password question is kinda "is you is or is you aint", though a possible avenue is to create a user <scriptname> and give him passwordless sudo and no login
*effectively making your script a daemon*
/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/max_brightness
max_bright=$(cat max_brightness)
if [ $new_bright > $max_bright ]
My guess would be that session D-Bus, which is where your elevated user rights are being applied can't touch the firmware controls because that falls to system D-Bus and I suspect there is some secret GTK voodoo we are unfamiliar with that controls the hand off.
Still, the X11 server has direct access to the hardware, can you pipe it through there?
My guess would be that session D-Bus, which is where your elevated user rights are being applied can't touch the firmware controls because that falls to system D-Bus and I suspect there is some secret GTK voodoo we are unfamiliar with that controls the hand off.
Still, the X11 server has direct access to the hardware, can you pipe it through there?
Well, it looks like I'm in way farther than I expected. That's not a bad thing, though.
I know next to nothing about D-bus, so I'll take your word for it
How would I pipe it through X11? I'm somewhat familiar with pipes on the command line, is it similar to that?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.