-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Added CPU temperature and Device name for X86 #267
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests failing for stickler
at L290
-f doesn't work with globs. Use a for loop
padd.sh
Outdated
@@ -267,7 +269,9 @@ GetSystemInformation() { | |||
fi | |||
|
|||
# Device model | |||
if [ -f /sys/firmware/devicetree/base/model ]; then | |||
if [ -f /sys/devices/virtual/dmi/id/product_name ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my system product_family
would be the better choice.
chrko@ThinkPad-X230:~$ cat /sys/devices/virtual/dmi/id/product_name
2325CN3
cat /sys/devices/virtual/dmi/id/product_family
ThinkPad X230
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the same file used by applications like neofetch to show the host name
. I tried with an MSI and a Mac Mini and product_name
and the results are these:
cat /sys/devices/virtual/dmi/id/product_family
PS
cat /sys/devices/virtual/dmi/id/product_name
PS63 Modern 8SC
cat /sys/devices/virtual/dmi/id/product_family
Macmini
cat /sys/devices/virtual/dmi/id/product_name
Macmini6,2
While on an Asus laptop the situation is as your:
cat /sys/devices/virtual/dmi/id/product_family
VivoBook
cat /sys/devices/virtual/dmi/id/product_name
X510UQR
So, I thought that a possible solution could be if product_family
is a substring of product_name
then only the latter is shown, otherwise both the strings are displayed.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if it works also in your system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works.
chrko@ThinkPad-X230:~$ ./test.sh
ThinkPad X230 2325CN3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the Stickler complains.
padd.sh
Outdated
@@ -267,7 +269,9 @@ GetSystemInformation() { | |||
fi | |||
|
|||
# Device model | |||
if [ -f /sys/firmware/devicetree/base/model ]; then | |||
if [ -f /sys/devices/virtual/dmi/id/product_name ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works.
chrko@ThinkPad-X230:~$ ./test.sh
ThinkPad X230 2325CN3
padd.sh
Outdated
sys_model="${product_family} ${product_name}" | ||
fi | ||
|
||
# sys_model=$(tr -d '\0' < /sys/devices/virtual/dmi/id/product_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# sys_model=$(tr -d '\0' < /sys/devices/virtual/dmi/id/product_name) | |
I can furthermore provide on a small NUC:
On my HP microserver:
On a new server:
|
Thank you very much, this is helpful! But what happens if you execute a program like |
Why don't we use the same logic as Including the cleaning: https://github.com/dylanaraps/neofetch/blob/ccd5d9f52609bbdcd5d8fa78c4fdb0f12954125f/neofetch#L1361-L1374 |
That's interesting. Currently the
Producing Using the locally installed version (also v7.1.0) And the code looks like
They added it here: dylanaraps/neofetch#1943 The old was more useful I think. We could simply change the order of |
I noticed the same thing. If you download the last release code, it is different from the one in the repo. However the same logic can be implemented without any problem, but that cleaning string way is not supported in |
To increase POSIX compliance to make it more portable.
|
Okay, thanks. I will try to implement the same logic and string cleaning then. |
Works good for me. Maybe @DL6ER could test on his devices. |
padd.sh
Outdated
fi | ||
|
||
# Cleaning device model from useless OEM information | ||
sys_model=$(echo "$sys_model" | sed -e 's:To be filled by O.E.M.::g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stickler test (actually Shellcheck) is complaining here. It is asking to use this variable substituion ${variable//search/replace}
, but I'm almost sure this is not POSIX.
You can try to use shell "pattern filtering":
sys_model=$(echo "$sys_model" | sed -e 's:To be filled by O.E.M.::g') | |
sys_model="${sys_model#"To be filled by O.E.M."}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is a more elegant way to clean the string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works if the searched string is on the beginning of $sys_model
. If you need to remove from the end, use ${sys_model%"To be filled by O.E.M."}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so for each string there must be two filters, one for the beginning and one for the end since there might be the possibility that the value of sys_model
is To be filled by O.E.M. To be filled by O.E.M.
, as shown by @DL6ER
padd.sh
Outdated
@@ -279,7 +279,6 @@ GetSystemInformation() { | |||
if [ -z "$sys_model" ]; then | |||
sys_model="${product_family} ${product_name}" | |||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more test failing (if you click on "Details" on the failing test you will be able to see it).
There are trailing spaces here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks. Now it should be fixed.
Tests pass now. Can you please squash down your commits into a single one? |
Signed-off-by: FauFra <[email protected]>
Is it okay now? |
Updated
cpu
andsys_model
variables with more precise files when the script is executed on a X86 machine.By submitting this pull request, I confirm the following:
git rebase
)