bevry/dorothy

Login shell restriction

Closed this issue · 6 comments

I'm running into a few issues with having dorothy only apply to login shells. It's easy enough to modify gnome-terminal to use a login shell, as suggested in the README.md. But I've run into two scenarios that aren't as easily handled:

  1. If I run VS code, it doesn't open a terminal as a login shell, and I don't obviously see an option to change it.
  2. My window manager, notion, provides a utility to invoke shell commands. It uses a non-login /bin/sh for this, which seems correct to me since it's not a login shell. I'd like to be able to run my dorothy commands here. In fact, this was part of the appeal of dorothy in the first place for me. I use fish normally, but I'd like to have my personal commands be accessible in all contexts.

What is the rationale for only applying dorothy on login shells? Do you have any suggestions for how to work around this? (I'm wondering if I can sneakily add in a bash -l somewhere during window manager initialization or something like that...)

For vscode:

https://github.com/bevry/dorothy/blob/master/docs/dorothy/dorothy-not-loading.md#visual-studio-code

for why login shells, in the same document:

If Dorothy were to load itself on non-login shells then every shell command would also have to load Dorothy which would be be an unnecessary slow down to every shell command! By having Dorothy only load inside login shells, we allow everything to work perfectly.

this is because even command executions (depending on platform, shell, etc) can also load the rc/profile config files, in which case as Dorothy uses commands instead of functions, this would cause noticeable slow downs for each command invocation.

To support raspberry pi os default terminal not allowing login shells, I do have an explicit exemption for that:

case "${GIO_LAUNCHED_DESKTOP_FILE-}" in *lxterminal*) DOROTHY_LOAD='yes' ;; esac

If necessary for notion, the same could be done. However if Notion does support login shell configuration, that should be done. Or perhaps I can check for an env var like DOROTHY_LOAD_ON_NONLOGIN=yes. Perhaps @molleweide knows a trick for this, as I believe he ran into such for something before.

One option I've been considering is even in non-login shells still exposing the dorothy command, so you can still do dorothy run .... or perhaps even a new dorothy load

In notion, what happens in the bin/sh instance if you then run bash -l or fish -l or whatever?

Sorry for not RTFM :-( I obviously stopped after finding the solution for gnome-terminal, and then forgot there was more!

So, in notion, if I run bash -l -c 'google-chrome-personal blah.com' it works! google-chrome-personal is a dorothy
custom command.

I don't think notion supports login shells, but let me take a quick look at the source code to find where the call happens.

This is what gets called...

https://github.com/raboof/notion/blob/82c48d53791ec0de9ffde8f67de1a1f09caaa27e/mod_query/mod_query.lua#L833

So I could modify that a bit to always add a bash -l -c wrapper and I think it would work. Though auto-completion wouldn't work, which is a bit disappointing.

Let me see if I can just add a bash -l -c in my X session setup, and if everything will basically just propagate downstream.

Cool, that worked! I have auto-completion and everything :-)

I do think it might be easier for new users to have an env. variable instead of spawning a login shell. Or maybe it's just me but it still feels weird.

Anyway, thanks for the help! Time to write some more commands.

For posterity's sake, here's what I did:

edmcman/ansible-notion@6b56482