Ubuntu: Need battery applet for Awesome WM and Ubuntu 14.04



Question:

Today I made a fresh installation of Ubuntu 14.04. I was using Ubuntu 10.04 previously. So far I have restored everything except for I cannot find an applet for Awesome WM that shows the battery status. How are we supposed to get that when using Ubuntu 14.04? It was so much easier with Ubuntu 10.04 where I could just run the power manager from Gnome on startup.


Solution:1

Just did it yesterday for my laptop :)

To get the battery status there is quite simple tool called acpi, you need to install it first:

sudo apt-get install acpi  

Then if you run it you'll have something like this:

acpi  Battery 1: discharging, 44%, 00:18:48 remaining  

So now you just need to create a widget which will run this command and the output in on the wibox - to display it.

For awesome 3.4:

batterywidget = widget({ type = "textbox" })                                      batterywidget.text = " | Battery | "                                              batterywidgettimer = timer({ timeout = 5 })                                       batterywidgettimer:add_signal("timeout",                                            function()                                                                          fh = assert(io.popen("acpi | cut -d, -f 2,3 -", "r"))                             batterywidget.text = " |" .. fh:read("*l") .. " | "                               fh:close()                                                                      end                                                                             )                                                                                 batterywidgettimer:start()  

For awesome 3.5:

batterywidget = wibox.widget.textbox()      batterywidget:set_text(" | Battery | ")      batterywidgettimer = timer({ timeout = 5 })      batterywidgettimer:connect_signal("timeout",        function()          fh = assert(io.popen("acpi | cut -d, -f 2,3 -", "r"))          batterywidget:set_text(" |" .. fh:read("*l") .. " | ")          fh:close()        end      )      batterywidgettimer:start()  

And then add it to wibox in your rc.lua:

right_layout:add(batterywidget)  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »