+-- utils
+local utils = require("utils")
+
-- Widget and layout library
-wibox = require("wibox")
--- my widgets
-require("widgets")
+local wibox = require("wibox")
--- {{{ Wibox
-- Create a textclock widget
-mytextclock = awful.widget.textclock()
+separator = wibox.widget.textbox()
+separator:set_markup('<span font="Symbola 10" color="#404040">│</span>')
+
+local function client_menu_toggle_fn()
+ local instance = nil
+
+ return function ()
+ if instance and instance.wibox.visible then
+ instance:hide()
+ instance = nil
+ else
+ instance = awful.menu.clients({ theme = { width = 250 } })
+ end
+ end
+end
+-- Wibox {{{1
-- Create a wibox for each screen and add it
-mywibox = {}
-mypromptbox = {}
-mylayoutbox = {}
-mytaglist = {}
-mytaglist.buttons = awful.util.table.join(
- awful.button({ }, 1, awful.tag.viewonly),
- awful.button({ modkey }, 1, awful.client.movetotag),
+local taglist_buttons = gears.table.join(
+ awful.button({ }, 1, function(t) t:view_only() end),
+ awful.button({ modkey }, 1, function(t)
+ if client.focus then
+ client.focus:move_to_tag(t)
+ end
+ end),
awful.button({ }, 3, awful.tag.viewtoggle),
- awful.button({ modkey }, 3, awful.client.toggletag),
- awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
- awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
- )
-mytasklist = {}
-mytasklist.buttons = awful.util.table.join(
+ awful.button({ modkey }, 3, function(t)
+ if client.focus then
+ client.focus:toggle_tag(t)
+ end
+ end),
+ awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
+ awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
+ )
+
+local tasklist_buttons = gears.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
- if not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
+ if not c:isvisible() and c.first_tag then
+ c.first_tag:view_only()
end
-- This will also un-minimize
-- the client, if needed
end
end),
awful.button({ }, 2, function (c) c:kill() end),
- awful.button({ }, 3, function ()
- if instance then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({ width=250 })
- end
- end),
+ awful.button({ }, 3, client_menu_toggle_fn()),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
- if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
- if client.focus then client.focus:raise() end
end))
-for s = 1, screen.count() do
+awful.screen.connect_for_each_screen(function(s)
-- Create a promptbox for each screen
- mypromptbox[s] = awful.widget.prompt()
+ s.mypromptbox = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
- mylayoutbox[s] = awful.widget.layoutbox(s)
- mylayoutbox[s]:buttons(awful.util.table.join(
- awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
- awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
+ s.mylayoutbox = awful.widget.layoutbox(s)
+ s.mylayoutbox:buttons(gears.table.join(
+ awful.button({ }, 1, function () awful.layout.inc( 1) end),
+ awful.button({ }, 3, function () awful.layout.inc(-1) end),
+ awful.button({ }, 4, function () awful.layout.inc( 1) end),
+ awful.button({ }, 5, function () awful.layout.inc(-1) end)))
-- Create a taglist widget
- mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
+ local theme = beautiful.get()
+ s.mytaglist = awful.widget.taglist{
+ screen = s,
+ filter = awful.widget.taglist.filter.all,
+ buttons = taglist_buttons,
+ style = {
+ squares_resize = false
+ },
+ widget_template = {
+ {
+ {
+ {
+ id = 'icon_role',
+ widget = wibox.widget.imagebox,
+ },
+ layout = wibox.layout.fixed.horizontal,
+ },
+ forced_width = theme.wibar_height,
+ widget = wibox.container.place,
+ },
+ id = 'background_role',
+ widget = wibox.container.background,
+ },
+ }
-- Create a tasklist widget
- mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
+ s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
-- Create the wibox
- mywibox[s] = awful.wibox({ position = "top", screen = s })
+ s.mywibox = awful.wibar({ position = "top", screen = s })
- -- Widgets that are aligned to the left
- local left_layout = wibox.layout.fixed.horizontal()
- left_layout:add(mylauncher)
- left_layout:add(mytaglist[s])
- left_layout:add(mypromptbox[s])
-
- -- Widgets that are aligned to the right
- local right_layout = wibox.layout.fixed.horizontal()
- if s == 1 then right_layout:add(wibox.widget.systray()) end
- --right_layout:add(APW)
- right_layout:add(volwidget)
- right_layout:add(mytextclock)
- right_layout:add(mylayoutbox[s])
-
- -- Now bring it all together (with the tasklist in the middle)
- local layout = wibox.layout.align.horizontal()
- layout:set_left(left_layout)
- layout:set_middle(mytasklist[s])
- layout:set_right(right_layout)
-
- mywibox[s]:set_widget(layout)
-end
--- }}}
+ -- Add widgets to the wibox
+ s.mywibox:setup {
+ layout = wibox.layout.align.horizontal,
+ { -- Left widgets
+ layout = wibox.layout.fixed.horizontal,
+ s.mytaglist,
+ s.mypromptbox,
+ },
+ s.mytasklist, -- Middle widget
+ { -- Right widgets
+ layout = wibox.layout.fixed.horizontal,
+ mykeyboardlayout,
+ wibox.widget.systray(),
+ separator,
+ require("widgets/pomodoro"),
+ separator,
+ require("widgets/mpd_widget"),
+ separator,
+ require("widgets/volume_widget"),
+ utils.has_battery() and {
+ layout = wibox.layout.fixed.horizontal,
+ separator,
+ require("widgets/battery_widget"),
+ },
+ separator,
+ require("widgets/network_widget"),
+ separator,
+ require("widgets/calendar"),
+ s.mylayoutbox,
+ },
+ }
+end)