summaryrefslogtreecommitdiff
path: root/battery-widget
diff options
context:
space:
mode:
authorRoman Sokolkov <rsokolkov@gmail.com>2017-02-08 18:53:26 +0100
committerRoman Sokolkov <rsokolkov@gmail.com>2017-02-08 19:53:44 +0100
commit524e6da88ddfe5111f2b72bcac2c96e4d87743e7 (patch)
tree490862a8f79e589b33972343266d5a56fb88607d /battery-widget
parenteba5fcb7a8a1d3bfaef5739521e235ff1e4734dd (diff)
Refactored popup for battery
Use Awesome tooltip instead of naughty notify https://awesomewm.org/doc/api/classes/awful.tooltip.html
Diffstat (limited to 'battery-widget')
-rw-r--r--battery-widget/battery.lua29
1 files changed, 13 insertions, 16 deletions
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index 71d1823..446bafa 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -21,6 +21,15 @@ battery_widget = wibox.widget {
end
}
+-- Popup with battery info
+battery_popup = awful.tooltip({objects = {battery_widget}})
+
+-- To use colors from beautiful theme put
+-- following lines in rc.lua before require("battery")
+--
+-- beautiful.tooltip_fg = beautiful.fg_normal
+-- beautiful.tooltip_bg = beautiful.bg_normal
+
watch(
"acpi", 10,
function(widget, stdout, stderr, exitreason, exitcode)
@@ -41,22 +50,13 @@ watch(
batteryType = string.format(batteryType,'')
end
battery_widget.image = path_to_icons .. batteryType .. ".svg"
+
+ -- Update popup text
+ -- TODO: Filter long lines
+ battery_popup.text = string.gsub(stdout, "\n$", "")
end
)
-function show_battery_status()
- awful.spawn.easy_async([[bash -c 'acpi']],
- function(stdout, stderr, reason, exit_code)
- naughty.notify{
- text = stdout,
- title = "Battery status",
- timeout = 5, hover_timeout = 0.5,
- width = 200,
- }
- end
- )
-end
-
function show_battery_warning()
naughty.notify{
icon = "/home/pashik/.config/awesome/nichosi.png",
@@ -70,6 +70,3 @@ function show_battery_warning()
width = 300,
}
end
-
--- popup with battery info
-battery_widget:connect_signal("mouse::enter", function() show_battery_status() end) \ No newline at end of file