shdown / luastatus

universal status bar content generator
GNU General Public License v3.0
293 stars 12 forks source link

[network-linux] signal_percent returns nil #40

Closed lieux closed 5 years ago

lieux commented 5 years ago

The parameter signal_dbm works fine but signal_percent returns nil.

shdown commented 5 years ago

This is expected: some drivers only return signal in percents (presumably this is rare), some in dbms.

Same on my machine.

I guess this needs to be stated in plugins/network-linux/README.rst.

You can use NetworkManager's formula of calculating percent from dbm: 1 - 0.7 * (MAX_DBM - dbm) / (MAX_DBM - MIN_DBM), where dbm is clamped between MIN_DBM and MAX_DBM, MIN_DBM = -90, MAX_DBM = -20. See examples/i3/wireless.lua, make_wifi_gauge function.