#!/bin/bash

app_dir="/usr/share/applications";
tmp_compare="/tmp/applications-modified-time";

case $1 in 
set)
    stat -c %Y $app_dir > $tmp_compare;
;;
check)
    current_date=$(stat -c %Y $app_dir)
    past_date=$(cat $tmp_compare)
    if [ "$current_date" != "$past_date" ]; then
        desktop-menu --write-out-global;
    else 
        exit 0
    fi
;;
force)
    desktop-menu --write-out-global;
;;
*)
    echo "Not an option";
    echo "set - sets the log for pre apt time stamp"
    echo "check - checks to see if the applications directory has changed in post apt"
    echo "force - forces an update"
;;
esac

