koiuo / randrctl

Profile based screen manager for X
GNU General Public License v3.0
47 stars 12 forks source link

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

Open drws opened 2 years ago

drws commented 2 years ago

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:

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 commented 2 years ago

@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!