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

Terminal has weird name on NixOS with home-manager #272

Open
yavko opened this issue Jan 23, 2023 · 12 comments · May be fixed by Macchina-CLI/libmacchina#130
Open

Terminal has weird name on NixOS with home-manager #272

yavko opened this issue Jan 23, 2023 · 12 comments · May be fixed by Macchina-CLI/libmacchina#130

Comments

@yavko
Copy link

yavko commented Jan 23, 2023

Describe the bug
On NixOS under home-manager the terminal app name starts with a . and ends with -wrapped,
I know this is because home-manager creates a kitty script which then calls an executable with the name .kitty-wrapped as seen below ↓
image
My proposal is to try parsing the $TERM or $TERMINFO environment variables if possible

To Reproduce
Steps to reproduce the behavior:

  1. Run macchina
  2. Look at result

Expected behavior
Terminal appears as kitty

Screenshots
image

System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.

  • Distribution: NixOS
  • Desktop Environment: Hyprland
  • Operating System: Linux 5.15.79
  • Terminal: kitty
  • Macchina's version: 6.1.8
@grtcdr
Copy link
Member

grtcdr commented Jan 23, 2023

The current implementation parses /proc to determine the most likely
terminal, but it does so through the /proc/PID/comm file which we
have no way of saniziting.

$TERM has proven to be unreliable at detecting the real terminal
being used (anyone can for example set the variable to xterm and
that would then be reflected in macchina).

$TERMINFO is new to me, I've never had to directly interact with it.

I believe we're better off returning the relevant terminfo description
directly.

@yavko
Copy link
Author

yavko commented Jan 23, 2023

The current implementation parses /proc to determine the most likely terminal, but it does so through the /proc/PID/comm file which we have no way of saniziting.

Ah makes sense

$TERM has proven to be unreliable at detecting the real terminal being used (anyone can for example set the variable to xterm and that would then be reflected in macchina).

Thats true, I have seen that done a lot

$TERMINFO is new to me, I've never had to directly interact with it.

I believe we're better off returning the relevant terminfo description directly.

Yeah, I agree, idk if this helps but I found a crate that could aid in this https://crates.io/crates/terminfo

@grtcdr
Copy link
Member

grtcdr commented Jan 23, 2023

Yeah, I agree, idk if this helps but I found a crate that could aid in this https://crates.io/crates/terminfo

Yeah it looks like it will, I was never really a fan of our little procfs hack.

@yavko
Copy link
Author

yavko commented Jan 23, 2023

Yeah, I agree, idk if this helps but I found a crate that could aid in this crates.io/crates/terminfo

Yeah it looks like it will, I was never really a fan of our little procfs hack.

Oh yeah definitely seems pretty hacky

@yavko
Copy link
Author

yavko commented Jan 24, 2023

@grtcdr If you'd like I can write up something with this, just wanna know in case someone has already started on this.

@grtcdr
Copy link
Member

grtcdr commented Jan 24, 2023

Absolutely, go ahead!

I await the improvements your pull request will bring :)

@yavko
Copy link
Author

yavko commented Jan 24, 2023

Absolutely, go ahead!

I await the improvements your pull request will bring :)

After implementing terminfo, it seem futile, same issue as with $TERM

with terminfo name:
image

with description:
image

@yavko
Copy link
Author

yavko commented Jan 24, 2023

I found this result on stackoverflow that uses ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) to get the term name, which results in something like this
image
could the path then be stripped to only get exec name, as this method seems to use the exact exec name

@grtcdr
Copy link
Member

grtcdr commented Jan 24, 2023

You'll have to manually traverse /proc and compare the values of /proc/<TERMPID>/comm and /proc/<TERMPID>/cmdline.

cmdline should hopefully show you an output like the one returned by the ps command you mentioned.

If it does, and you think the output of cmdline is more consistent, I'd be happy to include the change.

@yavko
Copy link
Author

yavko commented Jan 24, 2023

Okay, so it sorta works. I mean it does, but when its in a nix-shell it says rc, which happens to be the exec name of nix shells. I'm quite sad, because I kept getting rc, and was very confused until i just ran ps, and it also said rc
image
image

I'll make the pr now

@yavko
Copy link
Author

yavko commented Jan 24, 2023

I've made a PR now! Macchina-CLI/libmacchina#130

@grtcdr
Copy link
Member

grtcdr commented Jan 27, 2023

Thank you, I'll review it as soon as possible :)

@grtcdr grtcdr changed the title [BUG] Terminal has weird name on NixOS with home-manager Terminal has weird name on NixOS with home-manager May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants