Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-24 Thread Greg Wooledge
On Tue, Oct 24, 2023 at 08:54:35AM +0100, Tixy wrote:
>   step=200
>   curval=`cat $device/brightness`
>   newval=`echo $(expr $curval - $step)`

Just FYI, all POSIX compatible shells can do integer arithmetic without
calling expr(1).

newval=$((curval - step))

Also, assuming "$device/brightness" is a (pseudo-)file containing a
textual representation of a number, you can read it with "read" to avoid
forking an unnecessary process.

read -r curval < "$device/brightness"



Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-24 Thread tomas
On Tue, Oct 24, 2023 at 09:32:24AM +0200, basti wrote:
> 
> 
> On 24.10.23 06:18, David Wright wrote:
> > On Mon 23 Oct 2023 at 20:03:50 (+0200), basti wrote:
> > > I have a Lenovo E16 Gen1 with Intel Iris and try to adjust brightness
> > > via Fn-Keys.
> > > All other Fn-Keys are working.

[...]

> OK, I can write the values ​​to
> /sys/class/backlight/intel_backlight/brightness
> 
> The default is 15040, which seems to be the maximum.
> Nothing visible changes between 15040 and 13000.
> 60 is very dark.
> It therefore looks like an exponential function.
> 
> I have to see how I can represent this in a function to use it with the
> fn-keys.

What I have done (Thinkpad X230 here) is to put this in
/etc/acpi/actions/brite (call it how you like):


#!/bin/sh
logger "[ACPI] $@"
BASE="/sys/class/backlight/intel_backlight"
CURR=$(cat "$BASE/brightness")
MAX=$(cat "$BASE/max_brightness")
# MIN is some arbitrary "low" value. Note that for values
# of MIN below 6 (more precisely: 2/11 for our factor), the
# thing gets stuck at the low end: (13 * x) / 11 == x,
# in integer arithmetic, for x <= 5.
#
# The "exponential" algorithm is a bit long at the low
# end. We might consider stretching there. Or increasing
# MIN.

MIN=20
if [ "$CURR" -lt "$MIN" ] ; then CURR="$MIN" ; fi

# NOTE: 11/13 is approx the fourth root of 1/2:
#   i.e. four steps are a doubling/halving
#   of brightness (constant steps gave too
#   coarse jumps in the low range)

case $1 in
  video/brightnessdown* )
NEW=$(( (11 * CURR) / 13 )) 
;;
  video/brightnessup* )
NEW=$(( (13 * CURR) / 11 )) 
;;
  * )
exit 0
;;
esac

if [ "$NEW" -lt "$MIN" ] ; then NEW="$MIN" ; fi
if [ "$NEW" -gt "$MAX" ] ; then NEW="$MAX" ; fi
logger "[ACPI] brightness $CURR --> $NEW"
echo "$NEW" > $BASE/brightness


The real action is in the last line, which writes to the sys file.

Then hook it up on your acpi events. In /etc/acpi/events/briteup , I
have this:

event=video/brightnessup
action=/etc/acpi/actions/brite "%e"


and in .../britedn, this

event=video/brightnessdown
action=/etc/acpi/actions/brite "%e"


I *think* that was all. Now you have to find out how the ACPI events
are actually spelt by your computer (the "brightnessup" and "...down"
above). For this, you enter

  acpi_listen

into your favourite terminal and hit the keys in question.

It's a long while ago and my notes are fragmentary, so perhaps I've
forgotten something.

The nice part is that this works outside of X, too.

Cheers
-- 
t


signature.asc
Description: PGP signature


Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-24 Thread Tixy
On Tue, 2023-10-24 at 09:32 +0200, basti wrote:
> 
> OK, I can write the values ​​to 
> /sys/class/backlight/intel_backlight/brightness
> 
> The default is 15040, which seems to be the maximum.
> Nothing visible changes between 15040 and 13000.
> 60 is very dark.
> It therefore looks like an exponential function.
> 
> I have to see how I can represent this in a function to use it with the 
> fn-keys.
> 

You can edit ~/.config/openbox/lxde-rc.xml

Here's my full notes from when I did what your trying to do on a laptop
many years ago. This obviously needs modifying for your machine...

0. Edit /etc/rc.local to add

# make brightness writeable
chmod a+w 
/sys/devices/pci:00/:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness
# set brightness to a nice default
echo 1200 
>/sys/devices/pci:00/:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness

   The make file executable

chmod a+x /etc/rc.local

   UPDATE: rc.local now needs a shebang at the top, i.e. #!/bin/sh

1. Create /home/tixy/bin/bl- to reduce brightness in steps

#!/bin/bash


device="/sys/devices/pci:00/:00:02.0/drm/card0/card0-LVDS-1/intel_backlight"
step=200
curval=`cat $device/brightness`
newval=`echo $(expr $curval - $step)`
if [ $newval -le $step ]; then
  newval=$step
fi
echo $newval
echo $newval >$device/brightness

2. Create /home/tixy/bin/bl+ to increase brightness in steps

#!/bin/bash


device="/sys/devices/pci:00/:00:02.0/drm/card0/card0-LVDS-1/intel_backlight"
step=200
curval=`cat $device/brightness`
maxval=`cat $device/max_brightness`
newval=`echo $(expr $curval + $step)`
if [ $newval -ge $maxval ]; then
  newval=maxval
fi
echo $newval
echo $newval >$device/brightness

3. Edit '' section of ~/.config/openbox/lxde-rc.xml


  
/home/tixy/bin/bl+
  


  
/home/tixy/bin/bl-
  




Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-24 Thread basti




On 24.10.23 06:18, David Wright wrote:

On Mon 23 Oct 2023 at 20:03:50 (+0200), basti wrote:

I have a Lenovo E16 Gen1 with Intel Iris and try to adjust brightness
via Fn-Keys.
All other Fn-Keys are working.

basti@thinkpad:~$ xbacklight -set 50
No outputs have backlight property

I also try to create a xorg.conf:

|Section "Device" Identifier "Intel Graphics" Driver "intel" Option
"Backlight" "intel_backlight" EndSection But after that X is not
start. [ 20.735] (II) LoadModule: "intel" [ 20.735] (WW) Warning,
couldn't open module intel [ 20.735] (EE) Failed to load module
"intel" (module does not exist, 0) [ 20.735] (EE) No drivers
available. I use LXDE as Desktop. How can I get it working.


Do you have the following file:

   $ cat /sys/class/backlight/intel_backlight/brightness
   40
   $

If so, do you get brightness changes when you write values
into it:

   # printf '%s' "60" > /sys/class/backlight/intel_backlight/brightness

Cheers,
David.



OK, I can write the values ​​to 
/sys/class/backlight/intel_backlight/brightness


The default is 15040, which seems to be the maximum.
Nothing visible changes between 15040 and 13000.
60 is very dark.
It therefore looks like an exponential function.

I have to see how I can represent this in a function to use it with the 
fn-keys.




Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-23 Thread David Wright
On Mon 23 Oct 2023 at 20:03:50 (+0200), basti wrote:
> I have a Lenovo E16 Gen1 with Intel Iris and try to adjust brightness
> via Fn-Keys.
> All other Fn-Keys are working.
> 
> basti@thinkpad:~$ xbacklight -set 50
> No outputs have backlight property
> 
> I also try to create a xorg.conf:
> 
> |Section "Device" Identifier "Intel Graphics" Driver "intel" Option
> "Backlight" "intel_backlight" EndSection But after that X is not
> start. [ 20.735] (II) LoadModule: "intel" [ 20.735] (WW) Warning,
> couldn't open module intel [ 20.735] (EE) Failed to load module
> "intel" (module does not exist, 0) [ 20.735] (EE) No drivers
> available. I use LXDE as Desktop. How can I get it working.

Do you have the following file:

  $ cat /sys/class/backlight/intel_backlight/brightness
  40
  $ 

If so, do you get brightness changes when you write values
into it:

  # printf '%s' "60" > /sys/class/backlight/intel_backlight/brightness

Cheers,
David.



Re: Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-23 Thread Charles Curley
On Mon, 23 Oct 2023 20:03:50 +0200
basti  wrote:

> I have a Lenovo E16 Gen1 with Intel Iris and try to adjust brightness 
> via Fn-Keys.
> All other Fn-Keys are working.

Your best bet for this might be the thinkwiki.
https://www.thinkwiki.org/wiki/ThinkWiki

Good luck.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/



Lenovo E16 Gen1 with Intel Iris adjust brightness, get Fn-Keys working

2023-10-23 Thread basti

Hello,
I have a Lenovo E16 Gen1 with Intel Iris and try to adjust brightness 
via Fn-Keys.

All other Fn-Keys are working.

basti@thinkpad:~$ xbacklight -set 50
No outputs have backlight property

I also try to create a xorg.conf:

|Section "Device" Identifier "Intel Graphics" Driver "intel" Option 
"Backlight" "intel_backlight" EndSection But after that X is not start. 
[ 20.735] (II) LoadModule: "intel" [ 20.735] (WW) Warning, couldn't open 
module intel [ 20.735] (EE) Failed to load module "intel" (module does 
not exist, 0) [ 20.735] (EE) No drivers available. I use LXDE as 
Desktop. How can I get it working. Best Regards |