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