Code: Select all
#!/usr/bin/env bash
YELLOW="\033[1;33m"
ENDCOLOR="\033[0m"
icon=cs-desktop
jas=$(xbacklight -get)
yad --mouse \
--undecorated \
--title "fenyerö" \
--image="$icon" \
--window-icon="$icon" \
--text="Valassz! Aktualis=$jas%" \
--button="10%":2 \
--button="40%":3 \
--button="60%":4 \
--button="80%":5 \
--button="100%":6 \
--button=gtk-cancel:1 \
--on-top
ret=$?
case $ret in
2) adj=10
;;
3) adj=40
;;
4) adj=60
;;
5) adj=80
;;
6) adj=100
;;
*) adj=$jas
;;
esac
if test $jas != $adj; then
xbacklight -set $adj
fi
echo -e $YELLOW"fenyerö bealitva!"$ENDCOLOR
exit 0
I found a better one:
Code: Select all
#!/bin/bash
# detect monitor
MON=$(xrandr -q | grep " connected" | cut -f1 -d ' ')
# find current xrandr brightness value
XR=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)
BrCur=`awk "BEGIN {print $XR*100}"` # calculate, so e.g. 0.5 gets 50
BrMax="100"
BrMin="10"
yad --undecorated --on-top --geometry=450x70+550+650 --scale --value $BrCur --print-partial --min-value $BrMin --max-value $BrMax --button="Done":1 | while read BrNew; do
# division using awk, so xrandr value gets e.g. 0.5 rather than 50
xrandr --output $MON --brightness $(awk "BEGIN {print $BrNew/100}")
done