#!/bin/bash

# restore saved brightness upon reboot
# if xfce is starting up, wait for xfdesktop
if [ "$XDG_CURRENT_DESKTOP" = "XFCE" ]; then
    while [ -z "$(pidof xfdesktop)" ]; do
        sleep 1
done
fi
 
sleep 1
CONFIG_FOLDER="$HOME/.config/MX-Linux/MX-Tweak/brightness"

for file in $(ls "$CONFIG_FOLDER"); do
    echo $file
    #check to see if display exists and is connected
    xrandr |grep connected |grep $file
    #if present, run command in file
    if [ $? = 0 ]; then
        source "$CONFIG_FOLDER/$file"
    fi
done
