diff options
author | streetturtle <streetturtle@gmail.com> | 2015-07-13 18:26:39 +0200 |
---|---|---|
committer | streetturtle <streetturtle@gmail.com> | 2015-07-13 18:26:39 +0200 |
commit | a02279a9f2e18b0a60add45669000749d38a3020 (patch) | |
tree | 7dbbd2e380ff3285497aada9fd4ae99b6fad2e5b /BatteryWidget | |
parent | 336a88219b9f812382738a0342757c32fb954688 (diff) |
Moved to special folder
Diffstat (limited to 'BatteryWidget')
-rw-r--r-- | BatteryWidget/battery-icons/100.png | bin | 0 -> 1250 bytes | |||
-rw-r--r-- | BatteryWidget/battery-icons/20.png | bin | 0 -> 1161 bytes | |||
-rw-r--r-- | BatteryWidget/battery-icons/40.png | bin | 0 -> 1191 bytes | |||
-rw-r--r-- | BatteryWidget/battery-icons/60.png | bin | 0 -> 1222 bytes | |||
-rw-r--r-- | BatteryWidget/battery-icons/80.png | bin | 0 -> 1235 bytes | |||
-rw-r--r-- | BatteryWidget/battery.lua | 45 |
6 files changed, 45 insertions, 0 deletions
diff --git a/BatteryWidget/battery-icons/100.png b/BatteryWidget/battery-icons/100.png Binary files differnew file mode 100644 index 0000000..48cc412 --- /dev/null +++ b/BatteryWidget/battery-icons/100.png diff --git a/BatteryWidget/battery-icons/20.png b/BatteryWidget/battery-icons/20.png Binary files differnew file mode 100644 index 0000000..e3b455b --- /dev/null +++ b/BatteryWidget/battery-icons/20.png diff --git a/BatteryWidget/battery-icons/40.png b/BatteryWidget/battery-icons/40.png Binary files differnew file mode 100644 index 0000000..5de8a1d --- /dev/null +++ b/BatteryWidget/battery-icons/40.png diff --git a/BatteryWidget/battery-icons/60.png b/BatteryWidget/battery-icons/60.png Binary files differnew file mode 100644 index 0000000..483506f --- /dev/null +++ b/BatteryWidget/battery-icons/60.png diff --git a/BatteryWidget/battery-icons/80.png b/BatteryWidget/battery-icons/80.png Binary files differnew file mode 100644 index 0000000..11dc029 --- /dev/null +++ b/BatteryWidget/battery-icons/80.png diff --git a/BatteryWidget/battery.lua b/BatteryWidget/battery.lua new file mode 100644 index 0000000..09e0ed6 --- /dev/null +++ b/BatteryWidget/battery.lua @@ -0,0 +1,45 @@ +local wibox = require("wibox") +local awful = require("awful") +local naughty = require("naughty") + +function showBatteryWidgetPopup() + local save_offset = offset + naughty.notify({ + text = awful.util.pread("acpi | cut -d, -f 2,3"), + title = "Battery status", + timeout = 2, hover_timeout = 0.5, + width = 160, + }) +end + +function showBatteryWidgetIcon() + local charge = tonumber(awful.util.pread("acpi | cut -d, -f 2 | egrep -o '[0-9]{1,3}'")) + local batteryType + + if (charge >= 0 and charge < 20) then batteryType=20 + elseif (charge >= 20 and charge < 40) then batteryType=40 + elseif (charge >= 40 and charge < 60) then batteryType=60 + elseif (charge >= 60 and charge < 80) then batteryType=80 + elseif (charge >= 80 and charge < 100) then batteryType=100 + end + + batteryIcon:set_image("/home/pashik/.config/awesome/battery-icons/" .. batteryType .. ".png") +end + +batteryIcon = wibox.widget.imagebox() +showBatteryWidgetIcon() +batteryIcon:connect_signal("mouse::enter", + function() + showBatteryWidgetPopup() + end +) + +-- timer to refresh battery icon +batteryWidgetTimer = timer({ timeout = 5 }) +batteryWidgetTimer:connect_signal("timeout", + function() + showBatteryWidgetIcon() + end +) + +batteryWidgetTimer:start()
\ No newline at end of file |