Ubuntu - Remap numpad hotkeys for window snap resize

439 views
Skip to first unread message

Edwin Castillo

unread,
Sep 14, 2017, 2:00:24 AM9/14/17
to autokey-users
I have an Ubuntu laptop with Autokey 0.93.10. In Ubuntu, using the hotkey "Ctrl+Alt+[NumPad]" allows you to snap the current window to a fraction of the screen (eg, "Ctrl+Alt+NP_Left" snaps the window to the left half of the screen, "Ctrl+Alt+NP_Right" snaps to the right half, "Ctrl+Alt+NP_Home" snaps to the top right quarter, "Ctrl+Alt+NP_PgDn" snaps to the bottom right quarter, etc).

I'd like to use these shortcuts, but my laptop doesn't have a NumPad. So I've tried to use Autokey to remap the arrow keys to correspond to each of the NumPad keys, but I can't figure it out. This is my failed attempt to write the script for the "Ctrl+Alt+NP_Left" remap, using the "<alt>+<ctrl>+<left>" hotkey:

keyboard.send_keys("<alt>+<ctrl>+<np_left>\n")

And so forth with the right, up and down keys. For the diagonal resize shortcuts ("Ctrl+Alt+NP_Home" and "Ctrl+Alt+NP_PgDn"), I suppose I could do a combination of "<alt>+<ctrl>+<left>+<up>" and "<alt>+<ctrl>+<right>+<down>", if it can be done.

Thanks a lot in advance for any help, even if it is to say it's not possible.

Joe

unread,
Sep 14, 2017, 2:51:27 AM9/14/17
to autoke...@googlegroups.com, Edwin Castillo
Welcome to the list, Edwin.

First, I don't know the answer.

I haven't run into this functionality (even without AutoKey) before.

I'm running kubuntu 16.04 (KDE 5.5) (autokey-qt 0.90.4) on a Toshiba
notebook that does have a numeric keypad. I tried Ctrl+Alt+NP_Left and
...NP_Home (from my keyboard) with a small window focused and nothing
happens. What am I missing? Is this specific to a non-KDE desktop
environment?

From your description, I'm *guessing* that nothing happens when you run
the phrase.

Small point: If you do get it to work, I don't see why you would want to
send a newline (\n). If it works as I suspect it should, that would do
the desktop manipulation and then send the newline to whatever was
running in the current window. This could do almost anything depending
on the state of the receiving application.

Additional generic advice:

Take a look at our problem reporting guide
https://github.com/autokey/autokey/wiki/Problem-Reporting-Guide . It has
instructions for running a trace. Generally, when AutoKey doesn't seem
to be cooperating with you, a trace will show you things from its
viewpoint which can be quite helpful.

There are several other tools for changing the behavior of your keyboard
and desktop. Once we get this much sorted, we can see if any of those
might help.

Joe

On 09/14/2017 02:00 AM, Edwin Castillo wrote:
> I have an Ubuntu laptop with *Autokey 0.93.10*. In Ubuntu, using the
> hotkey "/Ctrl+Alt+[NumPad]/" allows you to snap the current window to
> a fraction of the screen (eg, "/Ctrl+Alt+NP_Left/" snaps the window to
> the left half of the screen, "/Ctrl+Alt+NP_Right/" snaps to the right
> half, "/Ctrl+Alt+NP_Home/" snaps to the top right quarter,
> "/Ctrl+Alt+NP_PgDn/" snaps to the bottom right quarter, etc).
>
> I'd like to use these shortcuts, but *my laptop doesn't have a
> NumPad*. So I've tried to use Autokey to *remap the arrow keys to
> correspond to each of the NumPad keys*, but I can't figure it out.
> This is my failed attempt to write the script for the
> "/Ctrl+Alt+NP_Left/" remap, using the "/<alt>+<ctrl>+<left>/" hotkey:
>
> |
> keyboard.send_keys("<alt>+<ctrl>+<np_left>\n")
> |
>
> And so forth with the right, up and down keys. For the diagonal resize
> shortcuts (/"Ctrl+Alt+NP_Home"/ and "/Ctrl+Alt+NP_PgDn/"), I suppose I
> could do a combination of "/<alt>+<ctrl>+*<left>+<up>*/" and
> "/<alt>+<ctrl>+*<right>+<down>*/", if it can be done.
>
> Thanks a lot in advance for any help, even if it is to say it's not
> possible.
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Edwin Castillo

unread,
Sep 14, 2017, 4:48:11 AM9/14/17
to autokey-users
Hi Joe,

Thanks for the quick reply.

The shortcut functionality is available on the standard Ubuntu distro (which is Unity). It works as described on this video:


Now, since I don't have the NumPad on my laptop, I can't press this exact shortcut, which is why I was looking to create a hotkey to emulate "Ctrl+Alt+[NumPad]" using the arrow keys in place of the NumPad positions. And of course, I can't get Autokey to send the NumPad sequence, which is why I was looking for help.

The "\n", I must admit, I just copied from another similar script (inserting special characters) without knowing what it did, thinking it might've been necessary since I couldn't get it to work. Other than that, is there any reason why Autokey wouldn't send "<alt>+<ctrl>+<left>"? How would you go about remapping a key combination?

This is what I get from the trace output (specific where I press the keys):

2017-09-14 01:42:18,078 DEBUG - iomediator - <ctrl> pressed
2017-09-14 01:42:18,079 DEBUG - iomediator - <alt> pressed
2017-09-14 01:42:18,276 DEBUG - service - Raw key: '<left>', modifiers: ['<alt>', '<ctrl>'], Key: <left>
2017-09-14 01:42:18,276 DEBUG - service - Window visible title: 'Terminal', Window class: 'gnome-terminal-server.Gnome-terminal'
2017-09-14 01:42:18,276 INFO - service - Matched hotkey phrase/script with prompt=False
2017-09-14 01:42:18,277 DEBUG - service - Script runner executing: Script('WIN: LEFT')
2017-09-14 01:42:18,277 DEBUG - service - Ignored locking error in handle_keypress
2017-09-14 01:42:18,277 DEBUG - iomediator - Send via event interface
2017-09-14 01:42:18,280 DEBUG - interface - Send modified key: modifiers: ['<alt>', '<ctrl>'] key: <np_left>
^[[1;7D2017-09-14 01:42:18,622 DEBUG - iomediator - <ctrl> released
2017-09-14 01:42:18,622 DEBUG - iomediator - <alt> released

Joe

unread,
Sep 14, 2017, 9:02:24 AM9/14/17
to autoke...@googlegroups.com, Edwin Castillo
The trace says AutoKey did exactly what you wanted to do. That means one
of two things. 1) AutoKey lied (has a bug) or 2) (more likely) whatever
keyboard driver software there is - possibly all the way up to
gnome-terminal, thinks it knows what you want better than you do and
filtered it out somehow instead of letting it work.

I'm not particularly adept at problems like this. I have a couple of
specific suggestions and some more generic info to lead you astray. ;)

1) Try your macro/phrase in a few other windows like gedit or nano or
anything else that seems appropriate to make sure it's a generic
problem, not just with a few apps.

2) I'm not sure if or how it interacts with AutoKey, but running your
phrase/macro in an xev window *might* tell you something.

3) Once you've done 1 and 2, you might want to file an issue at
https://github.com/guoci/autokey-py3/issues . Maybe Troy, the developer,
will have some insight.

More generic stuff: (If it were me, I would do step 3 before most of the
stuff below. We have to figure out what the problem is before coming up
with fancy solutions.)

If you have any spare keys or key combos somewhere on your keyboard, you
can remap them (temporarily or permanently) to send things like <NP_Left>.

Start by looking at xmodmap and xkb. (If you're not into international
character sets, you can ignore the stuff below about "compose" - at
least to start with.)

> It would not be too difficult to make the caps lock key do the same
> thing as another key or even add a few "known" keys. The following
> issue may contain a clue as to how to do this.
>
> https://github.com/autokey/autokey/issues/44
>
> Here's a ton of stuff, courtesy of Sven, which relates to modifying
> the keyboard. I'd look at the xkb stuff first.
>
> https://help.ubuntu.com/community/ComposeKey
> http://en.wikipedia.org/wiki/Compose_key
> http://fsymbols.com/keyboard/linux/compose/
> https://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
> https://www.linux.com/learn/tutorials/769644-hacking-your-linux-keyboard-with-xkb
>
> https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions
>
> https://wiki.archlinux.org/index.php/Keyboard_configuration_in_Xorg
> https://wiki.archlinux.org/index.php/Xorg#Configuration
>
Whatever happens, please post back here so we can learn from your
experiences.

Joe

On 09/14/2017 04:48 AM, Edwin Castillo wrote:
> Hi Joe,
>
> Thanks for the quick reply.
>
> The shortcut functionality is available on the standard Ubuntu distro
> (which is Unity). It works as described on this video:
>
> https://youtu.be/cuvoTig1dt0?t=300
>
> Now, since I don't have the NumPad on my laptop, I can't press this
> exact shortcut, which is why I was looking to create a hotkey to
> emulate "/Ctrl+Alt+[NumPad]/" using the *arrow keys* in place of the
> NumPad positions. And of course, I can't get Autokey to send the
> NumPad sequence, which is why I was looking for help.
>
> The "/\n/", I must admit, I just copied from another similar script
> (inserting special characters) without knowing what it did, thinking
> it might've been necessary since I couldn't get it to work. Other than
> that, is there any reason why Autokey wouldn't send
> "/<alt>+<ctrl>+<left/>"? How would you go about remapping a key
> > an email to autokey-user...@googlegroups.com <javascript:>
> > <mailto:autokey-user...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.

Joe

unread,
Sep 14, 2017, 9:15:12 AM9/14/17
to autoke...@googlegroups.com, Edwin Castillo
I forgot to mention xdotool. It's kind of a one-thing-at-a-time analog
of AutoKey. It's a bit more work to use it, but it's very powerful once
you figure it out.

Joe

Dell Anderson

unread,
Sep 14, 2017, 1:25:17 PM9/14/17
to autoke...@googlegroups.com
Edwin,
I'm  not an expert but I did manage some interesting things with Autokey and what you are describing seems straightforward but I feel like I am missing some critical data.

What distro of Ubuntu are you using?   I know Lubuntu uses Openbox which grabs some hit keys including ALT but these can be configured in .openconfig IIRC.  Which numbered distro version?

Lastly, do you reboot after xmodmap?   I found nothing changed until I rebooted.   Autokey alone doesn't require reboot though.   

Does anything happen when you use the desired keys or does computer just sit there?

Dell

    > <mailto:autokey-users+unsubscri...@googlegroups.com <javascript:>>.

    > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-users+unsubscribe@googlegroups.com <mailto:autokey-users+unsubscri...@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-users+unsubscribe@googlegroups.com.

Edwin Castillo

unread,
Sep 21, 2017, 3:32:26 AM9/21/17
to autokey-users
I'm sorry... I'm not familiar with "xmodmap". And nothing happens when I try the hotkey combo.

I'm using Ubuntu 16.04 LTS
    > <mailto:autokey-users+unsub...@googlegroups.com <javascript:>>.

    > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com <mailto:autokey-users+unsub...@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.

Dell Anderson

unread,
Sep 21, 2017, 6:26:39 PM9/21/17
to autokey-users
Edwin,

xmodmap is a combination of two things:  A CLI (terminal) command and also a custom hidden file (.Xmodmap hidden by the '.')  file that you can create in your home directory that allows you to customize key mappings, for example to free up the Right control key to do something different.   I used it to modify my Right CTRL key and turn it into a mod key.  

If you are not sure what keys are mapped to what, you can use Xev (I had to install mine IIRC).  I'ts been a while, and I used several tricks, but as I recall, Xev allows you to see what code your keyboard & autokey are actually sending to the console so you can determine whether autokey is actually doing what you think. Due to time constraints,  I have not carefully studied all the previous posts you sent & received so perhaps you already know this.

Here's my personal experience using it (you will possibly want to compare your results and adjust for your particular situation).

I first used a CLI program called xev that opens a little GUI window which when active allows you to type any keyboard key and find out which keycode is sent by that key.  Actually, xev generates TONS of information when the xev GUI window is active, every mouse twitch sends a cavalcade of data which is very difficult to read, but what you want to look for is the 'keycode". For example, on my computer, the following excerpt from xev output pressing F4 results in keycode = 70:



This can be very useful, because it tells you the keycodes for the keys you want to use, which in turn can later be directly xmodmapped to what you want to happen.

In your case, you want to emulate the numpad keys.  If you don't have an external USB keyboard to determine those codes, here's what I found


WITH NUMLOCK OFF

Left to right, Bottom to top, including Enter, +, and - keys to the right of my numpad


KEY LABEL => KEYCODE => Xev / OS  interpretation comment


0 =>   90  => KP_Insert

.          91      KP_Delete

Enter  104    KP_Enter

1         87      KP_End

2         88      KP_Down

3         89      KP_Next

4         83      KP_Left

5         84      KP_Begin

6         85      KP_Right

+         86      KP_Add

7         79      KP_Home

8         80      KP_Up

9         81      KP_Prior (NOTE this seems odd as my 9 key is labeled "page up" but it is sending 81 "KP_Prior")


(Same as with Numlock On)

Numlock    77   Num_Lock

/               106   KP_Divide

*                63    KP_Multiply

- (minus)   82    KP_Subtract


WITH NUMLOCK ON
Left to right, Bottom to top, including Enter, +, and - keys to the right of my numpad

KEY LABEL => KEYCODE => Xev /OS interpretation comment

0  =>     90  =>  KP_0

.            91        KP_Decimal

Enter  104        KP_Enter

1           87        KP_1

2           88        KP_2

3           89        KP_3

4           83        KP_4

5           84        KP_5

6           85        KP_6

+           86        KP_Add

7           79        KP_7

8           80        KP_8

9           81        KP_9


(Same as with Numlock off)

Numlock  77     Num_Lock

/             106     KP_Divide

*               63     KP_Multiply

- (minus)  82    KP_Subtract


Other keys technically not part of numpad

but possibly not present on your keyboard:

KEY LABEL => KEYCODE => Xev / OS interpretation comment

Insert               118     Insert

Delete             119     Delete

Home             110      Home

End                115      End

PageUp         112      Prior

Page Down   117      Next


UpArrow       111 up

DownArrow  116 Down

LeftArrow      113 Left

RightArrow    114 Right



Once you have the the desired codes, you cand find out if they are being used xmodmap.  This command lists the 8 modifiers and which keys (up to 4 per modifier) are assigned to each). These will be useful in AutoKey later.


For example, I was having trouble with Autokey so I opened a terminal, typed:
xmodmap

and my original console output was:

shift       Shift_L (0x32), Shift_R (0x3e)
lock        Caps_Lock (0x42)
control   Control_L (0x25), Control_R (0x69)
mod1     Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2      Num_Lock (0x4d)
mod3
mod4     Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 I     SO_Level3_Shift (0x5c), Mode_switch (0xcb) 



As an aside, I vaguely recall some 'funkiness' as to OS interpretation of keys with regard to Mod keys, but not enough to explain here.
Basically it comes down to various degrees of compliance with the abstraction of mod keys vs Control key interpreations

I then modified this by creating a .Xmodmap hidden file in my user directory with only the following content in it:

clear mod3
keycode 74 = Hyper_R
add mod3 = Hyper_R

Explanation (as best I can recall!)
The first line clears mod3 (for good measure although I don't think mod3 had anything assigned to it to begin with)
second line assigns keycode 74 (the F8 key) Hyper_R functionality
I assign Hyper_Right functionality (now triggered by F8) back to mod3
(I know, I know, it's confusing, but the simplest way I could find to do what I needed, turn my F8 key into a modifier key.)

Now my xmodmap output has changed (changes in red) to:

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Hyper_R (0x4a)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

As you can see, the only significant changed is that I assigned meta Hyper_R functionality to the F8 key (key code 74)) so now I could use it in AutoKey as part of a key combination


If you want to share your full script I could take a look at it and see if I can get it to work with Lubuntu (although I'm not sure the shortcuts are the same as Lubuntu since I'm using LXDE).

I'm still not sure I understand why your AutoKey is not triggering the correct response, but it might be related to Xmodmap above.   Joe can probably set me straight on this because he understands all this better.

Hope this triggers some creative thoughts in you both!

best,
Dell
PS I plan to create a how to video using Lubuntu on something similar I did, but this should get you started.

Dell Anderson

unread,
Sep 21, 2017, 6:33:59 PM9/21/17
to autokey-users
PPS 
I wonder if it is something as simple as capitalization?  I noticed everything output from Xev is NP_Left etc.   You are sending <np_left>
Crazier things have happened.
OTHERWISE:  Joe's clue is what I was trying to expand on.  Please forgive if I have presumed too much shared applicability between your particular problem and mine.  They obviously are somewhat different but related in that Joe's idea of remapping might work:
>>>If you have any spare keys or key combos somewhere on your keyboard, you 
can remap them (temporarily or permanently) to send things like <NP_Left>. 

Start by looking at xmodmap and xkb. (If you're not into international 
character sets, you can ignore the stuff below about "compose" - at 
least to start with.) 


Dell Anderson

unread,
Sep 21, 2017, 6:35:44 PM9/21/17
to autokey-users
PS part 3 (sorry)

I wrong said " I used it to modify my Right CTRL key and turn it into a mod key.  "
What I actually did was simply assign mod3 (hyperkey) status to a non-hyper key (in my case, F8)


On Wednesday, September 13, 2017 at 11:00:24 PM UTC-7, Edwin Castillo wrote:

Joe

unread,
Sep 22, 2017, 3:22:07 AM9/22/17
to autoke...@googlegroups.com, Dell Anderson
Dell, thanks for this great resource post.

Joe


On 09/21/2017 06:26 PM, Dell Anderson wrote:
> Edwin,
>
> xmodmap is a combination of two things:  A CLI (terminal) command and
> also a custom hidden file (.Xmodmap hidden by the '.')  file that you
> can create in your home directory that allows you to customize key
> mappings, for example to free up the Right control key to do something
> different.   I used it to modify my Right CTRL key and turn it into a
> mod key.
>
> If you are not sure what keys are mapped to what, you can use Xev (I
> had to install mine IIRC).  I'ts been a while, and I used several
> tricks, but as I recall, Xev allows you to see what code your keyboard
> & autokey are actually sending to the console so you can determine
> whether autokey is actually doing what you think. Due to time
> constraints,  I have not carefully studied all the previous posts you
> sent & received so perhaps you already know this.
>
> Here's my personal experience using it (you will possibly want to
> compare your results and adjust for your particular situation).
>
> I first used a CLI program called *xev *that opens a little GUI window
> which when active allows you to type any keyboard key and find out
> which *keycode *is sent by that key.  Actually, *xev* generates TONS
> of information when the xev GUI window is active, every mouse twitch
> sends a cavalcade of data which is very difficult to read, but what
> you want to look for is the 'keycode". For example, on my computer,
> the following excerpt from xev output pressing F4 results in keycode = 70:
>
>
> <https://lh3.googleusercontent.com/-hBsMjQ1VpYU/WcQurulO3VI/AAAAAAAACgw/u24xAjFB_L81NRz6PYFiX_fPE0DvLuR-wCLcBGAs/s1600/Screenshot%2Bfrom%2B2017-09-21%2B14-18-02_edited.png>
>
>
> This can be very useful, because it tells you the keycodes for the
> keys you want to use, which in turn can later be directly xmodmapped
> to what you want to happen.
>
> In your case, you want to emulate the numpad keys.  If you don't have
> an external USB keyboard to determine those codes, here's what I found
>
>
> *WITH NUMLOCK OFF*
>
> Left to right, Bottom to top, including Enter, +, and - keys to the
> right of my numpad
>
>
> /KEY LABEL => KEYCODE => Xev / OS  interpretation comment/
>
>
> 0 =>   90  => KP_Insert
>
> .       91      KP_Delete
>
> Enter 104    KP_Enter
>
> 1      87      KP_End
>
> 2      88      KP_Down
>
> 3      89      KP_Next
>
> 4      83      KP_Left
>
> 5      84      KP_Begin
>
> 6      85      KP_Right
>
> +      86      KP_Add
>
> 7      79      KP_Home
>
> 8      80      KP_Up
>
> 9      81      KP_Prior (NOTE this seems odd as my 9 key is labeled
> "page up" but it is sending 81 "KP_Prior")
>
>
> /(Same as with Numlock On)/
>
> Numlock   77   Num_Lock
>
> /            106   KP_Divide
>
> *             63    KP_Multiply
>
> - (minus)   82    KP_Subtract
>
> *
> *
>
> *WITH NUMLOCK ON*
> Left to right, Bottom to top, including Enter, +, and - keys to the
> right of my numpad
>
> /KEY LABEL => KEYCODE => Xev /OS interpretation comment/
>
> 0  =>     90 =>  KP_0
>
> .            91 KP_Decimal
>
> Enter  104 KP_Enter
>
> 1           87 KP_1
>
> 2           88 KP_2
>
> 3           89 KP_3
>
> 4           83 KP_4
>
> 5           84 KP_5
>
> 6           85 KP_6
>
> +           86 KP_Add
>
> 7           79 KP_7
>
> 8           80 KP_8
>
> 9           81 KP_9
>
>
> /(Same as with Numlock off)/
>
> Numlock  77  Num_Lock
>
> /             106  KP_Divide
>
> *               63  KP_Multiply
>
> - (minus)  82 KP_Subtract
>
>
> *Other keys technically not part of numpad*,
>
> but possibly not present on your keyboard:
>
> /KEY LABEL => KEYCODE => Xev / OS interpretation comment/
>
> Insert              118     Insert
>
> Delete            119     Delete
>
> Home            110      Home
>
> End               115      End
>
> PageUp        112      Prior
>
> Page Down   117      Next
>
>
> UpArrow      111 up
>
> DownArrow 116 Down
>
> LeftArrow     113 Left
>
> RightArrow   114 Right
>
>
>
> Once you have the the desired codes, you cand find out if they are
> being used xmodmap.  This command lists the 8 modifiers and which keys
> (up to 4 per modifier) are assigned to each). These will be useful in
> AutoKey later.
>
>
> For example, I was having trouble with Autokey so I opened a terminal,
> typed:
> *xmodmap*
> *
> *
> and my original console output was:
>
> *shift       Shift_L (0x32), Shift_R (0x3e)
> lock        Caps_Lock (0x42)
> control   Control_L (0x25), Control_R (0x69)
> mod1     Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
> mod2      Num_Lock (0x4d)
> mod3
> mod4     Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
> mod5 I     SO_Level3_Shift (0x5c), Mode_switch (0xcb) *
>
>
>
> As an aside, I vaguely recall some 'funkiness' as to OS interpretation
> of keys with regard to Mod keys, but not enough to explain here.
> Basically it comes down to various degrees of compliance with the
> abstraction of*mod keys *vs *Control key* interpreations
>
> I then modified this by creating a *.Xmodmap* hidden file in my user
> directory with only the following content in it:
> *
> *
> *clear mod3*
> *keycode 74 = Hyper_R*
> *add mod3 = Hyper_R*
>
> Explanation (as best I can recall!)
> The first line clears mod3 (for good measure although I don't think
> mod3 had anything assigned to it to begin with)
> second line assigns keycode 74 (the F8 key) Hyper_R functionality
> I assign Hyper_Right functionality (now triggered by F8) back to mod3
> (I know, I know, it's confusing, but the simplest way I could find to
> do what I needed, turn my F8 key into a modifier key.)
>
> Now my*xmodmap *output has changed (changes in red) to:
>
> *shift       Shift_L (0x32),  Shift_R (0x3e)*
> *lock        Caps_Lock (0x42)*
> *control  Control_L (0x25),  Control_R (0x69)*
> *mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)*
> *mod2        Num_Lock (0x4d)*
> *mod3 Hyper_R (0x4a)*
> *mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce), 
> Hyper_L (0xcf)*
> *mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)*
>
> As you can see, the only significant changed is that I assigned meta
> Hyper_R functionality to the F8 key (key code 74)) so now I could use
> it in AutoKey as part of a key combination
>
> To learn more about .Xmodmap see
> here https://askubuntu.com/questions/93624/how-do-i-swap-left-ctrl-with-left-alt-on-my-keyboard
>
> If you want to share your full script I could take a look at it and
> see if I can get it to work with Lubuntu (although I'm not sure the
> shortcuts are the same as Lubuntu since I'm using LXDE).
>
> I'm still not sure I understand why your AutoKey is not triggering the
> correct response, but it might be related to Xmodmap above.   Joe can
> probably set me straight on this because he understands all this better.
>
> Hope this triggers some creative thoughts in you both!
>
> best,
> Dell
> PS I plan to create a how to video using Lubuntu on something similar
> I did, but this should get you started.
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.

Joe

unread,
Sep 22, 2017, 3:36:40 AM9/22/17
to autoke...@googlegroups.com, Dell Anderson
Things like have happened, but not in this case. See

https://github.com/autokey/autokey/wiki/Special-Keys

xmodmap (and lots of other stuff) is in the links I provided for the OP.

That much material takes some time to digest. I know I've only scratched
the surface of it.
I've played a bit more with xdotool (in a skirmish I had with KDE). It
also goes from very easy to opaque with almost nothing in between.

If you do publish any related videos, etc., post back here so we'll know
where to view them.

Thanks.

Joe


On 09/21/2017 06:33 PM, Dell Anderson wrote:
> PPS
> I wonder if it is something as simple as capitalization?  I noticed
> everything output from Xev is NP_Left etc.   You are sending <np_left>
> Crazier things have happened.
> OTHERWISE:  Joe's clue is what I was trying to expand on. Please
> forgive if I have presumed too much shared applicability between your
> particular problem and mine.  They obviously are somewhat different
> but related in that Joe's idea of remapping might work:
> */>>>If you have any spare keys or key combos somewhere on your
> keyboard, you
> can remap them (temporarily or permanently) to send things like
> <NP_Left>.
>
> Start by looking at xmodmap and xkb. (If you're not into international
> character sets, you can ignore the stuff below about "compose" - at
> least to start with.) /*
>
>
>
>
> On Wednesday, September 13, 2017 at 11:00:24 PM UTC-7, Edwin Castillo
> wrote:
>
> I have an Ubuntu laptop with *Autokey 0.93.10*. In Ubuntu, using
> the hotkey "/Ctrl+Alt+[NumPad]/" allows you to snap the current
> window to a fraction of the screen (eg, "/Ctrl+Alt+NP_Left/" snaps
> the window to the left half of the screen, "/Ctrl+Alt+NP_Right/"
> snaps to the right half, "/Ctrl+Alt+NP_Home/" snaps to the top
> right quarter, "/Ctrl+Alt+NP_PgDn/" snaps to the bottom right
> quarter, etc).
>
> I'd like to use these shortcuts, but *my laptop doesn't have a
> NumPad*. So I've tried to use Autokey to *remap the arrow keys to
> correspond to each of the NumPad keys*, but I can't figure it out.
> This is my failed attempt to write the script for the
> "/Ctrl+Alt+NP_Left/" remap, using the "/<alt>+<ctrl>+<left>/" hotkey:
>
> |
> keyboard.send_keys("<alt>+<ctrl>+<np_left>\n")
> |
>
> And so forth with the right, up and down keys. For the diagonal
> resize shortcuts (/"Ctrl+Alt+NP_Home"/ and "/Ctrl+Alt+NP_PgDn/"),
> I suppose I could do a combination of
> "/<alt>+<ctrl>+*<left>+<up>*/" and
> "/<alt>+<ctrl>+*<right>+<down>*/", if it can be done.
>
> Thanks a lot in advance for any help, even if it is to say it's
> not possible.
>

Dell Anderson

unread,
Oct 1, 2017, 12:10:45 AM10/1/17
to Joe, autoke...@googlegroups.com
Joe,
>>If you do publish any related videos, etc., post back here so we'll know where to view them.

OK, challenge accepted!  Thanks for the kind words of encouragement.   Took me a while to create a video (it was quite a discovery process finding all Linux based FOSS tools for screencapture, audio recording configuration, and stable video editing, but I think I succeeded.   Please excuse the length and pace.  I opted for complete start-to-finish Autokey & Function Key remapping from scratch (including installing the software) so it's a bit on the long side.  Also demo'd a cursory look at xkeycaps as well as xev and xmodmap. (I won't know if you watch it in 1.5 or 2x mode!).  Just make sure it's in HD mode.

Here's the YouTube link:

& if you prefer Vimeo, the video is also (temporarily) here until free space is needed for other videos:

Hope this helps someone else!
Feel free to comment and correct any misconceptions, uncaught errors, hints or tips.

best,
Dell



To unsubscribe from this group and stop receiving emails from it, send an email to autokey-users+unsubscribe@googlegroups.com <mailto:autokey-users+unsubscri...@googlegroups.com>.

Joe

unread,
Oct 6, 2017, 1:13:53 AM10/6/17
to Dell Anderson, autoke...@googlegroups.com
Just reviewed your new AutoKey video.

Some comments:

0) Thanks for doing this!

1) The relaxed pace is right for learning. Many videos are so fast that
I have to pause them every few seconds to absorb the details.
Overall, it's a clear presentation.

2) You probably should indicate that this is an advanced topic that the
average user will not need and should not do.

If a beginner starts remapping their keyboard, then all sorts of
unexpected things can happen which will affect their entire desktop ...

Have mercy on those of us who try to help people get out of such messes!
Changes like this are invisible and if the user neglects to mention what
they did (a fairly common occurrence), they're likely to be told to
reinstall their desktop because it's broken.

3) Along with that, if a user is advanced enough to attempt to do this
(or even to realize that it's an option), then they don't need
installation instructions.

4) I didn't know about xkeycaps. I'm going to look into it. But, it adds
nothing to your tutorial because you don't actually use it.
23 minutes is on the long side for a topic like this. Removing these
will shave a few minutes off. I'm told that the younger you are, the
lower your attention span is.

5) It would *really* help if you maximized your terminal window (and the
AutoKey window) and increased the font size/magnification.
I was unable to read the details. When I magnified the display enough to
read the details, they blurred out. I was able to follow the
presentation from what you said and because I was already familiar with
most of the pieces. My notebook is 1366x768 (720P).

Joe


On 10/01/2017 12:10 AM, Dell Anderson wrote:
> Joe,
> />>If you do publish any related videos, etc., post back here so we'll
> know where to view them./
>
> OK, challenge accepted!  Thanks for the kind words of encouragement.  
> Took me a while to create a video (it was quite a discovery process
> finding all Linux based FOSS tools for screencapture, audio recording
> configuration, and /*stable*/ video editing, but I think I
> autokey-user...@googlegroups.com
> <mailto:autokey-users%2Bunsu...@googlegroups.com>
> <mailto:autokey-user...@googlegroups.com
> <mailto:autokey-users%2Bunsu...@googlegroups.com>>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>

Dell Anderson

unread,
Oct 6, 2017, 2:11:12 AM10/6/17
to Joe, autoke...@googlegroups.com
Joe,

Thanks so much for taking the time to both watch and give such valuable and detailed feedback on my too- lengthy video!  Sometimes looking at video too long makes me blind to faults, but I definitely was uncomfortable with the length.  

TL:DR;
First step will be to remove the xkeycaps section.  It is distracting. 

But long term, if my obsessive compulsive side flares up and I were to redo the entire thing, what do you think was the most valuable part of the video (ie. what part(s) should I definitely keep either in edit or in redo??

Some possible revised outline for redo in the future (if I get some extra time):

0) clearly state goal of using Function key as modifier with AutoKey
1) clearly state this the danger of remapping keyboard involved
2) xmodmap usage (brief before & after remapping)
3) Custom .Xmodmap file content creation
4) xev demo
5) Very abbreviated demo setup Autokey

More detailed responses inline:

>>If a beginner starts remapping their keyboard, then all sorts of unexpected things can happen which will affect their entire desktop ...
Have mercy on those of us who try to help people get out of such messes!

I totally agree, including the danger or remapping the keyboard.  I had not really thought of the possibility an average user might venture into this territory but should have because I never think of myself as an advanced user.  

>>3) Along with that, if a user is advanced enough to attempt to do this (or even to realize that it's an option), then they don't need installation instructions.

Do you mean Autokey installation?  Or xmodmap configuration?   
>>4) I didn't know about xkeycaps. I'm going to look into it. But, it adds nothing to your tutorial because you don't actually use it.
23 minutes is on the long side for a topic like this. Removing these will shave a few minutes off. I'm told that the younger you are, the lower your attention span is

​Agree 100%!   I tend to ignore videos over 100%, but you know what Mark Twain said:  I would have written a shorter letter but I did not have the time!  ;-)   I might just rerecord, but in the mean time, removing the xkeycaps is a great idea.   Is there anything else that seems superfluous?   My goal for this video was to 'hide nothing' (I personal have aversion to videos where they start simple then 'something magic happens' and the goal is attained, so probably went overboard on showing every d@#$ second of configuration.   Add to this not having done it myself for a month or more.

>
​>
5) It would *really* help if you maximized your terminal window (and the AutoKey window) and increased the font size/magnification.
Good idea.  ​I will do that next time (hopefully not too long).  
I am
​ a little
 surprised that the resolution
​was ​
not as good as it should be
​ at full 720p​
.  I have the same laptop screen you do but recorded the video
​ at 1080p​
on a desktop with a 24" monitor at full 1080pHD (a standard preset). I am assuming that somehow the 1366 x 768 
​​
is
​ causing some issue with 720p​
  (
1080p ​
was overkill but
​ seems to be the new standard and​
looks crystal clear on my external monitor
​ almost indistinguishable from live monitor​
). 
 

Thanks again for the very helpful suggestions and thanks in advance for any other thoughts you have.

best,
Dell

Joe

unread,
Oct 6, 2017, 5:28:09 AM10/6/17
to Dell Anderson, autoke...@googlegroups.com
Inline.

Joe


On 10/06/2017 02:10 AM, Dell Anderson wrote:
> Joe,
>
> Thanks so much for taking the time to both watch and give such
> valuable and detailed feedback on my too- lengthy video!  Sometimes
> looking at video too long makes me blind to faults, but I definitely
> was uncomfortable with the length.
Happens to everybody - especially detail-oriented people like programmers.

We have very little help material for AutoKey and most of it is way out
of date - even for 0.90.4 - so what you are doing is very valuable.
It's way more fun to program than it is to document, but most programs
are almost useless without good documentation.

As for me, I'm paying it forward. If it wasn't for my local lug, I would
never have tried Linux (around 2003 - at least not for a few more years
- and I had already worked with Unix System 3!). If it weren't for all
the great resources on the web, I wouldn't be able to figure out 10% of
what I do now. I don't think I can ever give back as much as I have
received.
>
> TL:DR;
> First step will be to remove the xkeycaps section.  It is distracting.
>
> But long term, if my obsessive compulsive side flares up and I were to
> redo the entire thing, what do you think was the most valuable part of
> the video (ie. what part(s) should I definitely keep either in edit or
> in redo??
>
Possible motivation: If you clean it up, I will add a link to it in the
AutoKey wiki and, maybe in the autokey-py3 wiki as well.
> Some possible revised outline for redo in the future (if I get some
> extra time):
>
> 0) clearly state goal of using Function key as modifier with AutoKey
> 1) clearly state this the danger of remapping keyboard involved
Just tell them to think about what they're doing because the keyboard is
a resource common to almost everything and
<soapbox>modifying base behavior is bad practice because it bites you
when you have to use an unmodified system and it bites anybody else who
uses your system - or advises you about it because, in both cases, you
get unexpected behavior. Things that work as expected are hard enough to
manage! </soapbox>
> 2) xmodmap usage (brief before & after remapping)
This can be very brief. What you have now is fine. X.Org supports
xmodmap and stackexchange, archwiki, ...
> 3) Custom .Xmodmap file content creation
> 4) xev demo
That part is good. Just rehearse or follow your outline so you don't add
extra steps by accident.
> 5) Very abbreviated demo setup Autokey
Not necessary IMO.
>
> More detailed responses inline:
>
xmodmap is a separate utility, so you just have to show how to use it
and wave your hands or provide a link to another tutorial on it.
If you want to demo the AutoKey setup, that's a good thing - but for a
separate video - it's for a different, more general audience
(and I'll put that in the wiki(s) too.)
> >>If a beginner starts remapping their keyboard, then all sorts of
> unexpected things can happen which will affect their entire desktop ...
> Have mercy on those of us who try to help people get out of such messes!
>
> I totally agree, including the danger or remapping the keyboard.  I
> had not really thought of the possibility an average user might
> venture into this territory but should have because I never think of
> myself as an advanced user.
I hang out in a few stackexchange q&a sites. There are guys there who
are world-level experts and they still ask questions and make occasional
mistakes!

It's a matter of degree. AutoKey is simple enough to be used by people
with minimal programming backgrounds, so that's the base audience. If
they just use phrases, they don't need to know anything about programming.

Given what can be done in the macros, there's plenty of room for
advanced users too. You just have to decide who your target audience is
and tailor your presentation accordingly.

Beginners need a setup video, intermediate to advanced users don't.
Beginners always need warnings about dangerous things. More advanced
users need them less frequently and they can be more terse because they
already understand the implications of stepping outside the box and know
that they need a good reason for doing so.

Long ago and far away, I was using Wordmaster on CP/M. End of file was
indicated by a NUL character. If you inserted a NUL character in the
body of your text, a little reverse video word appeared on the screen
for a moment that said something like "stupid". That was sufficient
because it was usually one-trial negative conditioning! You only lost
the rest of your content that way once. If you ever started to do it
again, you'd hit undo pretty quickly.
>
> >>3) Along with that, if a user is advanced enough to attempt to do
> this (or even to realize that it's an option), then they don't need
> installation instructions.
>
> Do you mean Autokey installation?  Or xmodmap configuration?
AutoKey installation. We can assume they know how to do this, but not
that they are familiar with xmodmap.
Keith wrote an extensive AutoKey installation guide and I helped edit
it. It's out of date now, but I've patched it a little bit.
> >>4) I didn't know about xkeycaps. I'm going to look into it. But, it
> adds nothing to your tutorial because you don't actually use it.
> 23 minutes is on the long side for a topic like this. Removing these
> will shave a few minutes off. I'm told that the younger you are, the
> lower your attention span is
>
> ​Agree 100%!   I tend to ignore videos over 100%, but you know what
> Mark Twain said:  I would have written a shorter letter but I did not
> have the time!  ;-)
LOL. Having edited some of our documentation and other things, I know
how hard it is to be both concise and clear.
>    I might just rerecord, but in the mean time, removing the xkeycaps
> is a great idea.   Is there anything else that seems superfluous?   My
> goal for this video was to 'hide nothing' (I personal have aversion to
> videos where they start simple then 'something magic happens' and the
> goal is attained, so probably went overboard on showing every d@#$
> second of configuration.   Add to this not having done it myself for a
> month or more.
>
That's the beauty of hypertext/links. You can always link to more
details which you or, better yet, someone else has already written.
If you try to put it all in one place, it ends up being distracting or
forbidding.

I think your audience for this already knows what they're doing and just
wants to know how do I do this.
It may actually be beneficial if a new user gets there and realizes that
they are in over their head.
We want everybody to learn and grow, but a command of the basics must
always come before delving into advanced topics.
> >
> ​>
> 5) It would *really* help if you maximized your terminal window (and
> the AutoKey window) and increased the font size/magnification.
> Good idea.  ​I will do that next time (hopefully not too long).
> I am
> ​ a little
>  surprised that the resolution
> ​was ​
> not as good as it should be
> ​ at full 720p​
> .  I have the same laptop screen you do but recorded the video
> ​ at 1080p​
> on a desktop with a 24" monitor at full 1080pHD (a standard preset). I
> am assuming that somehow the 1366 x 768
> ​​
> is
> ​ causing some issue with 720p​
>   (
> 1080p ​
> was overkill but
> ​ seems to be the new standard and​
> looks crystal clear on my external monitor
> ​ almost indistinguishable from live monitor​
> ).
I wear reading glasses to start with. I really can't read small white
type on a black background especially when it's 5 point or less. The
whole terminal screen in your demo is 3x5" or less.
> <mailto:jos...@main.nc.us> <mailto:jos...@main.nc.us
> autokey-user...@googlegroups.com
> <mailto:autokey-users%2Bunsu...@googlegroups.com>
>         <mailto:autokey-users%2Bunsu...@googlegroups.com
> <mailto:autokey-users%252Buns...@googlegroups.com>>
>         <mailto:autokey-user...@googlegroups.com
> <mailto:autokey-users%2Bunsu...@googlegroups.com>
>         <mailto:autokey-users%2Bunsu...@googlegroups.com
> <mailto:autokey-users%252Buns...@googlegroups.com>>>.

Dell Anderson

unread,
Oct 7, 2017, 2:49:04 PM10/7/17
to Joe, autoke...@googlegroups.com
Joe, thanks again for the great advice.

I've tried to implement as much of your suggestions as I knew how.   I'm much happier with the (still imperfect) result.  It's hot off the press now available for viewing at https://youtu.be/pDrPr4PcytY   if anyone is interested.   Basically remade from scratch focusing only on Xmodmap key remapping of a single Function key to use as an AutoKey modifier.  Hope it helps someone.  It was much easier to create the second video than the first!  Feel free to comment, suggest improvements, etc.  I may do a simple 'installation of AutoKey' video later.  

best,
Dell

Reply all
Reply to author
Forward
0 new messages