TOTP-Script v1.2 - download here

#!/bin/bash
#Small bashscript to get a TAN from oathtool, copy TAN to clipboard and output a small window with TAN-lifetime
#requirements: gxmessage, oathtool and xclip; apt-get install xclip oathtool gxmessage
#(C) 2018 ThEPaniC/Evil|Pan!C -> mail (at) thepanic.eu
#https://www.thepanic.eu/totpscript.html
#Version 1.2
#Released under GPL v2 or later
#http://www.gnu.org/licenses/gpl-2.0.html
secret="your secret" #your base32 encoded secret
oldtan="5" #Time in Seconds to specify a old TAN, set this value higher if you need more time to paste your TAN
windowname="TOTP-Script" #you see this windowname if you remove -borderless below
windowsize="350x100" #well, the windowsize of the gxmessage window
windowtimeout="4" #time the gxmessage window waits before it closes itself
windowoparam="-borderless -wrap" #-borderless removes the gxmessage window border, -wrap lets the text wrap

###     ***If you get strange Errors from line 22 or 25, start the script with "bash totp.sh"    ***

#tanlifetime only supports the default 30 seconds lifetime
function tanlifetime {
DATE=`date +%S`
if [ "$DATE" -le "30" ]
then
timeleft=$(( 30-$DATE ))
elif  [ "$DATE" -le "60" ]
then
timeleft=$(( 60-$DATE ))
fi
}
function gettan {
TAN="`oathtool --base32 --totp $secret`" &&
echo $TAN | xclip -selection clipboard
}
tanlifetime &&
if [ "$timeleft" -le "$oldtan" ]
then
sleeptime=$(( $timeleft+1 ))
gxmessage -geometry $windowsize $windowoparam -timeout $sleeptime -center -title $windowname "New TAN in $sleeptime seconds" &
sleep $sleeptime
tanlifetime &&
gettan &&
gxmessage -geometry $windowsize $windowoparam -timeout $windowtimeout -center -title $windowname "TAN in clipboard, EOL in $timeleft seconds"
else
gettan &&
gxmessage -geometry $windowsize $windowoparam -timeout $windowtimeout -center -title $windowname "TAN in clipboard, EOL in $timeleft seconds"
fi
exit 0