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

randrctl encloses some values in quotation marks, but not all #32

Open
drws opened this issue Nov 29, 2021 · 1 comment
Open

randrctl encloses some values in quotation marks, but not all #32

drws opened this issue Nov 29, 2021 · 1 comment

Comments

@drws
Copy link

drws commented Nov 29, 2021

This is a sample randrctl show output:

name: current
outputs:
  VGA1:
    crtc: 0
    mode: 1920x1200
    panning: '0x0'
    pos: '0x0'
    rate: '59.95'
    rotate: normal
    scale: 1x1
primary: VGA1

Currently, the quotation marks are shown more or less randomly. I'd expect they followed some kind of order, such as:

  • every parameter value is quoted (currently 4 missing in this case)
  • only pure numerical values (ints and floats) aren't quoted (currently 4 missing and one redundant in rate)
  • only strings containing 2D numerical values are quoted (quotes missing in mode and scale, while again being redundant in rate)
  • no quotes are necessary (currently 3 redundant)

I vote for the last option since quotes aren't necessary to reliably parse such output and they also don't simplify screen reading, actually the opposite.

I know randrctl is currently not actively developed, but I'm still collecting ideas here for anyone that picks it up.

@koiuo
Copy link
Owner

koiuo commented Nov 29, 2021

@drws , thanks for expressing your ideas. Appreciate that.

The quotation is there in some cases because yaml is actually typed (sic!). If string type can be deduced from the content, quotation isn't necessary.

With 0x0 it is not obvious to parser whether it's a hexadecimal number or a string.

Same story with 59.95. We could of course drop quotation and treat it as float, but floats in most languages are expressed following the IEEE-754, meaning that upon parsing we'll have 59.9500000003 or something like that. And in general case we don't know at which point it is safe to trim that number.

randrctl performs some arithmetics only on tuples (2d numerical values), which are specified as strings and require parsing anyway. Hence the correct thing here would be to quote everything, but again this quotation is performed by PyYAML and I'm not even sure it gives any control over that.

Frankly, the better option IMO is to use a different format alltogether (yaml spec is really overly complicated despite its visual simplicity). TOML is a new trendy thing...

I know randrctl is currently not actively developed, but I'm still collecting ideas here for anyone that picks it up.

I've been meddling with a rewrite in a private repo which addresses some of the painful issues of the current implementation. Namely, the new version doesn't require xrandr and can be distributed as a single binary, however it is in the early prototype stage (and it's been like that for more than a year already, as I never have enough time/motivation). That's why I appreciate your attention to this project even more, and perhaps I can find motivation to push the rewrite further.
Thanks!

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

No branches or pull requests

2 participants