MarkHedleyJones / dmenu-extended

An extension to dmenu for quickly opening files and folders.
MIT License
390 stars 33 forks source link

Sudo plugin behavior #56

Open ptmcclellan opened 6 years ago

ptmcclellan commented 6 years ago

(running current GIT version under up-to-date Arch linux) While the instructions for using password helper work perfectly, using the Sudo plugin has an error immediately after typing Enter after typing the desired command target for 'sudo', e.g. 1) launch dmenu_extended_run, 2) choose the Sudo plugin, 3) type a program like 'gparted' which requires su 4) result: dmenu window closes.

Launching dmenu_extended_run in a terminal for the above yields:

`Traceback (most recent call last):

File "/usr/bin/dmenu_extended_run", line 7, in dmenu_extended.run(sys.argv) File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 1546, in run plugin_hook[0].run(out[len(plugin_hook[1]):].strip()) File "/home/paul/.config/dmenu-extended/plugins/plugin_sudo.py", line 63, in run dmenu_extended.handle_command(self, item) File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 1509, in handle_command d.execute(out) File "/usr/lib/python3.6/site-packages/dmenu_extended.py", line 649, in execute return subprocess.call(command) File "/usr/lib/python3.6/subprocess.py", line 267, in call with Popen(popenargs, **kwargs) as p: File "/usr/lib/python3.6/subprocess.py", line 707, in init restore_signals, start_new_session) File "/usr/lib/python3.6/subprocess.py", line 1333, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'SUDO_ASKPASS="/home/paul/.config/dmenu-extended/plugins/plugin_sudo.py" sudo -A '`

I don't have a good enough grasp of the py code to understand the cause of the error: the plugin_sudo.py file certainly exists and has +x permissions. Any ideas?

MarkHedleyJones commented 6 years ago

Hi there, Sorry it has taken so long for me to respond. Sudo as a plugin was removed after sudo support was integrated into dmenu_extended. You'll notice it's not listed under https://github.com/markjones112358/dmenu-extended-plugins/blob/master/plugins_index.json so you shouldn't be able to install it using the plug-in manager. Just out of curiosity, how did you install it?

Are you wanting the sudo plugin because it offers an easy way of running items already listed in the menu?

ptmcclellan commented 6 years ago

Hi, thanks for checking in, and thanks for making this tool!

I've had dmenu_extended installed for quite a while, first installation was at least a couple years I think, and through the Arch User Repositories; it came along with the sudo plugin, and in subsequent package upgrades, I think the package-management simply left the plugin in place. The sudo plugin probably stopped working less than a year ago, so not sure if that jives with the timing of the plugin removal from git.

In other words, the sudo plugin was installed with the package when I first set up the system, and was never removed in subsequent updates via package management.

I think for me the elegance of the plugin was to simply condition any subsequent query, as you say, taking advantage of the many fewer keystrokes to launch commands for those commands that need it, e.g., gparted. To me, that use case is more elegant than typing sudo and the command in one line, but then completely losing the autocompletion advantage.

MarkHedleyJones commented 6 years ago

Well, it's great to hear there are people out there making use of it. I agree, it is a shame that the menu disappeared when the plugin was integrated. As this is an open source project, how do you think it would be best to fix this? I'll propose a couple of options, you're free to suggest something else.

  1. Let the user enter sudo and press enter, then re-open the menu with all the items so the user can then use the fuzzy search.
  2. Add an option to the configuration that enables the Sudo -> submenu option in the menu and bring back the behaviour from the plugin.

Both of these options shouldn't affect most users unless they actively seek the feature. Let me know what you think.

-Mark