and Oleksii Shurubura
This plugin will generate the TOTP tokens and allows to copy them to clipboard
#!/bin/bash
# <xbar.title>Authenticator</xbar.title>
# <xbar.version>v0.2</xbar.version>
# <xbar.author>Gunasekaran Namachivayam, Oleksii Shurubura</xbar.author>
# <xbar.author.github>gunasekar</xbar.author.github>
# <xbar.desc>This plugin will generate the TOTP tokens and allows to copy them to clipboard</xbar.desc>
# <xbar.image>https://i.imgur.com/1AYh44b.png</xbar.image>
# Hack for language not being set properly and unicode support
export LANG="${LANG:-en_US.UTF-8}"
# update the key value pairs as per your requirement
# Key - for your reference to identify a TOTP Account
# Value - base32 secret key corresponding to the TOTP Account
totp_secrets=( "OpenVPN:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"BitBucket:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"GitHub:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"Okta:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"GrabTaxi:2b2drladcdoxtpheuom6t4zjsr6tq7ix" )
# oath-toolkit needs to be installed. Use 'brew install oath-toolkit'
# update the appropriate path of oathtool binary below
oathtool="/usr/local/bin/oathtool"
function get-totp {
$oathtool --totp -b "$1"
}
if [[ "$1" == "copy" ]]; then
echo -n "$(echo -n "$2")" | pbcopy
exit
fi
# Default Lock icon
echo " | templateImage=iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAJKADAAQAAAABAAAAJAAAAAA4NgJpAAAACXBIWXMAABYlAAAWJQFJUiTwAAACZmlUWHRYTUw6Y29tLmFkb2JlLnht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WWBxc6DUT3heM5HS6kwkSqzXbpNt0aiiK7JVCP/s4zGdyfW20RJ/xa+VAcDKUHQOSEPizoqLizZ6engF8ysqiwqNHo1MNDcuXbtny0SHZHhXeENjw5B/9cRzlBe8xvm94BdQLtYIdq5q5i30b+RnfSX/m2/laK3tD4wJbXV2pkV8FdjwifFBTU7NAGuHlSBYgOBm4y2YpM2TAZI8aY4nEhiJvsKO08Qm1OZVolFsbQp+Ojo5e5r0L/OcDu4M8O0zD2/K9j8VialIgFu86JLdsBwW2SJM42+eEfmFQsFeKmmmBDMSMXHrAN6qlufxOCLyAkdzIpHzTRTpf/d1NTU2L2zs6+NvyscAOdwp3tbe3z5OeULZvf/4iDdwn7BWYs6O7u9uOe0oy7G46wYegyP3C0wKfG9yyXwhHBDKAH58v1wmMc8R87+DPVYFAJuPd5awz+DHC1EJYD1xqTwn8m/hSGBSOCdzy7wmtApefSUFQCmY7K22EIv948sRQKxlCIftizrCrwybCpyx7fFw/veC4kUkMLKxr3j5PSL+92W0GJDgajpm3uR23mtPLjAllhWR++HSx+BlhRiSyYp5f3X8BrCx+fwRlX3oAAAAASUVORK5CYII="
# Google Authenticator icon
# If you would like to change the icon to Google Authenticator
# comment above and uncomment below
#echo " | image=iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAJKADAAQAAAABAAAAJAAAAAA4NgJpAAAACXBIWXMAABYlAAAWJQFJUiTwAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZ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ddCYTRzKM4tvklcOHDw89zg6FPNKwAIgfhiwDP9m9+45l+K8gOG/kcjmCYft3yQQvDqZ/EkeS7q4ujbMkMopHWLKyoacHDXaZwE1uLB73co2NcZSBbyIwTPPo2KrCFv48AYjPeT4iqD179gyVCnObZmdnT8BSCyd0upjVjhmo5xPUnSCP4yov1CGmaoA65NmxmItS4SPWEEq2BcNOuJXiy2SGYHCFdQKCascTLqt9GbmPz/r63n3N9f23EcC9CQSwG7qBGUXKqn0LTBoMZl6Mrfn8/OVrX//90C8OH9ZP6ae5qVbncwFxISxZ9M+G4319m8ENj51bgQP/bDCyUWyxQqPGzwRGcFMCox/fIGd++uab+s8GAmGvgrywn9SiqPm9JKBoLdmC0EX/junr62tH12hB9wmbmRgVJNbovn37qv+OwX4D+8ynxUsk+7+6ExjjaykhXMO1S617/P2/zdDjGzE3QP///F96/wKtrAwThKHV4QAAAABJRU5ErkJggg=="
echo '---'
echo "Clear Clipboard | bash='$0' param1=copy param2=' ' terminal=false"
echo "---"
for secret in "${totp_secrets[@]}" ; do
KEY="${secret%%:*}"
VALUE="${secret##*:}"
token=$( get-totp "$VALUE" )
echo "$KEY | bash='$0' param1=copy param2='$token' terminal=false"
done