Add tooltip to eww-battery-monitor
This commit is contained in:
parent
c8657e9378
commit
a4106633c8
@ -56,13 +56,24 @@ function warn_if_low() {
|
|||||||
|
|
||||||
function print_state() {
|
function print_state() {
|
||||||
percentage = state_info["percentage"]
|
percentage = state_info["percentage"]
|
||||||
printf "%s%s%d%%\n",
|
tooltip = ""
|
||||||
get_icon(percentage),
|
if (state_info["charging"]) {
|
||||||
state_info["charging"] ? "" : "",
|
tooltip = "Until Full: " state_info["time to full"]
|
||||||
percentage
|
} else {
|
||||||
|
tooltip = "Until Empty: " state_info["time to empty"]
|
||||||
|
}
|
||||||
|
printf "{\"text\":\"%s%s%d%%\",\"tooltip\":\"%s\"}\n",
|
||||||
|
get_icon(percentage),
|
||||||
|
state_info["charging"] ? "" : "",
|
||||||
|
percentage,
|
||||||
|
tooltip
|
||||||
fflush()
|
fflush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function string_or(str, def) {
|
||||||
|
return str == "" ? def : str
|
||||||
|
}
|
||||||
|
|
||||||
function parse_record(record, exit_on_absent) {
|
function parse_record(record, exit_on_absent) {
|
||||||
split(record, fields)
|
split(record, fields)
|
||||||
for (i in fields) {
|
for (i in fields) {
|
||||||
@ -77,6 +88,8 @@ function parse_record(record, exit_on_absent) {
|
|||||||
} else if ((! BATTERY && props["power supply"] == "yes" && \
|
} else if ((! BATTERY && props["power supply"] == "yes" && \
|
||||||
props["native-path"] ~ /BAT[0-9]+/) || name == BATTERY) {
|
props["native-path"] ~ /BAT[0-9]+/) || name == BATTERY) {
|
||||||
state_info["percentage"] = props["percentage"] + 0
|
state_info["percentage"] = props["percentage"] + 0
|
||||||
|
state_info["time to full"] = string_or(props["time to full"], "Unknown")
|
||||||
|
state_info["time to empty"] = string_or(props["time to empty"], "Unknown")
|
||||||
return 1
|
return 1
|
||||||
} else if ((! ADAPTER && props["power supply"] == "yes" && \
|
} else if ((! ADAPTER && props["power supply"] == "yes" && \
|
||||||
props["native-path"] ~ /ADP[0-9]+/) || name == ADAPTER) {
|
props["native-path"] ~ /ADP[0-9]+/) || name == ADAPTER) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user