You are not logged in.

#1 2017-12-08 15:30:47

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

toggle brightness of primary/connected monitor

for the benefit of reading an ebook.

https://raw.githubusercontent.com/bront … Brightness

Tested on two machines now and seems to be working.
Patching to tint2, one could use clock rclick:

clock_rclick_command = toggleBrightness

Last edited by brontosaurusrex (2017-12-08 20:17:25)

Offline

#2 2018-01-05 16:33:37

vinzv
Member
Registered: 2017-09-12
Posts: 186
Website

Re: toggle brightness of primary/connected monitor

Very useful and a good supplement to redshift. Thanks a lot!

Offline

#3 2018-01-05 18:55:33

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: toggle brightness of primary/connected monitor

Yw, p.s. actually this will probably fight with redshift for control (won't work with other words).

Offline

#4 2018-01-05 23:16:16

vinzv
Member
Registered: 2017-09-12
Posts: 186
Website

Re: toggle brightness of primary/connected monitor

Yep, saw that. But outside of redshift's active timespan your script is working fine!

Offline

#5 2018-01-06 09:38:44

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: toggle brightness of primary/connected monitor

thanks for this.
i noticed a flaw: if someone/something puts the brightness to some other than those 2 values, script will fail.
so i added a failsafe "else".

also i hopefully made the search for the current brightness a little more robust, and changed the shell from bash to dash, which should increase its speed significantly.

#!/bin/dash

# software toggle brightness of primary/connected monitor
# for the benefit of reading an ebook
# https://wiki.archlinux.org/index.php/xrandr

normal="1.0"
reader="0.70"

now="$(xrandr --verbose | grep -wA10 connected | grep Brightness | cut -f2 -d ' ')"
monitor="$(xrandr | grep -E " connected (primary )?[1-9]+" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")"


if [ "$now" = "$reader" ]; then
    xrandr --output "$monitor" --brightness "$normal" 
elif [ "$now" = "$normal" ]; then
    xrandr --output "$monitor" --brightness "$reader" 
else
    xrandr --output "$monitor" --brightness "$normal" 
fi

Offline

#6 2018-02-22 20:15:42

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: toggle brightness of primary/connected monitor

@ohnonot; added, also "tail -1" to get some basic protection against multihead configurations (It may or may not do what one wants).

Last edited by brontosaurusrex (2018-02-22 20:18:44)

Offline

Board footer

Powered by FluxBB