Fixed dfr usage
This commit is contained in:
parent
ec550c42b0
commit
f90e997da8
|
@ -6,31 +6,22 @@ let discordianDate = ^ddate
|
||||||
def get_batteries [] {
|
def get_batteries [] {
|
||||||
let power_supplies = (
|
let power_supplies = (
|
||||||
(ls /sys/class/power_supply).name
|
(ls /sys/class/power_supply).name
|
||||||
| each {|item|
|
| each { open $"($in)/uevent" }
|
||||||
open $"($item)/uevent"
|
| each { $in | lines | parse "{key}={value}"}
|
||||||
}
|
)
|
||||||
| each {|item|
|
|
||||||
$item | lines | parse "{key}={value}"
|
|
||||||
})
|
|
||||||
|
|
||||||
let batteries = $power_supplies | each {||
|
let batteries = $power_supplies
|
||||||
$in | dfr into-df | dfr get key | dfr contains POWER_SUPPLY_CAPACITY | dfr into-nu | get key | any {|| $in == true }
|
| each { where key == "POWER_SUPPLY_CAPACITY" | get value | is-not-empty }
|
||||||
} | into record | items {|k,v|
|
| enumerate | where item == true | get index
|
||||||
if $v == true {
|
| each {|index| $power_supplies | get $index | transpose -r}
|
||||||
($power_supplies | get ($k | into int) | transpose -r)
|
|
||||||
}
|
|
||||||
} | each {|| $in}
|
|
||||||
|
|
||||||
$batteries | each {|i|
|
$batteries
|
||||||
[ $i.POWER_SUPPLY_MANUFACTURER $i.POWER_SUPPLY_MODEL_NAME $i.POWER_SUPPLY_STATUS $i.POWER_SUPPLY_CAPACITY ]
|
| each {|i| [ $i.POWER_SUPPLY_MANUFACTURER $i.POWER_SUPPLY_MODEL_NAME $i.POWER_SUPPLY_STATUS $i.POWER_SUPPLY_CAPACITY ]
|
||||||
| each {|j|
|
| each { first }
|
||||||
$j | first
|
|
||||||
}
|
}
|
||||||
} | each {|str|
|
| each {|str| $str | str join " " }
|
||||||
$str | str join " "
|
| each {|str| $str | str replace -r '$' '%' }
|
||||||
} | each {|str|
|
| str join "\n"
|
||||||
$str | str replace -r '$' '%'
|
|
||||||
} | str join "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Documentation for notify
|
# Documentation for notify
|
||||||
|
|
Loading…
Reference in a new issue