Last active
February 16, 2017 17:37
-
-
Save mortymacs/7ba4260cc20ebba36122c87f7b84a644 to your computer and use it in GitHub Desktop.
Textbattery for awesome awful widget (modified version of textclock widget)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --------------------------------------------------------------------------- | |
| -- @copyright 2009 Julien Danjou | |
| --------------------------------------------------------------------------- | |
| local setmetatable = setmetatable | |
| local os = os | |
| local textbox = require("wibox.widget.textbox") | |
| local capi = { timer = timer } | |
| --- Text battery widget. | |
| -- awful.widget.textbattery | |
| local textbattery = { mt = {} } | |
| --- Create a textbattery widget. It draws the battery state it is in a textbox. | |
| function textbattery.new() | |
| local timeout = 30 | |
| local w = textbox() | |
| local timer = capi.timer { timeout = timeout } | |
| timer:connect_signal("timeout", function() x=io.popen("acpitool -b | awk '{print $4,$5}'");b=x:read("*a");w:set_markup(string.sub(b, 0, string.len(b)-2)) end) | |
| timer:start() | |
| timer:emit_signal("timeout") | |
| return w | |
| end | |
| function textbattery.mt:__call(...) | |
| return textbattery.new(...) | |
| end | |
| return setmetatable(textbattery, textbattery.mt) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this widget requires
acpitoolprogram. so install it before any action:sudo apt install acpitoolNow copy this widget in
/usr/share/awesome/lib/awful/widget/then import it ininit.luafile and then use it in yourrc.lualike so: