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

Messy output when using reboot/shutdown #126

Closed
techtruth opened this issue Mar 20, 2024 · 8 comments · Fixed by #135
Closed

Messy output when using reboot/shutdown #126

techtruth opened this issue Mar 20, 2024 · 8 comments · Fixed by #135
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@techtruth
Copy link

The system (in my case OpenRC) prints to stdout when the runlevel changes. This is normally very good.

I believe tuigreet is somehow holding onto the cursor position and the screen contents, forcing what character position stdout gets shown from.

I think this because the stdout messages get written to the spot where the username/password input is at on tuigreet. This indicates to me that the tuigreet is 'grabbing' the text input position, and as stdout prints, it prints from where tuigreet says is the position.

This is different than other issues #68 because this is shutdown, not startup. While I could set the system not to log these to stdout, I'd rather see them and have them land properly with tuigreet.

One solution I could think of would be to clear the screen, and stop the 'render loop' of tuigreet whenever the reboot or shutdown commands are invoked. This would let the terminal start in the top left character and not be disturbed from tuigreet setting the prompt for username/password.

This solution wont work for the startup flavor of this issue. This is only for shutting down.

As a note, if i run the shutdown from within wayland, it works as expected showing the last output and "skipping" the tuigreet.
This is only an issue when i shutdown/reboot before logging in, OR if i exit wayland to see tuigreet and then shutdown/reboot.

Here is an image of the behavior I'd like to resolve:
badlog

@techtruth
Copy link
Author

It might be the case that you can stop the running set/get loop when the code reaches https://github.com/apognu/tuigreet/blob/master/src/power.rs#L18 -- This may stop the rendering, but let stdout still print from a different process.

@techtruth
Copy link
Author

Or maybe a cleaner approach would be to do it when the main module receives the power event https://github.com/apognu/tuigreet/blob/master/src/main.rs#L93

@techtruth
Copy link
Author

techtruth commented Mar 20, 2024

Some progress, it looks like clearing is not enough, as it still retains its cursor position.

This patch does clear all the visual elements off the screen as intended, but still need to look at resetting the position of the cursor. ... This should also call clear only once, but used it twice when experimenting.

index c26877d..5d0ab7d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -79,7 +79,9 @@ async fn run() -> Result<(), Box<dyn Error>> {
         let command = greeter.write().await.power_command.take();
 
         if let Some(command) = command {
+          clear_screen(); // Call clear_screen after receiving the power command event
           power::run(&greeter, command).await;
+          clear_screen(); // Call clear_screen after receiving the power command event
         }
       }
     }

@apognu apognu self-assigned this Apr 23, 2024
@apognu apognu added the enhancement New feature or request label Apr 23, 2024
@apognu apognu added this to the 0.9.0 milestone Apr 23, 2024
@apognu
Copy link
Owner

apognu commented Apr 23, 2024

We probably need to exit raw mode before clearing the screen. I'll look into it if I can reproduce.

@techtruth
Copy link
Author

techtruth commented Apr 23, 2024

I'll look into it if I can reproduce.

I should have included... I reach this state when I set tuigreet to use the openrc-shutdown -p now command in its command line arguments. Tuigreet is launched by greetd. I'm assuming it's similar behavior to most other shutdown commands.

@apognu
Copy link
Owner

apognu commented Apr 24, 2024

Are you able to build the binary out of the dev/clear-screen-on-power branch and tell if it improves your experience?

@techtruth
Copy link
Author

This seems to have resolved the issue! Thank you!

I did notice however that the password input is now on a line lower than it should be.
image

@apognu
Copy link
Owner

apognu commented May 1, 2024

Yeah this was reported in #130 and fixed on the main branch. It should not be present once merged.

@apognu apognu linked a pull request May 1, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants