On 02.04.2012 06:32, Anurag Priyam wrote:
[...]
+-- local matcher = function (c)<br/>
+-- return awful.rules.match(c, {class = 'URxvt'})<br/>
+-- end<br/>
+-- awful.client.run_or_raise(cmd, matcher)
+-- end);
+--</code>
+function run_or_raise(cmd, matcher, merge)
+ local clients = capi.client.get(s)
This 's' is falling out of thin air? Didn't you mean to have that as an argument
to this function? (Or just always as nil?)
Copy paste error from awful.client.cycle :P.
Oh. Looking forward to the patch. :P
+ local findex = util.table.hasitem(clients, capi.client.focus) or 1
+ local start = util.cycle(#clients, findex + 1)
+
+ for c in cycle(matcher, start) do
If you use 's' above to calculate the index, you should pass in 's' here, too.
Also, I didn't know we had such a function, nice find.
Huh? I added that function only few days back, specifically for this.
How can you forget it so soon?
You are overestimating my memory. I came back from vacation, saw lots of patches
on the mailing list waiting for me and started merging.
> Btw, I just realized that I had made
a mistake in naming it cycle: there is another function with the same
name (around line 387) that swaps clients in a cyclic fashion. Why is
it needed?
Because c:swap(other_c) with two clients which aren't next to each other doesn't
necessarily have the expected effect. However, since most people call
awful.client.swap.byidx() only with an argument of 1 or -1, that function likely
doesn't get much use.
> Maybe we should call my function 'iterate'?
Yeah, I guess so. Yet another patch to write.
+ jumpto(c, merge)
+ return
+ end
+
+ -- client not found, spawn it
+ util.spawn(cmd)
I wonder if this should be turned into a callback instead? Well, at first I was
thinking about someone needing spawn_with_shell, then I thought about that.
I don't think we need the flexibility provided by a callback here.
Hm, on second thought (actually, third) I don't think that 'spawn_with_shell'
thingie is a valid use case and if someone asks for it, he will get told to use
bash -c.
Actually, let's make it make it spawn_with_shell instead: better than
documenting or answering on the ML a thousand times that one can use
'bash -c'. And we just found a case in Benjamin's mail later in this
thread.
I don't think so. See below.
Benjamin wrote:
I use spawn_with_shell to control mpd by making keyboard shortcuts for mpc
commands in
> rc.lua. Just using spawn makes the mouse cursor change to it's loading state.
Is there
> any way to work around this or does using bash -c stop this from
happening(I'm not at
> my computer at the moment so I can't test it)?
This sounds more like startup notification (@jd: Why do we have sn? :-/).
The reason that spawn_with_shell() makes this go away is that it always passes
in "false" for the startup_notification parameter while spawn() defaults to true.
@Benjamin:
So the "Real Fix"(tm) for this would awful.util.spawn("mpc next", false) instead
of just awful.util.spawn("mpc next").
And now this means that this no longer is a question of "spawn or
spawn_with_shell?", but that we have to worry about startup notification, too...
On the other hand, calling run_or_raise() for mpc commands doesn't make much
sense.
Uli
--
To unsubscribe, send mail to [email protected].