Quoting Uli Schlachter (2013-12-02 22:57:58)
> Hi,
> 
> On 02.12.2013 22:18, Stanislav Ochotnicky wrote:
> > First my use case (perhaps someone will suggest a different way to deal with
> > this):
> > I use dynamic tagging facilities in awesome (and tyrranical). I have
> > configuration for most applications that I use but I often connect to 
> > several
> > hosts and for each I create a separate tag so that I don't mess up.
> > 
> > Now the issue is that when I disconnect my laptop from docking station, 
> > awesome
> > restarts due to XRandR change and all the consoles and apps without specific
> > rules end up on the first tag.
> > 
> > I came up with a possible solution:
> >     * For each client awesome would set custom X property[1]
> >     * On restart awesome would look at that custom property and it would
> >       override whatever rules were configured
> > 
> > There are possible caveats but I'd say this might still be useful.
> > 
> > Is this perhaps something that someone else has already implemented? 
> > Couldn't
> > find anything in the archives. Ideally this would be done in the library 
> > code,
> > but as PoC I might just do a custom configuration
> > 
> > [1] xprop -f WM_AWESOME_TAGS 8s -set WM_AWESOME_TAGS tag1,tag2
> 
> Such a property (almost) already exists and is called _NET_WM_DESKTOP. It is
> used for saving the first (and only the first, this is the "almost" part) tag
> that a client is attached to (mostly because EWMH demands this).

Ah, I knew I read something about that before...

> After parsing the config, the C code goes through all already-existing clients
> and manages them (thus creates client objects for them and call the manage
> signal). Before emiting the manage hook, the C code checks if the client has 
> the
> _NET_WM_DESKTOP property set and tags it with the appropriate tag. This is 
> done
> in the following C code:
> 
>     reply = xcb_get_property_reply(globalconf.connection, c0, NULL);
>     if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
>     {
>         desktop = *(uint32_t *) data;
>         if(desktop == -1)
>             c->sticky = true;
>         else if (desktop >= 0 && desktop < globalconf.tags.len)
>             for(int i = 0; i < globalconf.tags.len; i++)
>                 if(desktop == i)
>                 {
>                     luaA_object_push(globalconf.L, globalconf.tags.tab[i]);
>                     tag_client(c);
>                 }
>                 else
>                     untag_client(c, globalconf.tags.tab[i]);
>         else
>             /* Value out of bounds, just give it the first tag */
>             if (globalconf.tags.len > 0)
>             {
>                 luaA_object_push(globalconf.L, globalconf.tags.tab[0]);
>                 tag_client(c);
>             }
>     }
> 
> This does work with the default config. Now why doesn't it work with your 
> config?

I know why (now!) :-) It's because tyrannical sets up awesome so it doesn't
actually create the tag unless there's a client that belongs to it.

In other words the condition "desktop < globalconf.tags.len" will most likely
never be true. And then there's the fact that order of tags in tyrannical is not
really static so there's no easy mapping between cardinal number in
_NET_WM_DESKTOP and the tag name in tyrannical config. Ergo...

> > I use dynamic tagging facilities in awesome (and tyrranical).
> 
> After your config was parsed, there is only a single tag (at least I guess 
> so).
> Thus, the above code cannot tag the client appropriately.
> 
While my original suggestion would probably solve my issue it might be a bit too
heavy-handed (and hacky).

I am now considering a completely different approach. I'll keep the 10 static
tags with few (basic consoles, web, irc/chat) being constant and the rest being
renamed on the fly depending on the application that is being run on them. With
some hooks and a bit of configuration I should be able to automate this.

Reasons for the above approach: For example I use digikam, darktable or gimp but
not every day. But when I do I always run them on an exclusive tag. Same thing
is true for a lot of other tools. So it doesn't make sense to always keep
"graphics" tag around for me.

> I hope this clears up the current state. Feel free to come up with suggestions
> on how to improve this.

Thanks for quick reply. I don't think it makes sense to complicate core awesome
codebase by introducing custom X property. It *would* be nice if completely full
dynamic tagging would be easily possible but that's not really a discussion for
this thread :-)

-- 
Stanislav Ochotnicky

PGP: 7B087241
jabber: [email protected]

--
To unsubscribe, send mail to [email protected].

Reply via email to