#!/bin/bash

#=========================================#
# Simple update notifier (DNF) v0.3.8     #
#=========================================#
# Icons
ICON="/usr/share/simple-notifier/icons/simple-notifier.png"
MICON="/usr/share/simple-notifier/icons/simple-notifier16.png"
TMP_FILE="/tmp/.simple-notifier/show_info"

# Read number of updates from previous check
UPDATES=$(cat /tmp/.simple-notifier/num_updates 2>/dev/null || echo 0)

export DISPLAY=:0.0

# Kill if no updates
if [ "$UPDATES" -eq 0 ]; then
    exit 0
fi

# Generate proper message
if [ "$UPDATES" -eq 1 ]; then
    NUM="There is $UPDATES update"
else
    NUM="There are $UPDATES updates"
fi

# Get list of upgradeable packages 
LIST=$(cat /tmp/.simple-notifier/show_info)

# Show YAD list of updates
echo "$LIST" | yad --list \
    --center \
    --title "Update Information" \
    --width=600 --height=350 --fixed \
    --window-icon="$MICON" \
    --image="$ICON" \
    --column "$NUM available" \
    --button=OK!gtk-ok:1
if [ $? -eq 1 ]; then
    exit 0
fi




