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

[Feature Request] Command Line Argument to Toggle Flow Launcher (in same way as Alt-Space) #2586

Closed
EnigmaSolved opened this issue Feb 24, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@EnigmaSolved
Copy link

It might be nifty if there could be a command line argument that would toggle the display of Flow Launcher, in the same way that the hotkey (ie, Alt-Space) toggles Flow. Currently, calling Flow.Launcher.exe correctly displays Flow Launcher (as opposed to launching a new instance), but there is no way (that I know of!) via the .exe to then hide Flow Launcher again in the way that executing the hotkey Alt-Space will hide Flow Launcher.

Granted, in most cases using the hotkey combo is going to be easiest and best, but there are some circumstances in which there can be a desire to toggle Flow from something other than a hotkey. One example is the recent exploration of using the Win key to toggle Flow, which, last I checked, is internally calling Alt-Space in order to toggle Flow Launcher:

I do not know for certain, but it seems possible to me that it would be cleaner, more direct, perhaps faster(?) if things like the above could directly toggle Flow instead of the user executing a hotkey (ie, Win) which then programmatically executes the true hotkey (ie, Alt-Space). Additionally, sometimes there can be funky issues with programmatic execution of hotkeys where you end up with stuck hotkeys (eg, the computer things Shift, Alt, etc are still held down), and a more direct interface for programmatically toggling Flow would avoid this possibility.

In my particular case, I am making use of HotFrameFx, which has support for some hotkey combos, but not all (currently). I have worked around that limitation by having HotFrameFx execute a simple AutoIt script which in turn executes the Alt-Space hotkey. But if there were (or is) a argument I could pass to the Flow .exe (eg, Flow.Launcher.exe -toggle) so that it would always toggle the Flow state that would certainly be more efficient in my particular case.

Just some things to consider! I know there are so many ideas to implement, so I do not expect this to be high need/priority. But thought it was worth putting out here. And if there is already an argument I can pass to the .exe to toggle Flow that would be awesome to know! :)

@EnigmaSolved EnigmaSolved added the enhancement New feature or request label Feb 24, 2024
@taooceros
Copy link
Member

interesting! Do you want to file a pr? I can show you where might be the starting point! I don't think we have a good command line argument so maybe that can also be added.

@EnigmaSolved
Copy link
Author

interesting! Do you want to file a pr? I can show you where might be the starting point! I don't think we have a good command line argument so maybe that can also be added.

In theory/principle I would love to contribute a PR -- whether I can realistically follow through on that right now time-wise is another story. 😆 But yes, I would be happy to be directed to a starting point in the code and at least my brain can be percolating on it (and any other interested parties will then also have the same starting point to work with as well, in the event someone else is able to get to it before me). :)

@taooceros
Copy link
Member

The startup code starts at this line

private async void OnStartupAsync(object sender, StartupEventArgs e)

and the code handling opening an existing process is here

void OnSecondAppStarted();

public void OnSecondAppStarted()
and probably some code here might be interesting
private static async Task CreateRemoteService(string channelName)
{
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(channelName, PipeDirection.In))
{
while(true)
{
// Wait for connection to the pipe
await pipeServer.WaitForConnectionAsync();
if (Application.Current != null)
{
// Do an asynchronous call to ActivateFirstInstance function
Application.Current.Dispatcher.Invoke(ActivateFirstInstance);
}
// Disconect client
pipeServer.Disconnect();
}
}
}

@EnigmaSolved
Copy link
Author

Looking through that helpful list I would add the following two:

mainViewModel.ToggleFlowLauncher();

public void ToggleFlowLauncher()

It seems to me that ToggleFlowLauncher() is what we'd be wanting to invoke.

Actually, it occurs to me that the current behavior is that when Flow.Launcher.exe is executed the first time (ie, not already loaded) the Flow dialog is not displayed -- it is only on a second execution of Flow.Launcher.exe that the dialog is displayed. So in theory, we could just replace the code that is executed on a second Flow.Launcher.exe execution with a call to ToggleFlowLauncher() and then we do not need a command line at all -- any clicking/executing of the Flow.Launcher.exe after it is already running will then automatically toggle it, which seems to me the intuitive result anyway. :)

So I think it might be as simple as replacing _mainVM.Show(); with _mainVM.ToggleFlowLauncher(); on the following line:

_mainVM.Show();

I sadly do not have an environment setup to build and test this, but let me know what you think -- this might be a very simple addition! :)

@taooceros
Copy link
Member

taooceros commented Feb 26, 2024

If you want to change the current behavior we may need extra discussion, in which I personally are not sure about it @Flow-Launcher/team.

If you want to extend some command line argument then you can manipulate the message sent through the pipe and parse it accordingly to determine which action should be acted.

@AminSallah
Copy link
Contributor

AminSallah commented Feb 26, 2024

Hey there, I noticed that Flow can handle launching a new process while an existing process is running. This means you can initiate a new process to trigger Flow if it's already running, using %localappdata%\FlowLauncher\Flow.Launcher.exe

@EnigmaSolved
Copy link
Author

If you want to change the current behavior we may need extra discussion, in which I personally are not sure about it @Flow-Launcher/team.

If you want to extend some command line argument then you can manipulate the message sent through the pipe and parse it accordingly to determine which action should be acted.

Hmm, I am reticent to take up mental energy from the Flow Launcher team on something like this that is rather low priority (ie, potentially nice to have, but not necessary). I've also been doing some more thinking and experimenting (in part in response to a side conversation with @AminSallah ), and while I still think it could be a nifty little change (with potentially no downsides), it is probably not going to be as effective for my purposes (and definitely not needed for the Win key plugin) as I was originally thinking. At the moment I could be fine with letting this sit for a bit and/or perhaps closing it for now.

Hey there, I noticed that Flow can handle launching a new process while an existing process is running. This means you can initiate a new process to trigger Flow if it's already running, using %localappdata%\FlowLauncher\Flow.Launcher.exe

Yes, thanks @AminSallah ! That is what I was playing with conceptually, is how to change that from just launching to also being able to toggle. :)

@jjw24
Copy link
Member

jjw24 commented Mar 8, 2024

Thanks for the suggestion @EnigmaSolved, sounds like you got the answer/feedback from @AminSallah already, I will close this issue. Feel free to reopen at any point if you want to further the discussion.

@jjw24 jjw24 closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants