magic-wormhole / magic-wormhole.rs

Rust implementation of Magic Wormhole, with new features and enhancements
European Union Public License 1.2
722 stars 78 forks source link

Clipboard support #123

Closed piegamesde closed 2 years ago

piegamesde commented 3 years ago

It would be cool if the send command automatically copied the the code to the clipboard.

nsmlzl commented 3 years ago

The CLI is supposed to run under Windows, macOS and Linux (X11 and Wayland), or? Any other platforms to consider? Could we just use the rust-clipboard crate? I did a quick test under X11 and Wayland; it seemed to work fine there.

Should the command be automatically copied? Or should we add a command line argument? E.g. pass has a --clip argument.

Should we inform the user about the new data in the clipboard? Might be informative for new users, but would also add clutter to the output.

piegamesde commented 3 years ago

I'd like to consider as many platforms as possible, of those where the application already runs. rust-clipboard looks fine, but it does not seem to have native Wayland support. This shouldn't be a problem as long as XWayland is a common thing, but we may want to look into this in the future.

Should the command be automatically copied? Or should we add a command line argument? E.g. pass has a --clip argument.

That's a hard question. I asked a few people, and not all were enthusiastic about writing stuff to the clipboard. So if we make it a flag, should it be opt-in or opt-out? I fear that independently of that decision, half of the users will be unhappy about this. Maybe the best thing is to make this a persistent configuration option?

An alternative that I thought of would be "press some shortcut to copy the code to the clipboard". But I can't think of any good shortcuts that aren't captured by terminal emulators, so what do you think about "press enter to copy the code to the clipboard"?

Should we inform the user about the new data in the clipboard?

Yes, absolutely, unless the action was explicitly requested by the user in the first place. I don't think that it would be cluttering the output.

corbinu commented 3 years ago

I would make it off by default but maybe print a message informing people they can use it.

nsmlzl commented 3 years ago

Is somebody already working on this issue? Or could I have a shot at it?

I was thinking about adding a --clip argument and also do a check for an environment variable (users could just add it to their bashrc to do a permanent configuration). Or does wormhole have its own configuration file?

An alternative that I thought of would be "press some shortcut to copy the code to the clipboard". But I can't think of any good shortcuts that aren't captured by terminal emulators, so what do you think about "press enter to copy the code to the clipboard"?

I was thinking about adding a dialogue asking if the string should be copied (similar to the dialogue during receive). However, in this case I think we would need a second thread, because we are at the same time waiting for the connection to the receiver. I don't know if the added complexity would be worth it? Or did I miss something?

piegamesde commented 3 years ago

Is somebody already working on this issue? Or could I have a shot at it?

Great, I'll assign you.

Or does wormhole have its own configuration file?

No, not yet. I'm trying to push this back for as long as possible, but I'm confident we'll have to add one some day, sooner or later. You can be the person adding one if you want to. You can also do CLI flags or environment variables or whatever you like most, I'm fine with it and it can always be changed later on.

However, in this case I think we would need a second thread, because we are at the same time waiting for the connection to the receiver.

We are using an async frameworks, so concurrent tasks are not a problem.

piegamesde commented 3 years ago

I propose the following implementation to get things started:

rpls commented 2 years ago

I was just hoping for a feature like this, so I found this issue. My idea would be to have an environment variable / cmdline flag that specifies a command to which the send command / codeword is piped. This way it's completely independent of X11/Wayland clipboard, and the user could specify one, e.g., xclip. Furthermore, this would enable more scripting if desired.

nsmlzl commented 2 years ago

sounds like an interesting solution as well. Unfortunately, I am currently a bit busy; if somebody else would like to have a shot at this issue, feel free to pursue it!

piegamesde commented 2 years ago

Generally, I really like the idea of passing commands to run via the command line for some things, but:

rpls commented 2 years ago

I gave it a first shot in #134!

piegamesde commented 2 years ago

@nsmlzl I see that you've made a few commits on your fork. Would you mind publishing them as a draft PR in the meantime?

rpls commented 2 years ago

134 is a draft PR