From c3be117610f464a1d4b8c5e8fee16c1e10a69da9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Mar 2017 15:49:55 +0100 Subject: [PATCH] Use only_on_screen in the declarative layout example This is a follow-up to 052cda939b8a5ce1. Expressions like 's.index == 2' and 's == screen.primary' might work at first. However, they are not "dynamic": If screens are added/removed or the primary screen changes, then the widgets are not updated to follow this. Instead, the example now uses the new awful.widget.only_on_screen container which provides the needed dynamic behaviour. This is arguably "the real fix" to #1562 and #1565. Signed-off-by: Uli Schlachter --- docs/03-declarative-layout.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/03-declarative-layout.md b/docs/03-declarative-layout.md index d00ae253..c48ee98a 100644 --- a/docs/03-declarative-layout.md +++ b/docs/03-declarative-layout.md @@ -41,8 +41,16 @@ configurable rules. Code: s.mywibox : setup { - s == screen.primary and my_first_widget, -- Only display on primary screen - s.index == 2 and my_second_widget, -- Only display on screen 2 + { + layout = awful.widget.only_on_screen, + screen = "primary", -- Only display on primary screen + my_first_widget, + }, + { + layout = awful.widget.only_on_screen, + screen = 2, -- Only display on screen 2 + my_second_widget, + }, my_third_widget, -- Displayed on all screens { -- Add a background color/pattern for my_fourth_widget my_fourth_widget, @@ -53,10 +61,8 @@ Code: } -In this example `s == screen.primary` is an inline expression. In the default -`rc.lua`, there is an `s` variable represent to define the current screen. Any -Lua logic expression can be used as long as it returns a valid widget or a -declarative layout, or `nil`. +This examples uses the `awful.widget.only_on_screen` container to display +widgets only on some screens. ### Composite widgets