Discussion:
Key sequences?
(too old to reply)
Rui Carmo
2013-05-27 12:12:46 UTC
Permalink
Hi there,

I was wondering if anyone knows how to implement key sequences - i.e.,
pressing "Mod+a" then "b" in sequence rather than pressing "Mod+a" and
binding that sequence to an action.

I need to do this to be able to use a limited keyboard, and even though the
modality of it might be weird, it's actually quite similar to using screen
or tmux (in which the Cmd+A or Cmd+B key puts you into control mode).

Regards,

R.
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtile-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Tom Dickson-Hunt
2013-05-27 12:31:15 UTC
Permalink
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=x-beenthere:date:from:to:subject:message-id:references:mime-version
:in-reply-to:user-agent:x-original-sender
:x-original-authentication-results:reply-to:precedence:mailing-list
:list-id:x-google-group-id:list-post:list-help:list-archive:sender
:list-subscribe:list-unsubscribe:content-type:content-disposition;
bh=NqLJdNwjNtOn/8j7bBcIqGD6BDimMpefU21F9KoB0iQ=;
b=pJALU52PL2k1wo5ABvltdf8QyrJunkHo26gOICsmTM1bVsoJpo4Y1rdG+QfAUhUB4b
wrmgBA0uywm+88afEvT0NlhPMR6ltAQldNaOZPgCt0bwZ418Rd4mNriAbNbkyZepjxAa
+6m3y9rHdaDbRipuP0gJslUTAgFj6l+nvCHq3fHmFzrX/phnaYOz88r0ois1gKoeqoFl
rvr0xz+dwRBkOY/Io7z0K2Kfg06bvWYeizDUb03keFNo7ZHaRDDK5qQ5JGRDuTLdt1Wv
tdjEP2YDdGnYTPBqPALygzjK19jTn4MC5GVMhqTK/EET+2j8dLQYQ6k+t1gaIQLCPCRs

X-Received: by 10.50.73.196 with SMTP id n4mr956918igv.3.1369658719639;
Mon, 27 May 2013 05:45:19 -0700 (PDT)
X-BeenThere: qtile-***@googlegroups.com
Received: by 10.50.117.36 with SMTP id kb4ls1961128igb.11.gmail; Mon, 27 May
2013 05:45:19 -0700 (PDT)
X-Received: by 10.42.70.132 with SMTP id f4mr20177872icj.15.1369658719190;
Mon, 27 May 2013 05:45:19 -0700 (PDT)
Received: by 10.50.22.210 with SMTP id g18msigf;
Mon, 27 May 2013 05:30:14 -0700 (PDT)
X-Received: by 10.43.44.194 with SMTP id uh2mr19905067icb.23.1369657814009;
Mon, 27 May 2013 05:30:14 -0700 (PDT)
Received: from mail-ie0-x22f.google.com (mail-ie0-x22f.google.com [2607:f8b0:4001:c03::22f])
by gmr-mx.google.com with ESMTPS id b5si1163124igx.3.2013.05.27.05.30.13
for <qtile-***@googlegroups.com>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Mon, 27 May 2013 05:30:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of ***@gmail.com designates 2607:f8b0:4001:c03::22f as permitted sender) client-ip=2607:f8b0:4001:c03::22f;
Received: by mail-ie0-f175.google.com with SMTP id tp5so1627702ieb.6
for <qtile-***@googlegroups.com>; Mon, 27 May 2013 05:30:13 -0700 (PDT)
X-Received: by 10.50.132.103 with SMTP id ot7mr3085704igb.99.1369657813488;
Mon, 27 May 2013 05:30:13 -0700 (PDT)
Received: from breitenfeld (c-71-196-152-173.hsd1.co.comcast.net. [71.196.152.173])
by mx.google.com with ESMTPSA id d9sm12914557igr.4.2013.05.27.05.30.11
for <qtile-***@googlegroups.com>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Mon, 27 May 2013 05:30:12 -0700 (PDT)
In-Reply-To: <695b7867-abe9-4b5a-b1b0-***@googlegroups.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Original-Sender: ***@gmail.com
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass
(google.com: domain of ***@gmail.com designates
2607:f8b0:4001:c03::22f as permitted sender) smtp.mail=***@gmail.com;
dkim=pass header.i=@gmail.com
Precedence: list
Mailing-list: list qtile-***@googlegroups.com; contact qtile-dev+***@googlegroups.com
List-ID: <qtile-dev.googlegroups.com>
X-Google-Group-Id: 1003572083451
List-Post: <http://groups.google.com/group/qtile-dev/post?hl=und>, <mailto:qtile-***@googlegroups.com>
List-Help: <http://groups.google.com/support/?hl=und>, <mailto:qtile-dev+***@googlegroups.com>
List-Archive: <http://groups.google.com/group/qtile-dev?hl=und>
Sender: qtile-***@googlegroups.com
List-Subscribe: <http://groups.google.com/group/qtile-dev/subscribe?hl=und>, <mailto:qtile-dev+***@googlegroups.com>
List-Unsubscribe: <http://groups.google.com/group/qtile-dev/subscribe?hl=und>, <mailto:googlegroups-manage+1003572083451+***@googlegroups.com>
Content-Disposition: inline
Archived-At: <http://permalink.gmane.org/gmane.comp.window-managers.qtile/206>

I've got some rather kludgy config.py code that does this; it's a
little bit troublesome to use, due to limitations of the code base
that I'm too lazy to have worked around as yet, but it's functional.
rv = dict.get(self, k, d)
qt.keyMap = qt.old_keymap
del qt.old_keymap
qt.grabKeys()
return rv
qt.old_keymap = qt.keyMap
qt.keyMap = ReplaceMap()
qt.mapKey(i)
qt.mapKey(Key(["control"], "g", lazy.spawn("true"))) # this is a decent no-op, could be better
qt.grabKeys()
return sm_closure
sm = [ Key([], "b", some_action()) ]
keys = [ Key(["control"], "t", lazy.function(make_submap(sm))) ]
In this example, you'd add the first key of your sequence to 'keys',
with the action being the result of make_submap called on the
submapping; then add the second to the submapping itself, with the
action being whatever you want. This works recursively, so for a
three-key sequence you'd call make_submap() twice. make_submap()
returns a closure, so it is correct to call it in the context of
config.py, rather than passing it to lazy.function. If you want
multiple actions in the same submap, just add them all to sm.

Hope this helps.
Hi there,
I was wondering if anyone knows how to implement key sequences - i.e.,
pressing "Mod+a" then "b" in sequence rather than pressing "Mod+a" and
binding that sequence to an action.
I need to do this to be able to use a limited keyboard, and even though the
modality of it might be weird, it's actually quite similar to using screen
or tmux (in which the Cmd+A or Cmd+B key puts you into control mode).
Regards,
R.
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
Tom Hunt

# strace -p `pgrep -d " -p " sshd`
Craig Barnes
2013-05-27 13:21:08 UTC
Permalink
I have considered this possibility myself as an emacs user ;-).

I think they we could use the prompt widget (or a variation of it) to
implement a key combination command list functionality.

I may have a crack at it tonight.

The only pitfall I see at the moment is applications (like firefox)
that seem to steal focus from the prompt widget, if anyone has ideas
on addressing this I would be very grateful.

Craig
Post by Tom Dickson-Hunt
I've got some rather kludgy config.py code that does this; it's a
little bit troublesome to use, due to limitations of the code base
that I'm too lazy to have worked around as yet, but it's functional.
rv = dict.get(self, k, d)
qt.keyMap = qt.old_keymap
del qt.old_keymap
qt.grabKeys()
return rv
qt.old_keymap = qt.keyMap
qt.keyMap = ReplaceMap()
qt.mapKey(i)
qt.mapKey(Key(["control"], "g", lazy.spawn("true"))) # this is a decent no-op, could be better
qt.grabKeys()
return sm_closure
sm = [ Key([], "b", some_action()) ]
keys = [ Key(["control"], "t", lazy.function(make_submap(sm))) ]
In this example, you'd add the first key of your sequence to 'keys',
with the action being the result of make_submap called on the
submapping; then add the second to the submapping itself, with the
action being whatever you want. This works recursively, so for a
three-key sequence you'd call make_submap() twice. make_submap()
returns a closure, so it is correct to call it in the context of
config.py, rather than passing it to lazy.function. If you want
multiple actions in the same submap, just add them all to sm.
Hope this helps.
Hi there,
I was wondering if anyone knows how to implement key sequences - i.e.,
pressing "Mod+a" then "b" in sequence rather than pressing "Mod+a" and
binding that sequence to an action.
I need to do this to be able to use a limited keyboard, and even though the
modality of it might be weird, it's actually quite similar to using screen
or tmux (in which the Cmd+A or Cmd+B key puts you into control mode).
Regards,
R.
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
Tom Hunt
# strace -p `pgrep -d " -p " sshd`
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
Craig
Björn Lindström
2013-05-27 13:25:53 UTC
Permalink
Post by Craig Barnes
The only pitfall I see at the moment is applications (like firefox)
that seem to steal focus from the prompt widget, if anyone has ideas
on addressing this I would be very grateful.
I know I never had trouble with this while using modal keybindings in
ratpoison, with Firefox or any other app apart from certain
virtualizers, so it's doable.
Rui Carmo
2013-05-27 13:43:39 UTC
Permalink
Post by Craig Barnes
I have considered this possibility myself as an emacs user ;-).
I think they we could use the prompt widget (or a variation of it) to
implement a key combination command list functionality.
That's interesting too. I'm a heavy tmux user, so I rely on its prompt as
well for seldom used commands and as a visible prompt (literally)/reminder
of the sequence I'm typing.

Anyway, I was drafting something like this:

{ "Ctrl" : { 'b': {'%': split_vertical(), '"': split_horizontal() } } }

...as a way to emulate tmux bindings (the split_ functions would
essentially create a new terminal window, since I have a screen solely for
those and another for chromium)

R.
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtile-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Rui Carmo
2013-05-27 13:36:24 UTC
Permalink
Thanks, that's interesting - I hadn't considered doing that sort of thing,
and it ties in nicely with my idea of using a multi-level dict for
representing the transitions inside the config - I'm setting up a new box
over the coming days, so I'll play around with that notion after I'm
settled in.
Post by Tom Dickson-Hunt
I've got some rather kludgy config.py code that does this; it's a
little bit troublesome to use, due to limitations of the code base
that I'm too lazy to have worked around as yet, but it's functional.
rv = dict.get(self, k, d)
qt.keyMap = qt.old_keymap
del qt.old_keymap
qt.grabKeys()
return rv
qt.old_keymap = qt.keyMap
qt.keyMap = ReplaceMap()
qt.mapKey(i)
qt.mapKey(Key(["control"], "g", lazy.spawn("true"))) # this is a
decent no-op, could be better
qt.grabKeys()
return sm_closure
sm = [ Key([], "b", some_action()) ]
keys = [ Key(["control"], "t", lazy.function(make_submap(sm))) ]
In this example, you'd add the first key of your sequence to 'keys',
with the action being the result of make_submap called on the
submapping; then add the second to the submapping itself, with the
action being whatever you want. This works recursively, so for a
three-key sequence you'd call make_submap() twice. make_submap()
returns a closure, so it is correct to call it in the context of
config.py, rather than passing it to lazy.function. If you want
multiple actions in the same submap, just add them all to sm.
Hope this helps.
Hi there,
I was wondering if anyone knows how to implement key sequences - i.e.,
pressing "Mod+a" then "b" in sequence rather than pressing "Mod+a" and
binding that sequence to an action.
I need to do this to be able to use a limited keyboard, and even though
the
modality of it might be weird, it's actually quite similar to using
screen
or tmux (in which the Cmd+A or Cmd+B key puts you into control mode).
Regards,
R.
--
You received this message because you are subscribed to the Google
Groups "qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/groups/opt_out.
--
Tom Hunt
# strace -p `pgrep -d " -p " sshd`
--
You received this message because you are subscribed to the Google Groups "qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtile-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...