From e55ea2b0d53e6acab97c98dfb6c0e7cb91bb8186 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 9 Sep 2021 16:44:55 -0700 Subject: [PATCH] doc: Support multiple screens in the "default look" template. --- tests/examples/shims/_default_look.lua | 165 +++++++++++++------------ 1 file changed, 88 insertions(+), 77 deletions(-) diff --git a/tests/examples/shims/_default_look.lua b/tests/examples/shims/_default_look.lua index c67927f7..3b0cee76 100644 --- a/tests/examples/shims/_default_look.lua +++ b/tests/examples/shims/_default_look.lua @@ -3,87 +3,98 @@ local wibox = require("wibox") local beautiful = require("beautiful") require("_date") --- Create the same number of tags as the default config -awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) -local mykeyboardlayout = awful.widget.keyboardlayout() -local mytextclock = wibox.widget.textclock() -local mylayoutbox = awful.widget.layoutbox(screen[1]) -local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) -local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) -local mypromptbox = wibox.widget.textbox("") +local ret = nil -local wb = awful.wibar { position = "top" } -wb:setup { - layout = wibox.layout.align.horizontal, - { - layout = wibox.layout.fixed.horizontal, - { - image = beautiful.awesome_icon, - widget = wibox.widget.imagebox, - }, - mytaglist, - mypromptbox, - }, - mytasklist, - { - layout = wibox.layout.fixed.horizontal, - mykeyboardlayout, - { - image = beautiful.awesome_icon, - widget = wibox.widget.imagebox, - }, - { - image = beautiful.awesome_icon, - widget = wibox.widget.imagebox, - }, - { - image = beautiful.awesome_icon, - widget = wibox.widget.imagebox, - }, - mytextclock, - mylayoutbox, - }, -} +for i = 1, screen.count() do + local s = screen[i] + -- Create the same number of tags as the default config + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + local mykeyboardlayout = awful.widget.keyboardlayout() + local mytextclock = wibox.widget.textclock() + local mylayoutbox = awful.widget.layoutbox(s) + local mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, {}) + local mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, {}) + local mypromptbox = wibox.widget.textbox("") -client.connect_signal("request::titlebars", function(c) - local top_titlebar = awful.titlebar(c, { - height = 20, - bg_normal = beautiful.bg_normal, - }) - - top_titlebar : setup { - { -- Left - awful.titlebar.widget.iconwidget(c), - layout = wibox.layout.fixed.horizontal - }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c) - }, - layout = wibox.layout.flex.horizontal - }, - { -- Right - awful.titlebar.widget.floatingbutton (c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton (c), - awful.titlebar.widget.ontopbutton (c), - awful.titlebar.widget.closebutton (c), - layout = wibox.layout.fixed.horizontal() - }, - layout = wibox.layout.align.horizontal + local wb = awful.wibar { + position = "top", + screen = s } -end) + + wb:setup { + layout = wibox.layout.align.horizontal, + { + layout = wibox.layout.fixed.horizontal, + { + image = beautiful.awesome_icon, + widget = wibox.widget.imagebox, + }, + mytaglist, + mypromptbox, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + { + image = beautiful.awesome_icon, + widget = wibox.widget.imagebox, + }, + { + image = beautiful.awesome_icon, + widget = wibox.widget.imagebox, + }, + { + image = beautiful.awesome_icon, + widget = wibox.widget.imagebox, + }, + mytextclock, + mylayoutbox, + }, + } + + client.connect_signal("request::titlebars", function(c) + local top_titlebar = awful.titlebar(c, { + height = 20, + bg_normal = beautiful.bg_normal, + }) + + top_titlebar : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } + end) + + ret = ret or { + mykeyboardlayout = mykeyboardlayout, + mytextclock = mytextclock , + mylayoutbox = mylayoutbox , + mytaglist = mytaglist , + mytasklist = mytasklist , + mywibox = wb , + mypromptbox = mypromptbox , + } +end require("gears.timer").run_delayed_calls_now() -return { - mykeyboardlayout = mykeyboardlayout, - mytextclock = mytextclock , - mylayoutbox = mylayoutbox , - mytaglist = mytaglist , - mytasklist = mytasklist , - mywibox = wb , - mypromptbox = mypromptbox , -} +return ret