Closed benjamin-voisin closed 3 months ago
Hi, I was tempted to merge this immediately. But then I noticed that in many places the indentations have slipped and only 2 blanks are used. TLP's standard is 4 blanks per level. Please correct this.
If you like, you can also update the auto-completion:
The main goal being to facilitate the usage of tlp with other script, by making easier to parse outputs.
Do you realize that the formatting can change at any time and your scraping will no longer work? I'm also curious: what are these "other scripts" - what is your use case?
I have updated the auto-completion, and fixed the indentation to 4 spaces.
Do you realize that the formatting can change at any time and your scraping will no longer work?
That is why I think an easy way to get the version is useful, and it will always be much more futurproof than trying to parse the output with grep
and sed
.
I'm also curious: what are these "other scripts" - what is your use case?
I'm making a waybar module to see the current tlp status, and to be able to change
I notice that -s -q
and -m
produce the same output, i.e. they are redundant. I will remove -m
if you agree.
I find it kinda weird that the -s
flag output two informations : system infos and status infos. To my, It would be preferable to remove status infos from -s
and put it only in the -m
flag. My idea is :
-m
output the status infos-m -q
output just the current tlp mode (bat, ac, bat (manual), ac (manual))-s
output only system infos-s -q
doesn't really matter, probably not different than -s
The main intention of my PR is to access easily the current mode (-m -q
) and the version (--version
). Maybe we remove the -m
flag, and make -s -q
output just the current status, but it feels weird to me (the fact that -s
output system and status infos feels weird).
I did not change -s
by fear that it might break retrocompatibility, but ideally I think -s
should only output system infos, and -m
status infos.
What do you think ?
The scope of -s
(System and Status) has been stable for a long time, I don't want to change it. I wouldn't call it "weird" but "legacy".
The main intention of my PR is to access easily the current mode and the version.
Then my suggestion is to implement just this:
-m
or --mode
outputs just the current tlp mode - bat, ac, bat (manual), ac (manual)--version
-q
or --quiet
removes the first line with version, and reduces the outputs for the temperature and cpu outputsWorks good for me :+1:
I have implemented my suggestions in my branch https://github.com/linrunner/TLP/tree/pr/729. Beyond -q
no longer suppresses the entire output, but only the corresponding parts of cpu and temperatures.
Please check if this still meets your requirements.
I'v tried it and it good for me, thanks !
Further fixes and additions were necessary -> https://github.com/linrunner/TLP/commits/pr/729/ The whole thing is merged to main now.
Thank you very much for your contribution.
Add 3 new flags to tlp-stat :
-m
,-q
and--version
. The main goal being to facilitate the usage of tlp with other script, by making easier to parse outputs. All already existing outputs are unchanged, there are no retrocompatibility issues.New outputs
The new flag
-m
(or--mode
) output the status. This data was already available under the-s
flag, but along with system informations. The output of-s
is not modified. For example, it may output something likeWhen passed with the new
-q
quiet flag, it only output the current mode (AC
,battery
,AC (manual)
orbattery (manual)
).--version
simply output the current version, nothing else :The new flag
-q
(or--quiet
) removes the first line with version, and reduce the outputs for themode
,temperature
andcpu
outputs. The differences inmode
is described above. For the temperature, if the results oftlp-stat -t
is :the result of
tlp-stat -t -q
will be :For the cpu, if the reslut of
sudo tlp-stat -p
is :the result of
sudo tlp-stat -p -q
will be :Docs
The manpage and the help output for
tlp-stat
are updated accordingly to what is described above.