#!/usr/bin/env bash
# Nastav jas

icon=cs-desktop

jas=$(ddcutil getvcp 10|awk '{ print $9 }'| tr -d ',')

yad --mouse \
   --undecorated \
   --title "Jas" \
   --image="$icon" \
   --window-icon="$icon" \
   --text="Zvol jas obrazovky, teraz=$jas%" \
   --button="20%":2 \
   --button="40%":3 \
   --button="60%":4 \
   --button="80%":5 \
   --button="100%":6
ret=$?

case $ret in
2) adj=20
   ;;
3) adj=40
   ;;
4) adj=60
   ;;
5) adj=80
   ;;
6) adj=100
   ;;
*) adj=$jas
  ;;
esac

if test $jas != $adj; then
   ddcutil setvcp 10 $adj 
fi
notify-send "Display" "Jas obrazovky $adj%" --icon=dialog-information -t 10000
