-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add input arguments to the applications #66
base: master
Are you sure you want to change the base?
Add input arguments to the applications #66
Conversation
…n the correct order, making sure the windows will be moved to the right place when using custom input arguments
Wow! That's a big one. Thank you very much! I'll review it tomorrow. Regarding your concerns:
If it's not used then just delete it.
Yes. Makes sense!
Making changes to the existing behavior is indeed a bit problematic. There are lots of different scenarios (and the whole x11 stuff is used differently by every app) and chances are that we make the app unusable for some people. I much prefer to add this new behavior as an opt in, via a config flag or a command line argument or both than enforcing it on everybody. Would you be ok with that? |
Sure, I think it makes perfect sense to use a flag or command line argument. The new code should work with the previous input, but I think it is a good idea to use a flag, at least until we have it well tested on different systems. |
2dbb08b
to
38056e4
Compare
Hey @johannesjo, |
@RodrigoATorres that's great! Will you also make the adjustments to maintain compatibility? |
I can do that. Right now, the new code is supposed to have backwards compatibility, it should work with previous input files. But I will add a input flag, so if the the flag is not added, it will run exactly the previous code. |
This would be the best solution for now, I think. This way we can sure we don't break anything while also giving people the option to use it. If we don't encounter any issues, we can switch from opt in to opt out later. |
…al code, or with the newly added, that allows adding input parameters to the window applications
Doing more testing I saw that the code is presenting some instabilities. |
No worries :) Take your time! |
I have been using the new version, with the input arguments flag, daily for the past two weeks now. I use always the same input, but it opens different software (like Vscode, chrome, firefox, nautilus) in 3 workspaces. Most of the time it works as expected. When I run lwsm right after I login, sometimes it won't open some windows or won't move it to the second or third workspace. If I wait something like 10 or 20 seconds this problem won't happen. I tried the previous code on the same conditions and it seems to have the same behavior. I am not sure what causes that. |
Thank you! I'll try to review this tomorrow! |
src/index.ts
Outdated
@@ -461,12 +471,141 @@ async function _startSessionPrograms( | |||
}) | |||
.map(win => { | |||
win.instancesStarted += 1; | |||
return startProgram(win.executableFile, win.desktopFilePath); | |||
return startProgram( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken this would lead toisAllowInputArgs
being false to have no effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long to answer,
The code would start the programs with arguments, in case there were input arguments in the json file, if the isAllowInputArgs
was set to false.
The effect isAllowInputArgs
being set to false would be running _startSessionPrograms
instead of _startAndWaitPrograms
.
I believe I did that way because the input arguments themselves were not a big change on the code, that could lead to instabilities (like _startAndWaitPrograms
).
But, now that you said, I agree that makes much more sense to remove them. I will just pass a empty string as an argument then, so the code will behave exactly as before.
src/index.ts
Outdated
// Get the windowIds of all Ids that were previously opened in order to | ||
// avoid these windows from being used isntead of the newly created windows | ||
// (necessary for windows with custom input arguments) | ||
var activeWindows = await getActiveWindowListFlow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer using 'letor
const`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, will change them.
Just saw this implemented. What's the right way to invoke this behavior so that when my session is restored proper arguments will be passed along? For example, I have quite a few Okular instances open. When I restore my session, ideally the current open PDF's will be opened automatically. Thanks. |
This PR does not generate the input arguments automatically, you have to do it manually editing the json files.
Following are samples of how the json should look for Google-chrome and Vscode.
|
sorry if i would like to help test, how am I supposed to install the feature branch from RodrigoATorres's repository? I assume it's not pushed to npm source given it's not merged yet? Thanks. |
@chensun-hep you should be able to do the following:
Not sure if the fork is up to date, but it should at least contain the state visible here. |
I have just updated the code with the changes you requested. |
Thanks. I'll try to review this, this weekend again. |
Sorry. I had a very busy weekend. I will try to do this on the next one. Sorry for the delay :-/ |
Sorry! I totally forgot about this one! I'll try to have another look tomorrow. |
Problem:
I felt that would be nice to have the possibility to have my browser, file explorer or VScode to open with the tabs I want, or in the folder I want, when restoring a session.
Saving that information automatically when saving a session looked like a hard tasks, and even harder to make it generic for all applications (maybe impossible).
Solution:
The workaround I found for these would be to enable user to manually put arguments on the json files to be passed as input arguments when starting the applications. Adding this functionality itself was not a problem, but an other issue came up:
When the session has more than one instance of the same application, it was impossible to tell which window of the application was opened with which input arguments (I could not find a way, at least).
To overcome that, bigger changes had to be done on the code. I created a function "_startAndWaitPrograms" that would, in case there were instances of the same applications with different input arguments, wait for the window of each instance of the application to open, before starting the other one. The new code is commented, in order to explain exactly how it is done.
How to use:
I tested the code with different applications,. To make use of the new functionality the field "executableArgs" has to be added to the json file.
For google chrome you can add:
"executableArgs": "--new-window gmail.com google.com"
For firefox:
"executableArgs": "--new-window gmail.com"
or (if you want to open more than one tab):
"executableArgs": " gmail.com google.com"
For nautilus:
"executableArgs": "/home/rodrigo/Desktop"
For Vscode:
"executableArgs": "/home/rodrigo/Desktop"
Concerns regarding the code:
Best regards,