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