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