On 01/13/2011 03:12 AM, Adrian C. wrote:
> On Wed, 12 Jan 2011, Torsten Wagner wrote:
>
>> Applying an awful.rule with a property tags[2][2] fails for Xephyr but
>> works for my dual screen on the "real" system.
>
> Don't hard code the number of screens. Use 'screen.count()' instead of
> the maximum number.
>
> Don't write code to make assumptions about the screen number either...
> then you can have 1 or 4 screens and your rc.lua work the same way.
>
Hi Adrian,
thanks for mailing
the problem in that particularity case is already given in the shipped
rc.lua.
Mainly these few lines (completely stripped down to the basic point)
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
...
-- Set Firefox to always map on tags number 2 of screen 2.
{ rule = { class = "Firefox" },
properties = { tag = tags[2][2] } },
As you see I set Firefox to screen 2 tag 2. This actually creates the
error in Xephyr. To avoid hard coding at that point is perfectly
possible chaining it to tag = tags[screen.count()][2] but might become a
bit difficult to read or unpredictable if you share your rc.lua between
different systems with different number of screens, e.g. how to refer to
screen 2 out of 3 screens screen.count()-1 fails for single screen
set-ups. Sure I could wrap around a lot of if clauses but this makes
thinks even more ugly. Maybe a function which returns at all time valid
screens is helpful. E.g. screen.count() would give highest screen
number. screen.count(-1) returns the the screen count decremented by one
but not less then 1. Making this accessible for both sides by
introducing screen.max and screen.min would avoid any index overflow
Just an idea
Totti
--
To unsubscribe, send mail to [email protected].