lain icon indicating copy to clipboard operation
lain copied to clipboard

Battery widget lists batteries twice when the number of screens is two

Open last5bits opened this issue 7 years ago • 0 comments

My laptop has only two batteries but bat_now lists four batteries when there are two screens:

image

With one screen, the widget seems to work fine.

The battery widget is created as described by @lcpz in #434:

local batstat = {}

local mybattery = lain.widget.bat {
    timeout = 5,
    settings = function()
        widget:set_markup(" ↯ " .. bat_now.perc)
        batstat = bat_now
    end
}

local mybattery_t = awful.tooltip {
    objects = { mybattery.widget },
    timer_function = function()
        local msg = ""
        for i = 1, #batstat.n_status do
            msg = msg .. lain.util.markup.font("monospace 10",
            string.format("┌[Battery %d]\n├Status:\t%s\n└Percentage:\t%s\n\n",
            i-1, batstat.n_status[i], batstat.n_perc[i]))
        end
        return msg .. lain.util.markup.font("monospace 10", "Time left:\t" .. batstat.time)
    end
}

And then added to the wibox of each screen as usual.

I can see that in bat.lua, variable batteries ends up having four elements but I can't understand why. Any input would be much appreciated.

  • output of awesome -v and lua -v
awesome v4.3-318-g6101ef518 (Too long)
 • Compiled against Lua 5.3.5 (running with Lua 5.3)
 • D-Bus support: ✔
 • xcb-errors support: ✘
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2

Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio

last5bits avatar Aug 04 '19 21:08 last5bits