gnupg: use a gtk3-based pinentry-program
[~bandali/configs] / .local / bin / rofi-remmina
1 #!/usr/bin/env python2
2
3 import ConfigParser
4 import os
5 from subprocess import Popen, PIPE
6
7 remmina_dir = os.path.expanduser("~/.local/share/remmina")
8
9 fdict = dict()
10
11 for f in os.listdir(remmina_dir):
12 fp = os.path.join(remmina_dir, f)
13 c = ConfigParser.ConfigParser()
14 c.read(fp)
15 n = c.get('remmina', 'name')
16 fdict[n] = fp
17
18 lines = max(min(15, len(fdict)), 1);
19 width = len(max(fdict.keys(), key=len))
20 rofi = Popen(["rofi", "-i", "-dmenu", \
21 "-l", str(lines), "-width", str(width), \
22 "-p", "connection"], stdout=PIPE, stdin=PIPE)
23 selected = rofi.communicate("\n" \
24 .join(fdict.keys()) \
25 .encode("utf-8"))[0] \
26 .decode("utf-8") \
27 .strip()
28 rofi.wait()
29
30 r = Popen(["remmina", "-c", fdict[selected]])
31 r.wait()