tobi-wan-kenobi / bumblebee-status

bumblebee-status is a modular, theme-able status line generator for the i3 window manager.
https://bumblebee-status.readthedocs.io/en/main/
MIT License
1.2k stars 229 forks source link

complex commands not executing in shell module #1009

Closed ndroppo closed 4 months ago

ndroppo commented 5 months ago

Bug Report

Description

Affected module: shell Version used: AUR

I have discovered that not all commands can be passed to this module exactly as they work from the terminal. I think this bit from the docs is relevant but both examples (what to do and what not to do) appear to be identical:

shell.command: Command to execute Use single parentheses if evaluating anything inside (sh-style) For example shell.command=’echo $(date +’%H:%M:%S’)’ But NOT shell.command=’echo $(date +’%H:%M:%S’)’ Second one will be evaluated only once at startup

The difficulty appears to crop up when I try to combine commands with a pipe | or $(subshell). When I try to troubleshoot by passing the same command directly in the terminal it runs successfully.

How to reproduce

in ~/.config/bumblebee-status.conf:

shell.command = curl -s https://api.ipify.org returns my IP address in the status bar the same as in the terminal.

shell.command = echo " $(curl -s https://api.ipify.org)" returns  <ip address> in the terminal, but  $(curl -s https://api.ipify.org) in the status bar.

shell.command = curl -s https://api.ipify.org | sed -e 's/^/ /' returns  <ip address> in the terminal, but curl -s https://api.ipify.org | sed -e 's/^/ /' exited with code 6 in the status bar.

shell.command = echo  also returns in the status bar the same as in the terminal so it is not a font issue.

I have tried several variations of the above both in my i3 config bar {} block and in a dedicated bumblebee-status.conf file - with various quoting strategies as well. It appears as though the shell module is simply not capable of handling more than one direct command. Whether this is the case or there is simply a preferred syntax that I have not tried, either way a clarification in the docs would be beneficial.

This is really a very small concern. I absolutely love bumblebee-status and appreciate all of the hard work you put into it. Thanks!

tobi-wan-kenobi commented 5 months ago

Yes, I believe this is a restriction from the Python library I am using - for security reasons.

I will think about how to document that better, though I think it is somerhing of a fringe case.

Thank you very much for your praise, glad you like bumblebee-status!

ndroppo commented 5 months ago

Ah. That makes sense. In that case maybe just a simple note in the docs that complex commands are beyond the scope of the module. Is the bit that is already in there a typo? It looks like the right way and wrong way are identical.

To be thorough, I tried putting my command in a bash script and calling the script from the shell module. It just gave me a perpetual please wait...

Also, in case it matters to anyone all of the above results are with async=True. My entire status line goes away without that, but I think issue #1001 already addressed that so no need to dig into it here.

Do you know of a way that does work to prepend a single character (icon) to the beginning of my output? If not, no worries. I'll just use the command that works until I get the time to play around with making my own modules. And maybe I'll put in a separate feature request for a way to attach a custom icon to any module. I think that would be pretty cool.

The praise is genuine. This project really embodies everything that is great about open-source software. Keep up the great work!

tobi-wan-kenobi commented 5 months ago

Having it as a separate bash script definitely should work, please wait would indicate the bash script does not terminate, maybe? If you show me the bash script and the bumblebee config, I can gladly try it locally and let you know.

For a custom icon, you have 2 options: The simpler one is to just add it to the output of the bash script via echo (from the font you are using, so for example font awesome). Alternately, you can edit the JSON of the theme you are using, there's settings for the prefix to use.

Hope this helps!