Skip to content
New issue

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

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

Already on GitHub? # to your account

Shutdown and reboot keyboard shortcuts #118

Closed
fgallaire opened this issue Jul 20, 2024 · 8 comments
Closed

Shutdown and reboot keyboard shortcuts #118

fgallaire opened this issue Jul 20, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@fgallaire
Copy link

Could it be possible to add shutdown and reboot keyboard shortcuts (for example ly uses F1 shutdown and F2 reboot) ?
I know it will not be so empt(t)y, but very useful !

@tvrzna
Copy link
Owner

tvrzna commented Jul 22, 2024

I was thinking about it whole weekend. In past I was against it without thinking, but this time I looked into it. The problem is, that emptty is not TUI, but CLI, so there is no layer for reading inputs in Raw/Cbreak mode. And it looks like quite hard task for "just" catching shortcuts (without external library), that could brings also issues to the current behaviour.

But maybe I was looking on wrong type of solution.

@fgallaire
Copy link
Author

Thanks for the time you took to think about it.
I really like how you work.

@noboruma
Copy link

What about adding a command mode like vim is doing:
:shutdown or :reboot
Username can only contain letters and digits, so if you type : from the username input, we could catch it and perform a different behavior?

@tvrzna
Copy link
Owner

tvrzna commented Jul 24, 2024

That's an excellent idea!

@tvrzna tvrzna self-assigned this Jul 24, 2024
@tvrzna tvrzna added the enhancement New feature or request label Jul 24, 2024
@tvrzna tvrzna closed this as completed in 0ab55fd Jul 24, 2024
tvrzna added a commit that referenced this issue Jul 24, 2024
@tvrzna
Copy link
Owner

tvrzna commented Jul 24, 2024

It's implemented now, I think this feature with proposed handling deserves to be enabled by default. More in readme.

@fgallaire
Copy link
Author

Nice, but you're too fast, needs to think about it more !

@fgallaire
Copy link
Author

What is really nice is the easy integration with the global CLI emptty design.

What needs more thinking:

  1. Commands are nice, but not shortcuts, i.e. they are long. Could we have a short version (:r, :p, :s) ?
  2. Should we have text printed with a reminder of the commands in the "UI" (when allow_commands is set to true) ?
  3. As commands are a generic concept, should it be limited to shutdown/reboot or possibly configurable with any command we could need ?

@tvrzna
Copy link
Owner

tvrzna commented Jul 24, 2024

Yes, the "hardest" part was to take it out of the authorization part.

  1. I was thinking about shorter variants too, but I'm affraid it's too easy to make an error. And I think that confirmation [y/N] would be annoying.
  2. It depends on what would be proposed. However since it's enabled by default, maybe the opposite situation needs to be reminded.
  3. It could be little bit dangerous, those commands are run by root itself. But yes, that's the user's responsibility.

@tvrzna tvrzna reopened this Jul 24, 2024
tvrzna added a commit that referenced this issue Aug 8, 2024
tvrzna added a commit that referenced this issue Aug 8, 2024
@tvrzna tvrzna closed this as completed Aug 15, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants