Skip to content

Commit

Permalink
Added dmenu_command option to config.ini to change default dmenu exec…
Browse files Browse the repository at this point in the history
…utable
  • Loading branch information
firecat53 committed Aug 30, 2014
1 parent 721ed7b commit cd25ad6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Installation
- If using networkmanager < version 0.9.10 you _must_ checkout the 'networkmanager-0.9.8' branch. Some of the nmcli terminology changed with 0.9.10 and is _not_ compatible with previous versions.
- To customize dmenu appearance, copy config.ini.example to ~/.config/networkmanager-dmenu/config.ini and edit.
- Set default terminal (xterm, urxvtc, etc.) command in config.ini if desired.
- Set your dmenu_command in config.ini if it's not 'dmenu' (for example dmenu_run or dmenu2). The alternate command should still respect the -l, -p and -i flags.
- Copy script somewhere in $PATH
- If desired, copy the nmcli_dmenu.desktop to /usr/share/applications or ~/.local/share/applications.
- If you want to run the script as $USER instead of ROOT, set `PolicyKit permissions`_. The script is usable for connecting to pre-existing connections without setting these, but you won't be able to enable/disable networking or add new connections.
Expand Down
1 change: 1 addition & 0 deletions config.ini.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# [dmenu]
# dmenu_command = /usr/bin/dmenu
# fn = font string
# nb = normal background (name, #RGB, or #RRGGBB)
# nf = normal foreground
Expand Down
13 changes: 9 additions & 4 deletions nmcli_dmenu
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ def dmenu_cmd(num_lines, prompt):
dmenu -l <num_lines> -p <prompt> -i ...
"""
dmenu = ["dmenu", "-l", str(num_lines), "-p", str(prompt), "-i"]
dmenu_command = "dmenu"
conf = configparser.ConfigParser()
conf.read(expanduser("~/.config/networkmanager-dmenu/config.ini"))
try:
args = conf.items('dmenu')
except configparser.NoSectionError:
conf = False
if not conf:
return dmenu
return [dmenu_command, "-l", str(num_lines), "-p", str(prompt), "-i"]
else:
extras = (["-" + str(k), str(v)] for (k, v) in args)
return dmenu + list(itertools.chain.from_iterable(extras))
args_dict = dict(args)
if "dmenu_command" in args_dict:
dmenu_command = args_dict["dmenu_command"]
del args_dict["dmenu_command"]
extras = (["-" + str(k), str(v)] for (k, v) in args_dict.items())
return [dmenu_command, "-l", str(num_lines), "-p", str(prompt), "-i"] \
+ list(itertools.chain.from_iterable(extras))


def current_conns():
Expand Down

0 comments on commit cd25ad6

Please sign in to comment.