]> git.rmz.io Git - dotfiles.git/blob - awesome/topbar.lua
Makefile: add target for git
[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 local function client_menu_toggle_fn()
12 local instance = nil
13
14 return function ()
15 if instance and instance.wibox.visible then
16 instance:hide()
17 instance = nil
18 else
19 instance = awful.menu.clients({ theme = { width = 250 } })
20 end
21 end
22 end
23
24 -- Wibox {{{1
25 -- Create a wibox for each screen and add it
26 local taglist_buttons = awful.util.table.join(
27 awful.button({ }, 1, function(t) t:view_only() end),
28 awful.button({ modkey }, 1, function(t)
29 if client.focus then
30 client.focus:move_to_tag(t)
31 end
32 end),
33 awful.button({ }, 3, awful.tag.viewtoggle),
34 awful.button({ modkey }, 3, function(t)
35 if client.focus then
36 client.focus:toggle_tag(t)
37 end
38 end),
39 awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
40 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
41 )
42
43 local tasklist_buttons = awful.util.table.join(
44 awful.button({ }, 1, function (c)
45 if c == client.focus then
46 c.minimized = true
47 else
48 -- Without this, the following
49 -- :isvisible() makes no sense
50 c.minimized = false
51 if not c:isvisible() and c.first_tag then
52 c.first_tag:view_only()
53 end
54 -- This will also un-minimize
55 -- the client, if needed
56 client.focus = c
57 c:raise()
58 end
59 end),
60 awful.button({ }, 2, function (c) c:kill() end),
61 awful.button({ }, 3, client_menu_toggle_fn()),
62 awful.button({ }, 4, function ()
63 awful.client.focus.byidx(1)
64 end),
65 awful.button({ }, 5, function ()
66 awful.client.focus.byidx(-1)
67 end))
68
69
70 awful.screen.connect_for_each_screen(function(s)
71 -- Create a promptbox for each screen
72 s.mypromptbox = 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 s.mylayoutbox = awful.widget.layoutbox(s)
76 s.mylayoutbox:buttons(awful.util.table.join(
77 awful.button({ }, 1, function () awful.layout.inc( 1) end),
78 awful.button({ }, 3, function () awful.layout.inc(-1) end),
79 awful.button({ }, 4, function () awful.layout.inc( 1) end),
80 awful.button({ }, 5, function () awful.layout.inc(-1) end)))
81 -- Create a taglist widget
82 s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
83
84 -- Create a tasklist widget
85 s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
86
87 -- Create the wibox
88 s.mywibox = awful.wibar({ position = "top", screen = s })
89
90 -- Add widgets to the wibox
91 s.mywibox:setup {
92 layout = wibox.layout.align.horizontal,
93 { -- Left widgets
94 layout = wibox.layout.fixed.horizontal,
95 s.mytaglist,
96 s.mypromptbox,
97 },
98 s.mytasklist, -- Middle widget
99 { -- Right widgets
100 layout = wibox.layout.fixed.horizontal,
101 mykeyboardlayout,
102 wibox.widget.systray(),
103 separator,
104 require("widgets/pomodoro"),
105 separator,
106 require("widgets/awesompd"),
107 require("widgets/volume_widget"),
108 utils.has_battery() and {
109 layout = wibox.layout.fixed.horizontal,
110 separator,
111 require("widgets/battery_widget"),
112 },
113 separator,
114 require("widgets/network_widget"),
115 separator,
116 require("widgets/calendar"),
117 s.mylayoutbox,
118 },
119 }
120 end)