pythontotp-dmenu/pythonTOTP-dmenu

24 lines
611 B
Plaintext
Raw Permalink Normal View History

2020-08-24 16:37:18 +02:00
#!/bin/python3
import dmenu
import pyotp
import clipboard
keysfile=open('keys', 'r')
keys=[]
names=[]
alllines=keysfile.readlines()
for i in range(0, len(alllines)):
2020-08-24 16:52:54 +02:00
if i%2==0: #alternatively put the name of the service and the key in each array
2020-08-24 16:37:18 +02:00
names.append(alllines[i][:-1])
else:
keys.append(alllines[i][:-1])
2020-08-24 16:52:54 +02:00
chose=dmenu.show(names,case_insensitive=True, prompt='Search:') #get the selection from the user through dmenu
2020-08-24 16:37:18 +02:00
for i in range(0,len(keys)):
if chose==names[i]:
totp = pyotp.TOTP(keys[i])
clipboard.copy(totp.now())
2020-08-24 16:52:54 +02:00
break
2020-08-24 16:37:18 +02:00
else:
continue