Number Pad Emulation

27 views
Skip to first unread message

Alex Becker

unread,
Apr 12, 2024, 7:41:44 AMApr 12
to qtile-dev
Hello all!
Bit of an odd request, but hear me out.  I am attempting to "emulate" a numpad on a keyboard that does not have one.  Effectively, I want to be able to map a box of nine keys on my keyboard to act as a number pad when a modifier is held down.

For example, using control + shift as a modified I would map the "box" of keys around the J key to act as a numberpad: yui -> 789, jkl -> 456, nm, -> 123.  I was able to accomplish this on my Windows work laptop fairly easily using AutoHotkey, but I have not yet been able to accomplish the same on my personal Arch Linux box with Qitle.  I have tried something like this:

    Key(['control', 'shift'], "j", lazy.spawn('xdotool key KP_Begin'))

but without success.  Any ideas?
Thanks!
Alex

Tycho Andersen

unread,
Apr 12, 2024, 11:00:38 AMApr 12
to qtil...@googlegroups.com
Why not `xdotool key 4` here? Then it's control+shift that activates
this keypad mode, and "j" in this case maps to 4.

If you want to do something to put it in "keypad mode" (so you don't
have to continuously hold ctrl+shift or whatever), I think you can
probably use KeyChords to accomplish this? Not sure.

Tycho

Alex Becker

unread,
Apr 12, 2024, 11:06:14 AMApr 12
to qtil...@googlegroups.com
Tycho

Thanks for the KeyChords idea, I'll have to check that out.  Having a separate keyboard "mode" for numpad and whatever other macros I can scheme up could have a lot of benefit

I think my main issue was with the xdotool component.  The command works as intended when I run it from a standalone terminal, but for whatever reason it doesn't type the input on my screen when I map it out in Qtile.  Without knowing how exactly everything is set up, I'm guessing the output of the xdotool command is going to some internal shell/process rather than my session.  Just a guess

Thanks!
Alex

--
You received this message because you are subscribed to a topic in the Google Groups "qtile-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qtile-dev/f3EhN0Wr0NA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qtile-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qtile-dev/ZhlMjTxZ//VyYWBN%40tycho.pizza.

Tycho Andersen

unread,
Apr 12, 2024, 2:52:25 PMApr 12
to qtil...@googlegroups.com
On Fri, Apr 12, 2024 at 10:05:59AM -0500, Alex Becker wrote:
> Tycho
>
> Thanks for the KeyChords idea, I'll have to check that out. Having a
> separate keyboard "mode" for numpad and whatever other macros I can scheme
> up could have a lot of benefit
>
> I think my main issue was with the xdotool component. The command works as
> intended when I run it from a standalone terminal, but for whatever reason
> it doesn't type the input on my screen when I map it out in Qtile. Without
> knowing how exactly everything is set up, I'm guessing the output of the
> xdotool command is going to some internal shell/process rather than my
> session. Just a guess

It should go to the screen that is currently highlighted. xdotool
doesn't print anything to its stdout/err by default, so it mostly
doesn't matter where that goes (qtile hooks stdout/err to /dev/null
anyway when it spawns things).

Tycho

Alex Becker

unread,
Apr 12, 2024, 4:56:56 PMApr 12
to qtile-dev
Here's what I have in my config.  I have tried both with and without shell=True, but it does not seem to want to write the output of xdotool to whatever window I have highlighted.  Any ideas?

Key(["control", "shift"], "j", lazy.spawn("xdotool key 4")),

Thanks!
Alex

Kai Stian Olstad

unread,
Apr 12, 2024, 5:35:49 PMApr 12
to qtil...@googlegroups.com
On 12.04.2024 22:56, Alex Becker wrote:
> Here's what I have in my config. I have tried both with and without
> shell=True, but it does not seem to want to write the output of xdotool
> to
> whatever window I have highlighted. Any ideas?
>
> Key(["control", "shift"], "j", lazy.spawn("xdotool key 4")),

xdotool is sending key 4 while you still have control, shift and j
pressed.
If you use "xdotool sleep 0.2 key 4" it will work if you let go of
control, shift and j before 0.2 second have elapsed.
But this is not practical solution if you are going to press several num
pad key consecutive.

--
Kai Stian Olstad

Tycho Andersen

unread,
Apr 12, 2024, 6:01:26 PMApr 12
to 'Kai Stian Olstad' via qtile-dev
Oh, duh. Great point. Another option would be to compile your own
layout via xkbcomp. I have an example where I remap capslock here:

https://github.com/qtile/qtile-examples/blob/master/tych0/xkb/symbols/tycho

you could maybe do a similar hack and load it in your ~/.xsession like
I do.

Tycho

acbecker27

unread,
Apr 29, 2024, 10:18:32 PMApr 29
to qtil...@googlegroups.com
Thank you all for the suggestions! Apologies for the late response, got
a little busy with life and forgot about this "project". I am not
familiar with xkbcomp, but that sounds like a promising approach (and
an interesting program to add to the tool belt). I'll check it out.

Thanks again!
Alex
> --
> You received this message because you are subscribed to a topic in the Google Groups "qtile-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/qtile-dev/f3EhN0Wr0NA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to qtile-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/qtile-dev/ZhmvL5ao6hWqtVzQ%40tycho.pizza.
Reply all
Reply to author
Forward
0 new messages