Use only_on_screen in the declarative layout example

This is a follow-up to 052cda939b. 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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-03-04 15:49:55 +01:00
parent 0bd29ae1e9
commit c3be117610
1 changed files with 12 additions and 6 deletions

View File

@ -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