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