#!/bin/bash

while [ 1 ]
do 
   stav=$(cat /sys/class/power_supply/ADP1/online)

   if [ $stav -eq 1 ]
     then sudo su -c 'echo 9 > /sys/class/backlight/acpi_video0/brightness';
     else sudo su -c 'echo 3 > /sys/class/backlight/acpi_video0/brightness'; 
   fi
sleep 2s
done

