From a5bb8bc021e9e23834c6d6c64e29ffde1b831c34 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 30 Jun 2021 22:38:21 -0400 Subject: [PATCH] News feature added. --- audiogame-manager.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index e6e0633..6b9edb4 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -46,6 +46,24 @@ EOF # Dialog accessibility export DIALOGOPTS='--no-lines --visit-items' + +# Check for latest news +check_news() { + # url for news file + local newsFile="https://stormgames.wolfe.casa/media/agm.ogg" + local newsPath="${configFile%/*.conf}/.news" + local newsTag="$(curl --connect-timeout 3 -sI "$newsFile" | grep 'etag: "' | cut -d '"' -f2)" + local newsOldTag="$(cat "$newsPath" 2> /dev/null)" + if [[ "$newsTag" != "$newsOldTag" ]]; then + dialog --yes-label 'Play' \ + --no-label 'Later' \ + --backtitle 'Audiogame Manager News' \ + --yesno 'Audiogame manager news is available. Please use left and right arrows to navigate and enter to confirm.' -1 -1 || return + sox -qV0 "$newsFile" -d &> /dev/null + echo -n "$newsTag" > "$newsPath" + fi +} + # Automatic update function update() { local filePath="$(command -v ${0})" @@ -791,6 +809,8 @@ if ! command -v sox &> /dev/null ; then echo "Please install sox before continuing." exit 1 fi +# Get latest news if available +check_news # With no arguments, open the game launcher. if [[ $# -eq 0 ]]; then game_launcher