You are not logged in.
Pages: 1
Hello,
For aesthetic reasons I would like to have a notification when I change my brightness, like you also have volume notifications. I know the power managers (gnome and xfce) supply this feature, but I don't want to use either of them, so is there any stand-alone application (for example, you have xfce-volumed for volume notifications) for brightness? I already searched the AUR but came up with nothing that looked promising.
Last edited by Unia (2011-08-27 11:07:57)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
I too would like an answer to this! The only thing I've seen is what Asus did on the original Eeepc (701) which had a nifty little OSD for a lot of things.
Offline
Perhaps someone who can actually code could do something with that?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
I have this:
#!/bin/bash
brightness="/sys/class/backlight/acpi_video0/brightness"
presbright=`cat /sys/class/backlight/acpi_video0/brightness`
perc=`expr $presbright "*" 100 "/" 24`
case "$1" in
up)
echo $(( ${presbright}+1 )) > $brightness
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness &
;;
down)
echo $(( ${presbright}-1 )) > $brightness
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness &
;;
status)
echo $presbright
;;
*)
echo "Accepted arguments are: up, down, status."
;;
esac
exit 0
My brightness keys didn't work out of the box, so I wrote a script for it. I just added the notification stuff (used notify-osd) today. Replace $user with your username, or prefix cat with sudo - whatever suits your scenario best. My brightness keys generate ACPI events and the script is called by the ACPI daemon, so everything is run as root, but notify-send won't work because root isn't authenticated with D-Bus etc. blabla. You also need to replace 24 with the maximum value your backlight supports.
Last edited by .:B:. (2011-08-24 18:09:38)
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
So you wrote that for notify-osd? Do you happen to know any way I could adjust for xfce4-notifyd? Also, how would I find out the max brightness? And how would I make it called by the ACPI daemon?
sorry for the many questions, am totally new to this sort of stuff...
Last edited by Unia (2011-08-24 19:54:34)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Won't work with xfce4-notifyd, the synchronous hint is only understood by notify-osd. For all other notifiers you need to update them programmatically. Which means either C or python. Kinda shame, because the synchronous hint is perfect for such shell scripting.
Offline
Hmm.. I'm willing to give notify-osd a shot.
Say I installed that, I would only have to look up my max brightness and change the $user value, no?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Yes. Also, if you take a careful look at the variables in my script, it's pretty easy to find out where your brightness values are stored.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Ok, thank you! I will have a go at this tomorrow!
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Where would I put my max brightness? I assume somewhere in this line, but I would like to be sure before I might harm my hardware:
perc=`expr $presbright "*" 100 "/" 24`
Also, you said you had the ACPI daemon call the script, how would I do that?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Where would I put my max brightness? I assume somewhere in this line, but I would like to be sure before I might harm my hardware:
perc=`expr $presbright "*" 100 "/" 24`
Like I said:
You also need to replace 24 with the maximum value your backlight supports.
Also, you said you had the ACPI daemon call the script, how would I do that?
Adapt /etc/acpi/handler.sh. But as I said: that only works if it generates ACPI events.
Last edited by .:B:. (2011-08-25 22:04:19)
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Moved to Newbie Corner. Have you checked the Wiki for some of these questions?
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Have you checked the Wiki for some of these questions?
Not for the max brightness, I guess I misread .:B:.'s post or not good enough. For the ACPI, I did search but didn't know the article I need was "ACPI Hotkeys". I did not scan those pages because of limited time.
I will have a go at all this now - I do have time now since it's weekend
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Well.. I got it all working now - but when I'm using the notifications, it seems like switching brightness levels is a bit choppier (and more flashing) than without the notifications.
Also, my max brightness is 9:
┌─[jente@lappy ~][20:57:26]
└─■ cat /sys/class/backlight/acpi_video0/max_brightness
9
But with notifications enabled it only goes up to 8. Lastly, whilst decreasing brightness, it goes down to 0 in just four steps.
Is something wrong?
EDIT: When I edit the script to not modify /sys/class/backlight/acpi_video0/brightness, the switching is as it should be. I am now working on editing the script to only get the current brightness level and calculate a percentage from there. As my bash skills (sadly) aren't that good, I'm puzzling now, but I will post the results once I'm done!
Last edited by Unia (2011-08-26 20:00:14)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Done! Somehow it firstly didn't want to accept the expr command, so I tried all sorts of stuff, but this morning it suddenly accepted expr so in the end, the script didn't change that much. Anyway, here's my version:
#!/bin/bash
curbright=`cat /sys/class/backlight/acpi_video0/brightness`
perc=`expr $curbright "*" 100 "/" 9`
case "$1" in
up)
sudo -u jente notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness &
;;
down)
sudo -u jente notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness &
;;
status)
echo $curbright
;;
*)
echo "Accepted arguments are: up, down, status."
;;
esac
exit 0
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Thanks to .:B:. and Unia's for their efforts. I'm sorry I couldn't contribute anything meaningful (I can't code for beans). I will try both scripts now and see which fits my netbook's configuration.
Offline
As for volume notifications, the xfce4-volumed will monitor the Master level and display a popup accordingly, you don't need any scripting for that. Apparently that notification stuff also picks up on downloads in Firefox and lets you know when they're done... Kinda creepy, really.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Nothing creepy about it, it's Firefox that sends notifications. That's the point of having a notification daemon, it's there so that apps can display notifications in a consistent way. If you compile Firefox yourself, you can turn that off, so that Firefox will use an internal notification mechanism.
Offline
As for volume notifications, the xfce4-volumed will monitor the Master level and display a popup accordingly, you don't need any scripting for that.
I asked you for that because a script like your brightness script would be lighter. And it could make me drop all xfce dependencies I have (which basically are just those for xfce4-volumed).
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Sorry man, don't have a script for it. I use xfce4-volumed myself, I have some XFCE libs installed anyway (Thunar etc.) so it didn't add any overhead.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
That's cool. It's not that heavy anyway and it does a good job. Thanks again for your brightness script, it's working like a charm!
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
For anyone interested, I found a volume script after all on our boards. Here's the topic link:
https://bbs.archlinux.org/viewtopic.php?id=69589
And here is the script itself:
#!/bin/sh
usage="usage: $0 -c {up|down|mute} [-i increment] [-m mixer]"
command=
increment=5%
mixer=Master
while getopts i:m:h o
do case "$o" in
i) increment=$OPTARG;;
m) mixer=$OPTARG;;
h) echo "$usage"; exit 0;;
?) echo "$usage"; exit 0;;
esac
done
shift $(($OPTIND - 1))
command=$1
if [ "$command" = "" ]; then
echo "usage: $0 {up|down|mute} [increment]"
exit 0;
fi
display_volume=0
if [ "$command" = "up" ]; then
display_volume=$(amixer set $mixer $increment+ unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi
if [ "$command" = "down" ]; then
display_volume=$(amixer set $mixer $increment- unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi
icon_name=""
if [ "$command" = "mute" ]; then
if amixer get Master | grep "\[on\]"; then
display_volume=0
icon_name="notification-audio-volume-muted"
amixer set $mixer mute
else
display_volume=$(amixer set $mixer unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi
fi
if [ "$icon_name" = "" ]; then
if [ "$display_volume" = "0" ]; then
icon_name="notification-audio-volume-off"
else
if [ "$display_volume" -lt "33" ]; then
icon_name="notification-audio-volume-low"
else
if [ "$display_volume" -lt "67" ]; then
icon_name="notification-audio-volume-medium"
else
icon_name="notification-audio-volume-high"
fi
fi
fi
fi
notify-send " " -i $icon_name -h int:value:$display_volume -h string:synchronous:volume
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
As a follow-up, if you happen to use the notify-osd-icons (in the AUR), I have a more fine-grained script that uses the different brightness statuses (it provides five different stages - off, low, medium, high, full).
brightness="/sys/class/backlight/acpi_video0/brightness"
presbright=$(cat /sys/class/backlight/acpi_video0/brightness)
perc=$(expr $presbright "*" 100 "/" 8)
video/brightnessdown)
case "$2" in
BRTDN)
echo $(( ${presbright}-1 )) > $brightness
if [ $presbright = 1
if [ $presbright = 0 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-off -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 1 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 2 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 3 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 4 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 5 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 6 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-high -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 7 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-high -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
fi
;;
esac
;;
video/brightnessup)
case "$2" in
BRTUP)
echo $(( ${presbright}+1 )) > $brightness
if [ $presbright = 1 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 2 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-low -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 3 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 4 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 5 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-medium -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 6 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-high -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 7 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-high -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
elif [ $presbright = 8 ]
then
sudo -u $user notify-send " " -i notification-display-brightness-full -h int:value:$perc -h string:x-canonical-private-synchronous:brightness
fi
;;
esac
;;
This is part of my ACPI handler.sh script.
Last edited by .:B:. (2011-12-25 00:42:21)
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Pages: 1