You are not logged in.
To change screen brightness in dwm, I use
sudo brightness upwhere brightness is the script
#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo "Please run $0 as root"
exit
fi
bd=/sys/devices/pci0000:00/0000:00:02.0/drm/card*/card*-eDP-1/intel_backlight/brightness
bdv=$(cat $bd)
case $1 in
up)
echo $(( bdv + 100 )) > $bd
cat $bd
;;
down)
echo $(( bdv - 100 )) > $bd
cat $bd
;;
*)
echo "$bdv"
esacThe drawback is that if I bind that to a keyboard key in dwm as in
static const char *cmdbrightnessup[] = { "sudo", "brightness", "up", NULL };
static Key keys[] = {
/* modifier key function argument */
{ 0, XF86MonBrightnessUp, spawn, {.v = cmdbrightnessup } }
};then my user needs to have root access without being prompt for a password for it to work.
Is there another way to set screen brightness that does not require root access? after all, in gnome the same button is bound to the same actoin, and there root access is not needed.
Last edited by nicolo (2017-09-09 02:32:18)
Offline
Add an entry to sudoers so that your user can run the brightness command as root without needing a password.
Offline
Actually, I've just realised that it boils down to add that command to sudoers file. So my question: how do I add a command to sudoers such that every user can run it without being asked for root password? and perhaps, since it is related, how do I add pacman command so that only my user is not prompted by root pwd?
Offline
how do I add a command to sudoers such that every user can run it without being asked for root password?
Did you know we have a Wiki for that kind of things? Or web search engines?
Also, I know there is xbacklight, although I don't know if that's suitable here...
Have you tried making the backlight buttons work with ACPI? It's probably less of a hack (and would also work in a TTY environment).
Offline
I think that adding to /etc/sudoers
ALL ALL=NOPASSWD: /path/to/brightness
myuser ALL=NOPASSWD: /usr/bin/pacman -Syyushould do the job. Thanks.
Last edited by nicolo (2017-09-09 02:31:59)
Offline
myuser ALL=NOPASSWD: /usr/bin/pacman -Syyu
May I ask what the purpose of this is?
Also, please read the pacman man page (especially the section about -y), because regularly running -Syyu is not only pointless, it also generates unnecessary traffic, as you download a new version of the package database everytime regardless of whether it is necessary or not.
Last edited by ayekat (2017-09-09 06:43:16)
Offline
May I ask what the purpose of this is?
My guess is that nicolo has another script running automatic updates in the background. In which case we'll see him back here soon when that totally borks his system. I'll make the popcorn.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
myuser ALL=NOPASSWD: /usr/bin/pacman -Syyu
It would be useful for manual updating too.
Last edited by RoundCube (2017-09-09 12:11:53)
Offline
Well your guess is bullshit. It's just so that I don't have to type a password when I upate with pacman, which I do by hand daily. I see, so is it better to have -Syu?
Last edited by nicolo (2017-09-09 15:51:43)
Offline