Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- input="$1"
- #either 1 or -1, must be int
- #turn off redshift animations if you don't want to commit die
- pid=$(pidof redshift)
- if [[ $pid -eq 0 ]]
- then
- number=10
- else
- current=$(ps --no-headers $pid | awk '{print $7}')
- number="${current//.}"
- fi
- new=$((number + input))
- if (( $new > 10 ))
- then
- #echo "Redshift: Max brightness reached"
- new=10
- fi
- if (( $new < 1 ))
- then
- #echo "Redshift: Min brightness reached"
- new=1
- fi
- displayval=$((new * 10))
- newnum=$(echo "scale=1; $new/10" | bc)
- #convert 10 to 1.0 etc
- killall redshift
- redshift -b "${newnum}" &
- if [ ! -s /dev/shm/rsnotifid ]
- then
- #echo "Redshift brightness: creating temp file"
- touch /dev/shm/rsnotifid
- echo 0 > /dev/shm/rsnotifid
- fi
- replaceid=$(cat /dev/shm/rsnotifid)
- replaceidnew=$(gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify redshiftbrightness.sh ${replaceid} redshift "" "" [] "{'String':<0>,'value':<${displayval}>,'String':<0>,'transient':<'true'>}" 2000 | cut -c 9- | egrep -o '[0-9]+')
- echo $replaceidnew > /dev/shm/rsnotifid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement