move modules to ./modules
This commit is contained in:
39
modules/battery
Executable file
39
modules/battery
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ ${BLOCK_INSTANCE} == '' ]] && BATTERY=0 || BATTERY=${BLOCK_INSTANCE}
|
||||
cat /sys/class/power_supply/BAT${BATTERY}/uevent | gawk -F '=' '
|
||||
/POWER_SUPPLY_STATUS=/ {
|
||||
status=$2
|
||||
}
|
||||
/POWER_SUPPLY_ENERGY_FULL=/ {
|
||||
efull=$2
|
||||
}
|
||||
/POWER_SUPPLY_ENERGY_NOW=/ {
|
||||
enow=$2
|
||||
}
|
||||
END {
|
||||
charge=enow/efull*100
|
||||
if (status == "Discharging") {
|
||||
status="↓"
|
||||
} else if (status == "Charging") {
|
||||
status="↑"
|
||||
} else {
|
||||
status=""
|
||||
}
|
||||
printf("%s%d%", status, charge)
|
||||
print("\n")
|
||||
if (charge > 25) {
|
||||
print("#04B431\n")
|
||||
} else if (charge > 20) {
|
||||
print("#A8FF00\n")
|
||||
} else if (charge > 15) {
|
||||
print("#FFF600\n")
|
||||
} else if (charge > 10) {
|
||||
print("#FFAE00\n")
|
||||
} else if (charge > 5) {
|
||||
print("#FF0000\n")
|
||||
} else {
|
||||
exit 33
|
||||
}
|
||||
}
|
||||
'
|
Reference in New Issue
Block a user