adds rofi as styling
This commit is contained in:
parent
d03146f3a1
commit
1682bed87f
9 changed files with 124 additions and 8 deletions
43
.config/rofi/scripts/2fa.sh
Executable file
43
.config/rofi/scripts/2fa.sh
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o pipefail
|
||||
|
||||
source "$HOME/.config/rofi/scripts/_lib.sh"
|
||||
|
||||
KEYRING_NAME="2fauth"
|
||||
KEYRING_VALUE="token"
|
||||
DOMAIN="https://auth.iedsoftworks.com"
|
||||
|
||||
getApiToken() {
|
||||
token=$(secret-tool lookup "$KEYRING_NAME" "$KEYRING_VALUE")
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
token=$(zenity --forms --add-multiline-entry="API Key" --text="Provide a valid API key")
|
||||
if [[ $token == "" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$token" | secret-tool store --label "2FAuth API Key" "$KEYRING_NAME" "$KEYRING_VALUE"
|
||||
}
|
||||
|
||||
getApiToken
|
||||
|
||||
setOption no-custom true
|
||||
case $ROFI_RETV in
|
||||
0)
|
||||
echo -en $(curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts" | jq -r '.[] | "\(.id)\\0display\\x1f\(.service) - \(.account)\\x1finfo\\x1f\(.)\\n"')
|
||||
;;
|
||||
1)
|
||||
id=$@
|
||||
|
||||
curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts/$id/otp" |
|
||||
jq ".password" -r |
|
||||
wl-copy
|
||||
|
||||
$(echo $ROFI_INFO | jq -r '"\(.service) - \(.account)"')
|
||||
|
||||
notify-send -i "lock" "2FA Code copied" "Copied code for '$(echo $ROFI_INFO | jq -r '"\(.service) - \(.account)"')'"
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue