Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Rofi custom modes #60

Open
jluttine opened this issue Oct 4, 2019 · 4 comments
Open

Support for Rofi custom modes #60

jluttine opened this issue Oct 4, 2019 · 4 comments

Comments

@jluttine
Copy link

jluttine commented Oct 4, 2019

Would it be possible to support rofi's custom modes? In rofi man page it says:

Custom modes can be added using the internal 'script' mode. Each mode has two parameters:

    <name>:<script>

Example: Have a mode 'Workspaces' using the i3_switch_workspaces.sh script:

    rofi -modi "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces

So I tried the following:

rofi -modi NetworkManager:`which networkmanager_dmenu` -show NetworkManager

But rofi is entirely empty. So this doesn't seem to work. networkmanager-dmenu only works if I run it as a stand-alone script by itself. But then I cannot combine it with other modes. Would it be possible to add support for this? Then, networkmanager-dmenu could be used as one mode alongside with other modes. For instance, as:

rofi -modi run,ssh,NetworkManager:`which networkmanager_dmenu` -show run
@firecat53
Copy link
Owner

Someone asked a similar question for my keepmenu project. These two projects are similar and would require some significant restructuring to make them work as a rofi modes or user scripts. PRs are welcome, and I'll leave this issue open in the event I get a chance to try and do the necessary rewrite.

@TRSx80
Copy link

TRSx80 commented Sep 27, 2020

Hi firecat53,

Nice project, thanks for sharing your work. 🍻

I got as far as parsing the output of nmcli using grep and awk to spit out a list of VPN connections that would be suitable as input into rofi as a modi.

Then I took one more look around before diving down the rabbit hole the rest of the way, and that's when I found this project (and this issue). 😄

would require some significant restructuring to make them work as a rofi modes or user scripts

It sounds like you may already be aware how this works, but in case not (and for benefit of OP, and anyone else coming along later) I will briefly explain how modi work in rofi. They call the target script, which, with no arguments should return a plain newline separated list. These are your candidates for completion in rofi. When you select one of them, rofi calls the target script again with the selected candidate as an argument. Therefore, in order for a script to work as a modi, it needs to support this way of I/O.

I have taken the time to figure out how this works, and so far added a couple modi to my regular window finder and launcher in rofi. It's very handy to be able to switch left and right into other modes. It turns rofi into an almost universal sort of interface, I'm really liking it so far, hence looking to add more things to that interface now.

Anyway, I just started looking at the code in this project, not sure yet exactly how it works or how difficult it would be to get that kind of I/O to/from it, but OTOH I am not sure either how going my simpler command line route is going to work out, either. I am starting to get some sort of vague anxiety about perhaps running into some sort of wall with permissions, as any networking stuff might need to run as sudo, etc... And you have this all figured out already in this package.

In either case, if I come up with something, I will report back. Any thoughts in the meantime are also appreciated.

EDIT: I just finished reading the linked (keepmenu) issue. So it does sound like you are aware how it works. I guess I leave this info here for anyone coming along later. Not sure which way I will go at this point. BTW you are a very nice guy, helping someone out with support for something that I think was even outside the scope of your own software.

Cheers! 🍻

@firecat53
Copy link
Owner

Thanks for the kind words. I did spend some time awhile ago trying to make it work but quickly realized that the script architecture doesn't mesh at all with the modi paradigm. Someone else also tried briefly before coming to the same conclusion. I want to keep the dmenu compatibility as well, so at this point I probably won't put any more time into making this into a modi script unless I get really really bored 😄

@TRSx80
Copy link

TRSx80 commented Sep 27, 2020

Fair enough. I think I am getting close with my bash script, which really is essentially only a VPN switcher. Personally I don't need any more than that (but you know how that goes, lol). Your package seems to have a lot more functionality.

One thing that I forgot to mention, there are some new features in rofi that were just released a couple weeks ago, having to do with adding more functionality for scripts. Previously it was very limited (as you found out). If you needed to pass state for example, you had to use a temp file or something like that (I did in one of my other scripts). Anyway, just FYI (maybe for other things in future) I wanted to mention it because it's pretty new.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants