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