]> git.rmz.io Git - dotfiles.git/blob - awesome/topbar.lua
nvim: add FPP copyright snippet
[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 = gears.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 = gears.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(gears.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 local theme = beautiful.get()
83 s.mytaglist = awful.widget.taglist{
84 screen = s,
85 filter = awful.widget.taglist.filter.all,
86 buttons = taglist_buttons,
87 style = {
88 squares_resize = false
89 },
90 widget_template = {
91 {
92 {
93 {
94 id = 'icon_role',
95 widget = wibox.widget.imagebox,
96 },
97 layout = wibox.layout.fixed.horizontal,
98 },
99 forced_width = theme.wibar_height,
100 widget = wibox.container.place,
101 },
102 id = 'background_role',
103 widget = wibox.container.background,
104 },
105 }
106
107 -- Create a tasklist widget
108 s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
109
110 -- Create the wibox
111 s.mywibox = awful.wibar({ position = "top", screen = s })
112
113 -- Add widgets to the wibox
114 s.mywibox:setup {
115 layout = wibox.layout.align.horizontal,
116 { -- Left widgets
117 layout = wibox.layout.fixed.horizontal,
118 s.mytaglist,
119 s.mypromptbox,
120 },
121 s.mytasklist, -- Middle widget
122 { -- Right widgets
123 layout = wibox.layout.fixed.horizontal,
124 mykeyboardlayout,
125 wibox.widget.systray(),
126 separator,
127 require("widgets/pomodoro"),
128 separator,
129 require("widgets/mpd_widget"),
130 separator,
131 require("widgets/volume_widget"),
132 utils.has_battery() and {
133 layout = wibox.layout.fixed.horizontal,
134 separator,
135 require("widgets/battery_widget"),
136 },
137 separator,
138 require("widgets/network_widget"),
139 separator,
140 require("widgets/calendar"),
141 s.mylayoutbox,
142 },
143 }
144 end)