summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2019-02-03 15:22:28 -0800
committerMike Crute <mike@crute.us>2019-02-03 15:22:28 -0800
commit03471fed1493ce16adc46f58c32fad3aa0e6b661 (patch)
treee709b57e445d6a0cca92352624285e0f52d2def3 /.config
parent052e50f8c232e284fc6b9d194d0673b28ed5387c (diff)
downloaddotfiles-03471fed1493ce16adc46f58c32fad3aa0e6b661.tar.bz2
dotfiles-03471fed1493ce16adc46f58c32fad3aa0e6b661.tar.xz
dotfiles-03471fed1493ce16adc46f58c32fad3aa0e6b661.zip
Add low battery warning
Diffstat (limited to '.config')
-rw-r--r--.config/awesome/battery.lua6
-rw-r--r--.config/awesome/mcrute.lua33
2 files changed, 32 insertions, 7 deletions
diff --git a/.config/awesome/battery.lua b/.config/awesome/battery.lua
index 9761354..772ed46 100644
--- a/.config/awesome/battery.lua
+++ b/.config/awesome/battery.lua
@@ -31,7 +31,7 @@ local status_text = {
31 ["unknown"] = "⌁" 31 ["unknown"] = "⌁"
32} 32}
33 33
34local battery = { mt = {} } 34local battery = { mt = {}, status_callback = nil }
35 35
36-- {{{ upower backend 36-- {{{ upower backend
37local tonumber = tonumber 37local tonumber = tonumber
@@ -212,6 +212,10 @@ local function update(force)
212 212
213 local battery_status 213 local battery_status
214 214
215 if battery.status_callback then
216 battery.status_callback(bat)
217 end
218
215 if blinking and inverted then 219 if blinking and inverted then
216 battery_status = status .. ' ' .. awful.util.escape(tostring(bat.charge)) .. '%' 220 battery_status = status .. ' ' .. awful.util.escape(tostring(bat.charge)) .. '%'
217 else 221 else
diff --git a/.config/awesome/mcrute.lua b/.config/awesome/mcrute.lua
index 62b83ae..f0a9bcd 100644
--- a/.config/awesome/mcrute.lua
+++ b/.config/awesome/mcrute.lua
@@ -60,12 +60,33 @@ function string_split(s, delimiter)
60 return result 60 return result
61end 61end
62 62
63-- TODO: figure out how to notify when below 5% 63local battery_warning_delivered = false
64function battery_low_warning() 64
65 naughty.notify({ preset = naughty.config.presets.critical, 65require("battery").status_callback = function(bat)
66 title = "Battery Low", 66 local should_warn = bat.charge <= 10 and (bat.status == 'discharging' or bat.status == 'not connected')
67 icon = "battery-empty", 67 local be_persistent = bat.charge <= 5 and (bat.status == 'discharging' or bat.status == 'not connected')
68 icon_size = 256 }) 68
69 if battery_warning_delivered and bat.status ~= 'discharging' then
70 battery_warning_delivered = false
71 end
72
73 -- Just one notification below 10% should be enough to get us to an outlet
74 if should_warn and not battery_warning_delivered then
75 naughty.notify({ preset = naughty.config.presets.critical,
76 title = "Battery Low",
77 icon = "battery-empty",
78 icon_size = 256 })
79 battery_warning_delivered = true
80 end
81
82 -- But if we make it to 5% then we're in danger of shutting down or
83 -- suspending imminently so start being annoying
84 if be_persistent then
85 naughty.notify({ preset = naughty.config.presets.critical,
86 title = "Battery Low",
87 icon = "battery-empty",
88 icon_size = 256 })
89 end
69end 90end
70 91
71-- TODO: 92-- TODO: