Skip to content

Comments

Fix TERM when launched with agetty#160

Merged
kdj0c merged 2 commits intokmscon:mainfrom
kdj0c:fix_term
Dec 5, 2025
Merged

Fix TERM when launched with agetty#160
kdj0c merged 2 commits intokmscon:mainfrom
kdj0c:fix_term

Conversation

@kdj0c
Copy link
Contributor

@kdj0c kdj0c commented Dec 3, 2025

Add a --append-term option, so that agetty will set $TERM to the right value.

Fixes: Aetf#168

@michael-oberpriller
Copy link
Contributor

Why not just change the service files to ExecStart=@bindir@/kmscon --login -- /sbin/agetty -o '-p -- \\u' --noclear -- - $TERM? I don't see why adding a new option to kmscon makes sense here.

@michael-oberpriller
Copy link
Contributor

Sorry I don't think my solution works with how kmscon executes. This solution still seems like it only applies to agetty. Maybe it would be better to use a keyword that automatically gets substituted. The logic for this is in Aetf#124.

@kdj0c
Copy link
Contributor Author

kdj0c commented Dec 3, 2025

$TERM is interpreted by systemd, and the default is "linux" when I test it.
If you escape it with $$TERM, kmscon won't interpret it and will start agetty with '$TERM'.
so now you have

echo $TERM

$TERM

You can also add xterm-256color in systemd service, but then people have to modify the service script, and I find it better to be able to change that in /etc/kmscon/kmscon.conf

@michael-oberpriller
Copy link
Contributor

michael-oberpriller commented Dec 3, 2025

From a quick look it seems we could use a DCS sequence to inform systemd of which terminal type is being used (systemd/systemd#37538). But we probably still need a solution for all inits.

@michael-oberpriller
Copy link
Contributor

michael-oberpriller commented Dec 3, 2025

If you escape it with $$TERM, kmscon won't interpret it and will start agetty with '$TERM'.

I think this is because execve doesn't substitute environment variables. This could be fixed by always executing the command as sh -c 'command', but I am not sure if this causes any issues.
I think a better solution would be to implement the substitution in kmscon in the same way shells do.

Jocelyn Falempe added 2 commits December 4, 2025 00:10
That way, you can specify the right TERM value for agetty
using $$TERM in the systemd unit file.

Signed-off-by: Jocelyn Falempe <[email protected]>
Otherwise agetty will overwrite TERM with vt102

Signed-off-by: Jocelyn Falempe <[email protected]>
@kdj0c
Copy link
Contributor Author

kdj0c commented Dec 3, 2025

I think a better solution would be to implement the substitution in kmscon in the same way shells do.

Agreed, done in my latest push.

@kdj0c kdj0c merged commit bbd427c into kmscon:main Dec 5, 2025
1 check passed
@kdj0c kdj0c mentioned this pull request Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

term defaults to vt102 instead of xterm-256color

2 participants