summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2016-12-16 22:01:26 +0100
committerPeter Palfrader <peter@palfrader.org>2016-12-19 08:50:01 +0100
commitc1e6f7f09b37e4ece220822887ad80cd6055dfbd (patch)
tree58e56f334292ef3fe86a2fea7d58472e4e7f97ac
parent5fff79f1ed33f6d185bdc1b73fbdb0d2c68d4ff7 (diff)
add a battery widget
-rw-r--r--config/awesome/battery.lua53
-rw-r--r--config/awesome/rc.lua31
-rw-r--r--config/awesome/weasel-rules.lua20
3 files changed, 87 insertions, 17 deletions
diff --git a/config/awesome/battery.lua b/config/awesome/battery.lua
new file mode 100644
index 0000000..988f9fa
--- /dev/null
+++ b/config/awesome/battery.lua
@@ -0,0 +1,53 @@
+function batteryInfoUpdate(adapter, warn, widget)
+ spacer = " "
+ local fcap = io.open("/sys/class/power_supply/"..adapter.."/capacity")
+ local fsta = io.open("/sys/class/power_supply/"..adapter.."/status")
+ local cap = fcap:read()
+ local sta = fsta:read()
+ fcap:close()
+ fsta:close()
+
+ if sta:match("Charging") then
+ state = 1
+ icon = "▴"
+ else
+ state = -1
+ icon = "▾"
+ end
+
+ if tonumber(cap) < 10 and warn then
+ naughty.notify({ title = "Battery Warning",
+ text = "Battery "..adapter.." low at "..cap.."%!",
+ timeout = 15,
+ position = "top_right",
+ fg = beautiful.fg_focus,
+ bg = beautiful.bg_focus,
+ })
+ end
+ if tonumber(cap) < 10 then
+ color='red'
+ elseif tonumber(cap) < 25 then
+ color='orange'
+ else
+ color='green'
+ end
+
+ widget:set_markup(spacer.."<span color='"..color.."'>"..icon..cap..'%</span>'..spacer)
+end
+
+local wibox = require("wibox")
+
+bat0_widget = wibox.widget.textbox()
+bat0_widget:set_align("right")
+
+bat1_widget = wibox.widget.textbox()
+bat1_widget:set_align("right")
+
+battery_timer = timer({timeout = 20})
+battery_timer:connect_signal("timeout", function()
+ batteryInfoUpdate("BAT0", true, bat0_widget)
+ batteryInfoUpdate("BAT1", false, bat1_widget)
+end)
+battery_timer:start()
+
+-- vim:set softtabstop=4:ts=4:shiftwidth=4:et=1:
diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua
index b26cdeb..d10ada6 100644
--- a/config/awesome/rc.lua
+++ b/config/awesome/rc.lua
@@ -14,6 +14,7 @@ local menubar = require("menubar")
-- Load Debian menu entries
require("debian.menu")
require("volume")
+require("battery")
require("weasel-rules")
-- require("revelation")
@@ -71,10 +72,10 @@ local layouts =
-- awful.layout.suit.fair.horizontal,
-- awful.layout.suit.spiral,
-- awful.layout.suit.spiral.dwindle,
- awful.layout.suit.max,
+ -- awful.layout.suit.max,
-- awful.layout.suit.max.fullscreen,
-- awful.layout.suit.magnifier
- awful.layout.suit.floating,
+ -- awful.layout.suit.floating,
}
-- }}}
@@ -206,6 +207,8 @@ for s = 1, screen.count() do
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
right_layout:add(volume_widget)
+ right_layout:add(bat0_widget)
+ right_layout:add(bat1_widget)
right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
@@ -270,8 +273,20 @@ globalkeys = awful.util.table.join(
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
- awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
- awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
+ awful.key({ modkey, }, "space", function ()
+ if awful.util.table.hasitem(layouts, awful.layout.get() ) then
+ awful.layout.inc(layouts, 1)
+ else
+ awful.layout.set(layouts[1])
+ end
+ end),
+ awful.key({ modkey, "Shift" }, "space", function ()
+ if awful.util.table.hasitem(layouts, awful.layout.get() ) then
+ awful.layout.inc(layouts, -1)
+ else
+ awful.layout.set(layouts[1])
+ end
+ end),
-- awful.key({ modkey, "Control" }, "n", awful.client.restore),
@@ -390,7 +405,7 @@ clientkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
awful.key({ modkey, }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
- -- awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
+ awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
-- weasel
awful.key({ "Mod1" }, "q", function (c)
@@ -561,11 +576,11 @@ client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_n
-- }}}
terminal = "urxvt"
-awful.util.spawn("nm-applet")
-awful.util.spawn("klipper")
+awful.util.spawn_with_shell("pkill -x -f nm-applet; nm-applet")
+--awful.util.spawn_with_shell("pkill -x -f klipper; klipper")
-- awful.util.spawn("xscreensaver -no-splash")
--KDE--awful.util.spawn("X-screensaver")
---KDE--awful.util.spawn_with_shell("pkill -x -f clipit; clipit")
+awful.util.spawn_with_shell("pkill -x -f clipit; clipit")
awful.util.spawn_with_shell("pkill -x -f 'alsa-volume-monitor hw:0'; alsa-volume-monitor hw:0")
-- vim:set softtabstop=4:ts=4:shiftwidth=4:et=1:
diff --git a/config/awesome/weasel-rules.lua b/config/awesome/weasel-rules.lua
index b645df3..ed659bf 100644
--- a/config/awesome/weasel-rules.lua
+++ b/config/awesome/weasel-rules.lua
@@ -1,30 +1,32 @@
function get_weasel_rules()
local sn = screen.count()
+ local browser_screen = 1
+ local im_screen = 1
local rules = {
{ rule = { class = "URxvt" , name = "FURxvt" },
properties = { floating = true } },
{ rule = { class = "Firefox" , name = "Mozilla Firefox" },
- properties = { tag = tags[sn][6] } },
+ properties = { tag = tags[browser_screen][6] } },
{ rule = { class = "Firefox" },
- properties = { tag = tags[sn][6] } },
+ properties = { tag = tags[browser_screen][6] } },
{ rule = { class = "chromium" , name = "New Tab - Chromium" },
- properties = { tag = tags[sn][7] } },
+ properties = { tag = tags[browser_screen][7] } },
{ rule = { class = "Tor Browser" , name = "Tor Browser" },
- properties = { tag = tags[sn][8], floating = true } },
+ properties = { tag = tags[browser_screen][8], floating = true } },
{ rule = { class = "Tor Browser" },
- properties = { tag = tags[sn][8], floating = true } },
+ properties = { tag = tags[browser_screen][8], floating = true } },
{ rule = { class = "URxvt" , name = "IRC" },
- properties = { tag = tags[sn][11] } },
+ properties = { tag = tags[im_screen][11] } },
{ rule = { class = "URxvt" , name = "Mail" },
- properties = { tag = tags[sn][12] } },
+ properties = { tag = tags[im_screen][12] } },
{ rule = { class = "URxvt" , name = "Mail COSY" },
- properties = { tag = tags[sn][12] } },
+ properties = { tag = tags[im_screen][12] } },
{ rule = { class = "chromium" , name = "Signal Private Messenger" },
- properties = { tag = tags[sn][13] } },
+ properties = { tag = tags[im_screen][13] } },
--{ rule = { maximized_horizontal = true }, -- these two should remove window borders from maximized windows because they get in the way
-- properties = { border_width = 0 } },