diff --git a/rc.lua b/rc.lua index 905e911..156fb4a 100644 --- a/rc.lua +++ b/rc.lua @@ -33,6 +33,7 @@ tags.setup() -- {{{ widgets widgets = require("widgets") awful.screen.connect_for_each_screen(function(s) + widgets.dynamic_taskbar(s) widgets(s).left( { widgets.screennum(s), diff --git a/widgets.lua b/widgets.lua index eb42a7e..1eeba6c 100644 --- a/widgets.lua +++ b/widgets.lua @@ -223,6 +223,68 @@ function widgets.battery(s) return combined_bats end +local tasklist_buttons = gears.table.join( + awful.button({ }, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal("request::activate", "tasklist", {raise = true}) + end + end), + awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end), + awful.button({ }, 4, function() awful.client.focus.byidx(1) end), + awful.button({ }, 5, function() awful.client.focus.byidx(-1) end)) + +-- display a taskbar +-- `when` is a function taking the current screen, that is called on the given signal, and should return true if the +-- taskbar should be shown. +-- If signal and when are not given, the taskbar will be visible on tags with "max" layout +function widgets.dynamic_taskbar(s, signal, when) + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + style = { + shape_border_width = 2, + bg_focus = beautiful.bg_focus, + shape_border_color = beautiful.border_focus, + shape = gears.shape.powerline, + spacing = -s.dpi / 8, + }, + widget_template = { + { + { + { + { id = 'icon_role', + widget = wibox.widget.imagebox, }, + margins = 2, + widget = wibox.container.margin, + }, + { id = 'text_role', + widget = wibox.widget.textbox, }, + layout = wibox.layout.fixed.horizontal, + }, + left = 20, + right = 15, + widget = wibox.container.margin + }, + id = 'background_role', + widget = wibox.container.background, + }, + } + s.taskbar = awful.wibar({ + position = "top", + screen = s, + opacity = 0.8, + height = math.floor(s.dpi / 4), + widget = s.mytasklist + }) + + condition = when or function(s) return awful.layout.get(s).name == "max" end + s:connect_signal(signal or "tag::history::update", function() + s.taskbar.visible = condition(s) + end) +end + -- name is ignored and there for backwards compatibility. will simply update all -- widgets registered with vicious function widgets.update(name)