Move host-specific additional profiles into .config/ itself
[~bandali/configs] / .local / bin / rofi-remmina
... / ...
CommitLineData
1#!/usr/bin/env python2
2import ConfigParser
3import os
4from subprocess import Popen, PIPE
5
6remmina_dir = os.path.expanduser("~/.local/share/remmina")
7
8fdict = dict()
9
10for 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
17lines = max(min(15, len(fdict)), 1);
18width = len(max(fdict.keys(), key=len))
19rofi = Popen(["rofi", "-i", "-dmenu", \
20 "-l", str(lines), "-width", str(width), \
21 "-p", "connection"], stdout=PIPE, stdin=PIPE)
22selected = rofi.communicate("\n" \
23 .join(fdict.keys()) \
24 .encode("utf-8"))[0] \
25 .decode("utf-8") \
26 .strip()
27rofi.wait()
28
29r = Popen(["remmina", "-c", fdict[selected]])
30r.wait()