#!/bin/bash
panel_fifo="/tmp/i3_lemonbar1_${USER}"
panel_commands="/tmp/i3_lemonbar2_${USER}"

if [[ "$1" == "-b" ]]; then
    icon="-s /usr/share/pixmaps/volnoti/display-brightness-symbolic.svg"
    if [[ "$2" == "up" ]]; then
        level=$(brillo -A 5 -u 100000; brillo)
    elif [[ "$2" == "down" ]]; then
        level=$(brillo -U 5 -u 100000; brillo)
    elif [[ "$2" == "set" ]]; then
        level=$(brillo -S $3; brillo)
    fi
    echo "BRIGHT$level" > $panel_fifo
elif [[ "$1" == "-v" ]]; then
    if [[ "$2" == "up" ]]; then
        amixer -q set Master 5%+
    elif [[ "$2" == "down" ]]; then
        amixer -q set Master 5%-
    elif [[ "$2" == "toggle" ]]; then
        amixer -q set Master toggle
    fi
    level=$(~/.i3/lemonbar/get_vol.sh)
    if [[ "$level" == "MUTE" ]]; then
        level="-m"
    elif [[ "$level" == "NONE" ]]; then
        echo "Missing"
    fi
fi

if [[ "$2" != "set" ]]; then
    volnoti-show $icon $level
fi
