Crylia / crylia-theme

A theme for AwesomeWM
520 stars 26 forks source link

[BUG] attempt to concatenate a nil value #3

Closed imalightbulb closed 2 years ago

imalightbulb commented 2 years ago

Describe the bug As in the screenshot, this error occurs Related lines of code (battery.lua:85:)

battery_tooltip:set_text("Remaining battery time: " .. stdout:match("%d+,%d") .. " " .. rem_time)
elseif stdout:match("time to full") then
battery_tooltip:set_text("Battery fully charged in: " .. stdout:match("%d+,%d") .. " " .. rem_time)
end

dk why it's not working To Reproduce Steps to reproduce the behavior: When hovering to the battery icon this occurs

image

Crylia commented 2 years ago

Could you please provide me with the output of upower -i $(upower -e | grep BAT).

imalightbulb commented 2 years ago
  native-path:          BAT1
  vendor:               DYNAPACK
  model:                HB4792J5ECW-31
  serial:               11257
  power supply:         yes
  updated:              Sat 23 Apr 2022 09:23:05 PM +08 (14 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              9.53472 Wh
    energy-empty:        0 Wh
    energy-full:         35.6177 Wh
    energy-full-design:  41.4279 Wh
    energy-rate:         9.43158 W
    voltage:             11.297 V
    charge-cycles:       309
    time to full:        2.8 hours
    percentage:          26%
    capacity:            85.9751%
    technology:          lithium-ion
    icon-name:          'battery-low-charging-symbolic'
  History (charge):
    1650720185  26.000  charging
    1650720111  27.000  discharging
    1650720103  0.000   unknown
  History (rate):
    1650720185  9.432   charging
    1650720111  6.727   discharging
    1650720103  0.000   unknown

here you go

Crylia commented 2 years ago

The issue seemed to be in " time to full: 2.8 hours". Looks like when doing :match("%d+, "d") it will return nil since your battery uses a '.' instead of ','. I added another :match("%d+. "d") and if that fails it will be an empty string to not concatenate a nil value