From 8e6e52e90085d18ebada6f3e71b8a154b1dced49 Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Sun, 18 Oct 2020 16:58:42 +0100 Subject: [PATCH] updated spotify.sh --- .bash.d/spotify.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.bash.d/spotify.sh b/.bash.d/spotify.sh index d7cac4cc..3109d037 100644 --- a/.bash.d/spotify.sh +++ b/.bash.d/spotify.sh @@ -18,9 +18,18 @@ spotifysession(){ # this would prevent it from being exported to the shell as we want to make it easier to use full spotify tools #local SPOTIFY_ACCESS_TOKEN - + # SECONDS cannot be reset in the background in spotify_token_expire_timer() function + SECONDS=0 + spotify_token_expire_timer & # defined in ../.bashrc # shellcheck disable=SC2154 SPOTIFY_ACCESS_TOKEN="$(SPOTIFY_PRIVATE=1 "$bash_tools/spotify_api_token.sh")" export SPOTIFY_ACCESS_TOKEN + +} + +spotify_token_expire_timer(){ + if [ "$SECONDS" -ge 3600 ]; then + unset SPOTIFY_ACCESS_TOKEN + fi }