]> git.rmz.io Git - dotfiles.git/blob - awesome/topbar.lua
fix battery widget
[dotfiles.git] / awesome / topbar.lua
1 -- utils
2 local utils = require("utils")
3
4 -- Widget and layout library
5 local wibox = require("wibox")
6
7 -- my widgets
8 local volume_widget = require("widgets/volume_widget")
9 local battery_widget = { }
10 if utils.host == "chronos" then
11 battery_widget = require("widgets/battery_widget")
12 end
13 local network_widget = require("widgets/network_widget")
14
15 -- Create a textclock widget
16 mytextclock = awful.widget.textclock()
17
18 -- {{{ Wibox
19 -- Create a wibox for each screen and add it
20 mywibox = {}
21 mypromptbox = {}
22 mylayoutbox = {}
23 mytaglist = {}
24 mytaglist.buttons = awful.util.table.join(
25 awful.button({ }, 1, awful.tag.viewonly),
26 awful.button({ modkey }, 1, awful.client.movetotag),
27 awful.button({ }, 3, awful.tag.viewtoggle),
28 awful.button({ modkey }, 3, awful.client.toggletag),
29 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
30 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
31 )
32 mytasklist = {}
33 mytasklist.buttons = awful.util.table.join(
34 awful.button({ }, 1, function (c)
35 if c == client.focus then
36 c.minimized = true
37 else
38 -- Without this, the following
39 -- :isvisible() makes no sense
40 c.minimized = false
41 if not c:isvisible() then
42 awful.tag.viewonly(c:tags()[1])
43 end
44 -- This will also un-minimize
45 -- the client, if needed
46 client.focus = c
47 c:raise()
48 end
49 end),
50 awful.button({ }, 2, function (c) c:kill() end),
51 awful.button({ }, 3, function ()
52 if instance then
53 instance:hide()
54 instance = nil
55 else
56 instance = awful.menu.clients({ width=250 })
57 end
58 end),
59 awful.button({ }, 4, function ()
60 awful.client.focus.byidx(1)
61 if client.focus then client.focus:raise() end
62 end),
63 awful.button({ }, 5, function ()
64 awful.client.focus.byidx(-1)
65 if client.focus then client.focus:raise() end
66 end))
67
68
69 for s = 1, screen.count() do
70 -- Create a promptbox for each screen
71 mypromptbox[s] = awful.widget.prompt()
72 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
73 -- We need one layoutbox per screen.
74 mylayoutbox[s] = awful.widget.layoutbox(s)
75 mylayoutbox[s]:buttons(awful.util.table.join(
76 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
77 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
78 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
79 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
80 -- Create a taglist widget
81 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
82
83 -- Create a tasklist widget
84 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
85
86 -- Create the wibox
87 mywibox[s] = awful.wibox({ position = "top", screen = s })
88
89 -- Widgets that are aligned to the left
90 local left_layout = wibox.layout.fixed.horizontal()
91 left_layout:add(mylauncher)
92 left_layout:add(mytaglist[s])
93 left_layout:add(mypromptbox[s])
94
95 -- Widgets that are aligned to the right
96 local right_layout = wibox.layout.fixed.horizontal()
97 if s == 1 then right_layout:add(wibox.widget.systray()) end
98 right_layout:add(network_widget)
99 right_layout:add(volume_widget)
100 if utils.host == "chronos" then
101 right_layout:add(battery_widget)
102 end
103 right_layout:add(mytextclock)
104 right_layout:add(mylayoutbox[s])
105
106 -- Now bring it all together (with the tasklist in the middle)
107 local layout = wibox.layout.align.horizontal()
108 layout:set_left(left_layout)
109 layout:set_middle(mytasklist[s])
110 layout:set_right(right_layout)
111
112 mywibox[s]:set_widget(layout)
113 end
114 -- }}}