Closed halocaridina closed 9 years ago
I'll take a look. First though, have you tried just changing the dmenu_cmd in the config file? Rofi claims to be a drop-in dmenu replacement, so I'd think that would work. On mobile right now, so I can't do anything else at the moment.
Thanks, Scott
Hi Scott,
Thanks for the quick reply. Yes, while advertised as a "drop-in" replacement for dmenu, I had to do some ugly hacks to get it to work-at-all with nmcli-dmenu since just changing the dmenu_command from /usr/bin/dmenu to /usr/bin/rofi lead to nmcli_dmenu failing to launch. So:
1) mv /usr/bin/dmenu /usr/bin/_dmenu 2) ln -s /usr/bin/rofi /usr/bin/dmenu 3) mod ~/.config/networkmanager-dmenu/config.ini (basically hashed out nearly all of my previous dmenu options since many are set for rofi in .Xresources and/or having them parsed from the .ini file lead nmcli_dmenu to fail; only one that parsed correctly was the "lines" option):
[dmenu]
lines = 16
[editor] terminal = urxvtc gui_if_available = True
4) setting the prompt (p) option in config.ini wasn't having an effect, so set that in the /usr/bin/nmcli_dmenu script itself (addition of "NETWORKS:" below):
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_command, "-l", str(num_lines), "-p", str(prompt), "-i"]
else:
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", "NETWORKS:", "-i"] \
+ list(itertools.chain.from_iterable(extras))
Ugly mods, but nmcli_demnu is working at this point.
From my reading of the man, to have rofi behave as a dmenu replacement requires the specific use of the options:
[ -dmenu [ -p prompt ] ]
plus there are subtle differences in other options (i.e., "-l" in dmenu is "-lines" in rofi) between the two.
Thanks again for considering this request as well as the great support.
Cheers,
halocaridina
Ok, give the 'rofi' branch a try. It basically functional, but any theming should be done in Xresources. All you should need to do is copy the slightly revised config.ini to ~/.config/networkmanager-dmenu and edit/uncomment the 'dmenu_command' line to 'rofi' instead of 'dmenu'.
Let me know if that works for you.
Scott
Hi Scott,
Thanks for the fast response to this request. So I installed nmcli_demnu off the "rofi" branch and used the slightly revised config.ini. This is with having the following symlink in place:
ln -s /usr/bin/rofi /usr/bin/dmenu
If the 'dmenu_command' option is COMMENTED OUT in config.ini, then nmcli_dmenu launches correctly via the assigned keybindings.
If the 'dmenu_command' option in config.ini is EXPLICITLY SET to either '/usr/bin/dmenu' or '/usr/bin/rofi', nmcli_dmenu fails to launch via the assigned keybindings and prints the following to the journal:
Dec 15 11:00:20 shockwave lightdm[353]: sorry, cannot understand key combination:
Adding any options to the 'dmenu_command' option like so:
dmenu_command = /usr/bin/rofi -dmenu -p network:
leads to nmcli_dmenu crashing (with the above being either in quotes or not):
Dec 15 10:58:15 shockwave lightdm[353]: FileNotFoundError: [Errno 2] No such file or directory: '"/usr/bin/rofi -dmenu -p network:"'
Dec 15 10:58:15 shockwave lightdm[353]: raise child_exception_type(errno_num, err_msg)
Dec 15 10:58:15 shockwave lightdm[353]: File "/usr/lib/python3.4/subprocess.py", line 1456, in _execute_child
Dec 15 10:58:15 shockwave lightdm[353]: restore_signals, start_new_session)
Dec 15 10:58:15 shockwave lightdm[353]: File "/usr/lib/python3.4/subprocess.py", line 858, in init
Dec 15 10:58:15 shockwave lightdm[353]: stdout=PIPE).communicate(input=inp_bytes)[0].decode()
Dec 15 10:58:15 shockwave lightdm[353]: File "/usr/bin/nmcli_dmenu", line 179, in get_selection
Dec 15 10:58:15 shockwave lightdm[353]: sel = get_selection(ssids, vpns, other)
Dec 15 10:58:15 shockwave lightdm[353]: File "/usr/bin/nmcli_dmenu", line 282, in run
Dec 15 10:58:15 shockwave lightdm[353]: run()
Dec 15 10:58:15 shockwave lightdm[353]: File "/usr/bin/nmcli_dmenu", line 312, in
So the results with the rofi branch are similar to what I was seeing as I was hacking and tweaking the master branch.
Hope this helps and thanks again,
halocaridina
This is with having the following symlink in place:
ln -s /usr/bin/rofi /usr/bin/dmenu
- Is this necessary for some reason? I have rofi installed (for testing) right alongside dmenu at /usr/bin/rofi with no symlink necessary. I'm wondering if this might be the cause of some of your issues. Try removing the symlink...doing things like that is typically not a good practice. Things in /usr/bin/ should ideally be managed by your package manager.
If the 'dmenu_command' option in config.ini is EXPLICITLY SET to either '/usr/bin/dmenu' or '/usr/bin/rofi', nmcli_dmenu fails to launch via the assigned keybindings and prints the following to the journal:
Dec 15 11:00:20 shockwave lightdm[353]: sorry, cannot understand key combination:
- Try running nmcli_dmenu from the command line first for testing (
./nmcli_dmenu
) with the config.ini copied to the correct place in ~/.config. If it launches correctly from there, but doesn't launch with the system keybinding, you may have something in your environment or $PATH messed up.Adding any options to the 'dmenu_command' option like so:
dmenu_command = /usr/bin/rofi -dmenu -p network:
leads to nmcli_dmenu crashing (with the above being either in quotes or not):
- Correct. The dmenu_command option is only looking for the executable. Any additional options will make it crash. Other dmenu options can be added to the config file (as demonstrated in config.ini.example), but not rofi options. The minimum options necessary to run rofi instead of dmenu are included in the script so you don't need to add them.
So, to summarize:
1. Remove the symlink
2. install the config.ini file in ~/.config/networkmanager-dmenu/config.ini
3. First try from the commandline `./nmcli_dmenu` and make sure it launches with dmenu
4. Change the `# dmenu_command = /usr/bin/dmenu` to `dmenu_command = /usr/bin/rofi`
5. Try again from the command line `./nmcli_dmenu`
6. Now if that works, you can start working with whatever system keybindings you have. The script parses ~/.config/networkmanager-dmenu/config.ini, so if the system keybinding doesn't respect ~/ as $HOME, then that will cause problems.
Hi Scott,
Thanks for the breakdown and here are the results.
1) Symlink removed. The reason I went that route is (taken from near the bottom of rofi man page):
Dmenu replacemnt If argv[0](calling command) is dmenu, rofi will start in dmenu mode. This way it can be used as a drop-in replacement for dmenu. just copy or symlink rofi to dmenu in $PATH.
ln -s /usr/bin/dmenu /usr/bin/rofi
Made sense to test it this way (i.e., whether rofi would really emulate dmenu in nmcli_dmenu)).
2) installed (copy/pasted) contents of config.ini.example in the rofi branch to ~/.config/networkmanager-dmenu/config.ini
3) installed (copy/pasted) contents of nmcli_dmenu in the rofi branch to ~/.config/networkmanager-dmenu/nmcli_dmenu & chmod +x nmcli_dmenu
4) default config.ini + ./nmcli_dmenu == successful execution of nmcli_dmenu via dmenu
5) explicitly set 'dmenu_command = /usr/bin/dmenu' (no quotes) in config.ini + ./nmcli_dmenu == successful execution of nmcli_dmenu via dmenu
6) 1st attempt: explicitly set 'dmenu_command = /usr/bin/rofi' (no quotes) in config.ini + ./nmcli_dmenu == script fails to execute via rofi; error message is:
./nmcli_dmenu sorry, cannot understand key combination:
NOTE: I just fixed this key combination error by explicitly setting in .Xresources (all which were empty before):
rofi.key: F12 rofi.rkey: mod1+F2 rofi.skey: mod1+F3
7) 2nd attempt: explicitly set 'dmenu_command = /usr/bin/rofi' (no quotes) in config.ini + ./nmcli_dmenu = script appears to execute but neither does rofi appear on screen nor does prompt return. Ctrl+c produces:
^CTraceback (most recent call last):
File "./nmcli_dmenu", line 312, in
8) opened nmcli_dmenu and noticed dmenu_command is setting "dmenu" (line 33) and "rofi" (line 47) without an absolute path as it is in config.ini.example. So on a hunch:
9) explicitly set 'dmenu_command = rofi' (no quotes) in config.ini + ./nmcli_dmenu = script executes as expected!!
So:
dmenu_command = rofi WORKS dmenu_command = /usr/bin/rofi DOESN'T WORK
although:
which rofi
returns:
/usr/bin/rofi
10) In contrast to the above, setting config.ini in the following way:
dmenu_command = dmenu WORKS dmenu_command = /usr/bin/dmenu WORKS
So the absolute path has been the issue.
Also added to config.ini:
p = network:
doesn't change the prompt for rofi while it does so for dmenu.
Cheers and thanks again,
halocaridina
Sorry for the delay...added some fixes to the 'rofi' branch:
I also tested this with the /usr/bin/dmenu symlink for rofi and it seemed to work fine.
Let me know! Scott
I'm going to go ahead and push this to master. Let me know if any other issues arise with the Rofi support.
hmm never check all the extra options for dmenu when claiming rofi as replacement. (I should) For me it was mostly it parsed the input the same way and produced output.
What exactly is wrong with the prompt support? I thought it was '-p' for dmenu and for rofi. Are there options that cause serious problems because of collision? if so that should be fixed.
I'm sorry, I'm having a tough time figuring out what your questions are! Are you bringing up a new issue related to rofi support? If so, can you please open a new github issue for each problem/bug that you are seeing.
Thanks! Scott
Aah sorry, wasn't clear (yeah humans do not multitask). I am the Rofi developer and was wondering if there are things in Rofi that should be fixed to make it a better drop in replacement.
From this topic it looks like it was more trouble then it should be.
Ah, I see :) The only differences I found were:
Those were the only differences I had to account for, and it was pretty minimal code, so no big deal!
From what I see the only collision is (1)-l
in Rofi it tells what line to (pre) select.
(2.) Rofi is case insensitive by default and passing -i should be silently ignored. (3.) This can be solved by the symlink (and fixed the issue linked above).
I need to see what to do about "-l" as that might break clerk if I change it.
Thanks for the feedback (and sorry for polluting your bug)
@halocaridina would you mind sharing your config.ini
please? I'm having a hard time grasping how things fit together.
I have a working rofi
which I launch with a shortcut, linked to: rofi -modi ssh,run,drun,window -lines 12 -padding 18 -width 60 -location 0 -show drun -sidebar-mode -columns 3 -font "Noto Sans 8"
I installed networkmanager-dmenu-git
on Arch, which is basically this repo. So I now have networkmanager_dmenu
as a new command.
I copied the example config.ini to ~/.config/networkmanager-dmenu/config.ini
but then I am wondering, do I put my entire rofi line like above as dmenu_command
or just rofi
?
I think I got it a bit, this is my config.ini
:
[dmenu]
dmenu_command = rofi -sidebar-mode -font "Noto Sans 8"
modi = ssh,run,drun,window
l = 12
padding = 18
width = 60
location = 0
show = drun
columns = 3
rofi_highlight = True
pinentry = pinentry
# nb = normal background (name, #RGB, or #RRGGBB)
# nf = normal foreground
# sb = selected background
# sf = selected foreground
# b = (just set to empty value and menu will appear at the bottom
# m = number of monitor to display on
# p = Custom Prompt for the networks menu
I am guessing using this does not play wel together with rofi -modi
?
Perhaps @DaveDavenport knows a trick for that?
@CumpsD
Thanks for the questions and a copy of my configuration file can be found at:
Many of the options you are trying can no longer be set in that manner either as flags or in .Xresources. Instead, they have to be set via a rofi config and CSS-type file like:
https://github.com/halocaridina/.dotfiles_thinkpad_X270_crucial/tree/master/rofi/.config/rofi
Hope this helps.
@halocaridina thanks. not sure what you mean about not being able to set those as flags? The command with all flags works perfectly :) or you mean in combination with this repo?
Apologies and should clarify that don't work when using rofi in full screen (or how I'm running it). See first comment at:
@halocaridina thanks to your advice, I moved over to rasi themes :) https://github.com/CumpsD/dotfiles/commit/505ed204b2a24bdd8d1eeae35e18d2e3c2326cba
I'm not using it fullscreen, but I was hoping to have this integrate as some sort of modi
This is how my rofi looks:
Notice at the bottom 4 modes, I was trying to get this in as an extra wifi
mode, but no idea if it's possible even
Hi Scott,
Hope this finds you well. I've been extremely happy using nmcli-dmenu over the last few month. A couple of weeks ago, I switched from dmenu to rofi:
https://davedavenport.github.io/rofi/
for its window switching ability (installed as rofi-git from AUR). Is there the possibility of extending nmcli-dmenu to support rofi?
Thanks in advance,
halocaridina