Change Luminosity, simple and effective

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

Change Luminosity, simple and effective

#1 Post by fabrice_035 »

Hello,

8)

Code: Select all

#!/bin/sh

# mini tool ! Easy change luminosity (mouse wheel) 
# Fabrice (fxc) 1/12/15 

b=`cat /sys/class/backlight/intel_backlight/brightness`
pth="/sys/class/backlight/intel_backlight/brightness"


lumi () {
if [ "$hs" -lt "50" ] ; then
hs="50"
echo $(( $b + $hs )) > /sys/class/backlight/intel_backlight/brightness
exit 0
fi

echo $(( $b + $hs )) > /sys/class/backlight/intel_backlight/brightness

}
export -f lumi


GTKDIALOG=gtkdialog



MAIN_DIALOG='
<window title="Lum" decorated="false"  skip_taskbar_hint="true"  window_position="2">
	
<vbox border-width="1" spacing="1">
	<hbox homogeneous="true">
<button use-stock="true" >  <input file stock="gtk-quit"></input> </button>

	
				<hscale space-expand="true" space-fill="true" range-min="10"  range-max="2000" range-value="'$b'"  range-step="10" tooltip-text="change luminosity">
					<variable>hs</variable>
				<action>lumi</action>
				</hscale>
			</hbox>
			</vbox>

	<variable>MAIN_DIALOG</variable>

</window>
'
export MAIN_DIALOG

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG  --program=MAIN_DIALOG ;;
esac
:shock:

Bye..
Attachments
lum.png_2015-12-01_214247.png
(3.76 KiB) Downloaded 564 times

uio
Posts: 76
Joined: Mon 31 Aug 2015, 18:01

#2 Post by uio »

I like the idea !
But I just tried it, and it didn't work...
would this be the same thing as brightness ??

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#3 Post by bigpup »

Specifically what device are you doing this on?

Code: Select all

b=`cat /sys/class/backlight/intel_backlight/brightness`
pth="/sys/class/backlight/intel_backlight/brightness" 
This indicates to me, it is for a specific device, that uses intel drivers.
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#4 Post by fabrice_035 »

Hi,
My laptop is a Dell E6420.

Search with Google (or other :roll: ) with "/sys/class/backlight/intel_backlight/brightness" , found solutions i think.

A+

phat7
Posts: 179
Joined: Fri 05 Jun 2015, 08:54

#5 Post by phat7 »

Simple and not effective :shock:
Bye..

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#6 Post by corvus »

Hi fabrice_035, I tried your script on an Asus A555LB with hybrid video card ( Intel / Nvidia ) and works well. Thanks for this little gem. :D

Best Regards.

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#7 Post by Flash »

This controls the screen brightness with a scroll wheel? When it works, I mean. :)

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#8 Post by corvus »

Not everything is for everyone. 8)

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#9 Post by Flash »

Thanks for clearing it up. :?

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#10 Post by MochiMoppel »

Flash wrote:This controls the screen brightness with a scroll wheel? When it works, I mean. :)
:lol: Yes, when it works.
It doesn't work for me either though I have Intel graphics and the file /sys/class/backlight/intel_backlight/brightness is present. Contains 0 and doesn't do anything when changed to a different value.

What works for me is changing the value in /sys/class/backlight/acpi_video0/brightness. And, to fend off any funny comments, I do not claim that it works for everyone and on any system. You may have to experiment.

Speaking of simplicity I could control brightness with 2 simple scripts, each assigned to its own desktop icon. Works similar as the button on my laptop where I have to press dedicated keys to increase/decrease brightness 1 notch.

Code: Select all

#!/bin/bash
#Decrease brightness
BP=/sys/class/backlight/acpi_video0
AB=$(< $BP/actual_brightness)
((AB>0)) && echo $((AB-1)) > $BP/brightness

Code: Select all

#!/bin/bash
#Increase brightness
BP=/sys/class/backlight/acpi_video0
MB=$(< $BP/max_brightness)
AB=$(< $BP/actual_brightness)
((AB<MB)) && echo $((AB+1)) > $BP/brightness

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#11 Post by drunkjedi »

There is a brightness script in /usr/sbin of tahr64.
But I don't know how to use it.
It's contents are

Code: Select all

#!/bin/sh
if find /sys/class/backlight/acpi_video0/brightness
then
brightness=`cat /sys/class/backlight/acpi_video0/brightness`
echo $brightness > /root/.config/brightness.conf
fi
Ohh and mine isn't a laptop but a desktop, so I don't know if this will work for me. I generally control brightness from physical buttons.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#12 Post by fabrice_035 »

hi,

of course work fine for me,

Device info, display:

Code: Select all

OpenGL Renderer		: Mesa DRI Intel(R) Sandybridge Mobile x86/MMX/SSE2
My computer is a DELL E6420.

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#13 Post by corvus »

Flash wrote:Thanks for clearing it up. :?
I apologise if my answer has offended you but as pointed out by bigpup and MochiMoppel only works with certain hardware and you must anyway experiment.
Greetings to all.

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#14 Post by Flash »

I wasn't offended, just not enlightened. :)

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#15 Post by corvus »

Flash wrote:I wasn't offended, just not enlightened. :)
The important thing is to have clarified.

corvus
Last edited by corvus on Sat 13 Feb 2016, 10:55, edited 1 time in total.
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#16 Post by rg66 »

Something like this might work (credit to Jemimah). Can't test as am on desktop.

Code: Select all

if [ -f /sys/class/backlight/acpi_video0/brightness ] ; then
  	   b=`cat /sys/class/backlight/acpi_video0/brightness`
        pth="/sys/class/backlight/acpi_video0/brightness"
else
        FILE=`ls /sys/class/backlight/*/brightness |head -n1`
        b=`cat $FILE`
        pth="$FILE" 
fi
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#17 Post by fabrice_035 »

update for Dell xps 1640, tested ok.

Work only with range-min="1" range-max="16

Code: Select all

#!/bin/sh

# mini tool ! Easy change luminosity (mouse wheel) 
# 
# !!!! right for DELL XPS 1640 !!!!
#
# Fabrice (fxc) 14 fev 2016

b=`cat /sys/class/backlight/acpi_video0/actual_brightness `

lumi () {
if [ "$hs" -lt "0" ] ; then
hs="1"
echo $(( $b + $hs )) > /sys/class/backlight/acpi_video0/brightness
exit 0
fi
echo $(( $b + $hs )) > /sys/class/backlight/acpi_video0/brightness

}
export -f lumi

GTKDIALOG=gtkdialog

MAIN_DIALOG='
<window title="Lum" decorated="false"  skip_taskbar_hint="true"  window_position="2">
	
<vbox border-width="1" spacing="1">
	<hbox homogeneous="true">
<button use-stock="true" >  <input file stock="gtk-quit"></input> </button>
				<hscale space-expand="true" space-fill="true" range-min="1"  range-max="16" range-value="'$b'"  range-step="1" tooltip-text="change luminosity">
					<variable>hs</variable>
				<action>lumi</action>
				</hscale>
			</hbox>
			</vbox>
	<variable>MAIN_DIALOG</variable>
</window>
'
export MAIN_DIALOG
case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG  --program=MAIN_DIALOG ;;
esac

Post Reply