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