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