dnkl/foot
41
2.0k
Fork
You've already forked foot
243

builtin terminfo: add custom 'query-os-name' #2217

Manually merged
dnkl merged 1 commit from terminfo-query-os-name into master 2025年12月20日 16:00:16 +01:00
Owner
Copy link

Inspired by Kitty's kitty-query-os_name

$ ./utils/xtgettcap query-os-name
reply: (44 chars): <ESC>P1+r71756572792d6f732d6e616d65=4C696E7578<ESC>\
 query-os-name=Linux

Closes #2209

Inspired by Kitty's `kitty-query-os_name` $ ./utils/xtgettcap query-os-name reply: (44 chars): <ESC>P1+r71756572792d6f732d6e616d65=4C696E7578<ESC>\ query-os-name=Linux Closes #2209
@ -186,3 +187,4 @@
entry.add_capability(StringCapability('name', target_entry_name))
entry.add_capability(IntCapability('RGB', 8)) # 8 bits per channel
entry.add_capability(StringCapability('query-os_name', platform.system().lower()))
First-time contributor
Copy link

Nice. We should probably make sure that terminals agree on the values for query-os_name.

I'd naively expect os.uname().sysname which is what uname prints,
so it should be a low common denominator (not specific to Python).
If we do that, we could call it query-uname which makes the semantics more obvious (and doesn't mix "-" and "_").

I'm not sure what are the downsides (compared to the kitty approach), maybe that the possible values are not known at compile time? Or that "darwin" is not as nice as "macos".
I'm also fine with platform.system().

Asked on the kitty tracker -> https://github.com/kovidgoyal/kitty/issues/9217

Nice. We should probably make sure that terminals agree on the values for `query-os_name`. I'd naively expect `os.uname().sysname` which is what `uname` prints, so it should be a low common denominator (not specific to Python). If we do that, we could call it `query-uname` which makes the semantics more obvious (and doesn't mix "-" and "_"). I'm not sure what are the downsides (compared to the kitty approach), maybe that the possible values are not known at compile time? Or that "darwin" is not as nice as "macos". I'm also fine with `platform.system()`. Asked on the kitty tracker -> https://github.com/kovidgoyal/kitty/issues/9217
Author
Owner
Copy link

I would also prefer uname. This was really just a quick hack to show how it can be done.

I would also prefer uname. This was really just a quick hack to show how it can be done.
Author
Owner
Copy link

+1 for calling it query-uname as well :)

+1 for calling it `query-uname` as well :)
Author
Owner
Copy link

Even if we keep the original name, query-os_name (query-os-name? query-os?), we could still standardize on using uname as source. That would make it very easy for all Unix terminals. Windows terminals would have to decide together, which name to use.

Even if we keep the original name, `query-os_name` (`query-os-name`? `query-os`?), we could still standardize on using `uname` as source. That would make it very easy for all Unix terminals. Windows terminals would have to decide together, which name to use.
Author
Owner
Copy link

I've updated the MR to use uname.sysname instead.

I've updated the MR to use `uname.sysname` instead.
First-time contributor
Copy link

To be explicit about the data source, we could add a uname= prefix (query-os-name=uname=$(uname)).
I guess conflicts would be quite unlikely but this seems a bit cleaner.
I'm okay either way I've cc'ed some folks in https://github.com/wezterm/wezterm/issues/7370 in case others want share thoughts.

I wouldn't call .lower() because that makes it needlessly different from uname(1).

Also some nits

  • I'd change query-os_name to query-os-name though I'm fine with either
  • (I generally don't like abbreviations in globally visible name so I wonder if query-system-name would be better.) Hard to tell, so I'd leave query-os.
To be explicit about the data source, we could add a `uname=` prefix (`query-os-name=uname=$(uname)`). I guess conflicts would be quite unlikely but this seems a bit cleaner. I'm okay either way I've cc'ed some folks in https://github.com/wezterm/wezterm/issues/7370 in case others want share thoughts. I wouldn't call `.lower()` because that makes it needlessly different from `uname(1)`. Also some nits - I'd change `query-os_name` to `query-os-name` though I'm fine with either - (I generally don't like abbreviations in globally visible name so I wonder if `query-system-name` would be better.) Hard to tell, so I'd leave `query-os`.
Author
Owner
Copy link

Updated to:

  • query-os-name
  • Use uname -s as is (no lower-casing)
  • Prefix the result with uname=
$ ./utils/xtgettcap query-os-name
reply: (56 chars): <ESC>P1+r71756572792d6f732d6e616d65=756E616D653D4C696E7578<ESC>\
 query-os-name=uname=Linux
Updated to: * `query-os-name` * Use `uname -s` as is (no lower-casing) * Prefix the result with `uname=` ``` $ ./utils/xtgettcap query-os-name reply: (56 chars): <ESC>P1+r71756572792d6f732d6e616d65=756E616D653D4C696E7578<ESC>\ query-os-name=uname=Linux ```
First-time contributor
Copy link

Thanks! Tested successfully with this upcoming change.

Usage would be a bit simpler without the uname= prefix but I think I still prefer its explicitness.

So this LGTM; maybe mention it in docs somewhere like this:

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6dd0719fa3..b4aec92c16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -74,8 +74,8 @@
 `foot` and `footclient`), allowing you to set a custom toplevel
 tag. The compositor must implement the new `xdg-toplevel-tag-v1`
 Wayland protocol ([#2212][2212]).
-* `XTGETTCAP`: added `query-os_name`, returning the OS foot is
- compiled for (e.g. _'linux'_) ([#2209][2209]).
+* `XTGETTCAP`: added `query-os-name`, returning the OS foot is
+ compiled for (e.g. _'Linux'_) ([#2209][2209]).
 
 [2212]: https://codeberg.org/dnkl/foot/issues/2212
 [2202]: https://codeberg.org/dnkl/foot/issues/2202
diff --git a/README.md b/README.md
index e8f3c8cd5a..632e6147f3 100644
--- a/README.md
+++ b/README.md
@@ -641,6 +641,9 @@
 capability name, foot's reply is identical to what `tigetstr()` would
 have returned.
 
+In addition to queries for terminfo entries, the `query-os-name`
+query will be answered with a response of the form `uname=$(uname)`,
+where `$(uname)` is the name of the OS foot was compiled for.
 
 # Credits
 
Thanks! Tested successfully with [this upcoming change](https://github.com/fish-shell/fish-shell/commit/14414ceec18fb836e61132dde1a9b4404d2e3fc9). [Usage](https://github.com/fish-shell/fish-shell/commit/14414ceec18fb836e61132dde1a9b4404d2e3fc9#diff-d8281319c42f0263bf9edf56669da239780d8e39ffee494bb4b7e06ba2303746R2) would be a bit simpler without the `uname=` prefix but I think I still prefer its explicitness. So this LGTM; maybe mention it in docs somewhere like this: ```diff diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dd0719fa3..b4aec92c16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,8 +74,8 @@ `foot` and `footclient`), allowing you to set a custom toplevel tag. The compositor must implement the new `xdg-toplevel-tag-v1` Wayland protocol ([#2212][2212]). -* `XTGETTCAP`: added `query-os_name`, returning the OS foot is - compiled for (e.g. _'linux'_) ([#2209][2209]). +* `XTGETTCAP`: added `query-os-name`, returning the OS foot is + compiled for (e.g. _'Linux'_) ([#2209][2209]). [2212]: https://codeberg.org/dnkl/foot/issues/2212 [2202]: https://codeberg.org/dnkl/foot/issues/2202 diff --git a/README.md b/README.md index e8f3c8cd5a..632e6147f3 100644 --- a/README.md +++ b/README.md @@ -641,6 +641,9 @@ capability name, foot's reply is identical to what `tigetstr()` would have returned. +In addition to queries for terminfo entries, the `query-os-name` +query will be answered with a response of the form `uname=$(uname)`, +where `$(uname)` is the name of the OS foot was compiled for. # Credits ```
Author
Owner
Copy link

Applied, thanks!

Applied, thanks!
dnkl marked this conversation as resolved
dnkl force-pushed terminfo-query-os-name from 16a0154970
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to 2e477f6a37
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年11月12日 13:22:43 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from 2e477f6a37
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to d29b1f915c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年11月19日 08:30:30 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from d29b1f915c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to 71a43f5420
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年11月19日 08:32:52 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from 71a43f5420
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to 87bc829e87
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
2025年11月20日 13:59:44 +01:00
Compare
@ -644,0 +644,4 @@
In addition to queries for terminfo entries, the `query-os-name` query
will be answered with a response of the form `uname=$(uname -s)`,
where `$(uname -s)` is the name of the OS foot was compiled for.
First-time contributor
Copy link

we got a vote for removing the uname= prefix (https://github.com/wezterm/wezterm/issues/7370#issuecomment-3567974927),
so I think we should do that (it's less surprising).

we got a vote for removing the `uname=` prefix (https://github.com/wezterm/wezterm/issues/7370#issuecomment-3567974927), so I think we should do that (it's less surprising).
Author
Owner
Copy link

I'm fine with either. I've dropped the uname=-prefix.

I'm fine with either. I've dropped the `uname=`-prefix.
dnkl marked this conversation as resolved
dnkl force-pushed terminfo-query-os-name from 87bc829e87
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
to 53b97b90dc
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年12月10日 13:43:52 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from 53b97b90dc
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to d8c69894e3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年12月10日 13:45:06 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from d8c69894e3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to c8cad1af57
All checks were successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年12月19日 07:08:28 +01:00
Compare
dnkl force-pushed terminfo-query-os-name from c8cad1af57
All checks were successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to aa26676c43
All checks were successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pull_request_metadata/woodpecker Pipeline was successful
2025年12月20日 15:59:38 +01:00
Compare
dnkl manually merged commit aa26676c43 into master 2025年12月20日 16:00:16 +01:00
dnkl changed title from (削除) builtin terminfo: add custom 'query-os_name' (削除ここまで) to builtin terminfo: add custom 'query-os-name' 2025年12月25日 15:27:48 +01:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot!2217
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "terminfo-query-os-name"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?