isDipesh / gnome-shell-extension-sensors

Gnome shell extension: Shows CPU temperature, HDD temperature, voltage and fan RPM
https://motorscript.com/gnome-shell-extension-sensors/
161 stars 153 forks source link

Multiple disk output is wrong #110

Open UshakovVasilii opened 10 years ago

UshakovVasilii commented 10 years ago

About code:

function parseHddTempOutput(txt, sep) {
    let hddtemp_output = [];
    if (txt.indexOf((sep+sep), txt.length - (sep+sep).length) >= 0)
    {
        hddtemp_output = txt.split(sep+sep);
    }
    else
    {
        hddtemp_output = txt.split("\n");
    }

My netcat output:

[ushakov@ushakov-pc ~]$ nc localhost 7634
|/dev/sda|KINGSTON SV300S37A120G|31|C||/dev/sdb|TOSHIBA DT01ACA200|36|C|

I think something wrong in first condition.

txt.length = 72 txt.length - (sep+sep).length = 70 So txt.indexOf((sep+sep), txt.length - (sep+sep).length) = txt.indexOf('||', 70) = -1 after that fist disk is outputted only.

I think should be something like:

if (txt.indexOf(sep+sep) > 0)

instead of:

if (txt.indexOf((sep+sep), txt.length - (sep+sep).length) >= 0)

How do you think? Thank you!