#!/bin/bash
bash $(realpath $(dirname $0))/maneki-logo
menu(){
    dialog --clear --title "Which PDF Viewer do you want?" \
        --menu "Choose one of the following options:" 15 40 4 \
        1 "Atril (Pacman)" \
        2 "Atril (AUR)" \
        3 "Exit" 2>&1 >/dev/tty
}

while true; do
    choice=$(menu)
    case $choice in
        1)
            echo "Downloading Atril (Pacman)..."
            sudo pacman -S atril --noconfirm
            echo -e "\n==> Downloaded and Installed Atril (Pacman)."
            xdg-mime default atril.desktop application/pdf
            echo -e "\nSetting Default PDF Viewer to Atril (Pacman): OK"
            ;;
        2)
            echo "Downloading Atril (AUR)..."
            yay -S atril --noconfirm
            echo -e "\n==> Downloaded and Installed Atril (AUR)."
            xdg-mime default atril.desktop application/pdf
            echo -e "\nSetting Default PDF Viewer to Atril (AUR): OK"
            ;;
        3)
            echo "Exiting..."
            exit 0
            ;;
    esac
done
