#!/bin/bash

# You can call this script like this:
# $ ./brightnessControl.sh up
# $ ./brightnessControl.sh down

# Script inspired by these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a

function get_brightness {
   /usr/bin/brightnessctl -m | /usr/bin/cut -d, -f4 | /usr/bin/tr -d %
}

function send_notification {
  icon="brightnesssettings"

  # Send the notification
  /usr/bin/dunstify -a "Brightness" -i $icon -u normal "" -h int:value:"$(get_brightness)"
}

case $1 in
  up)
    # Increase the backlight by 5%
    /usr/bin/brightnessctl -q set 5%+

    send_notification
    ;;
  
  down)
    # Decrease the backlight by 5%
    /usr/bin/brightnessctl -q set 5%-

    send_notification
    ;;
esac
