Author Topic: Remapping CAPS+number to F1-10  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

Offline maricn

  • Thread Starter
  • Posts: 5
Remapping CAPS+number to F1-10
« on: Thu, 23 January 2020, 09:46:22 »
Hi everyone, I'm looking into 60% keyboards, but for my daily use I need F-keys. I go nuts when I change layouts and shortcuts, so I want the mod applied on system level. I currently have:

xmodmap: CAPS_LOCK mapped into ISO_Level3_Shift
xkb: i directly edited /usr/share/X11/xkb/symbols/us (I know, refactoring is coming up) - there I have different functions for some keys (vim arrows and a couple more)

What I tried is to extend my xkb layout to add FK1 to FK9 on higher shift levels on numbers (AE01-AE10). But that doesn't really work.

Anyone has an idea how to proceed with systemwide software approach? Thanks!

Offline DALExSNAIL

  • The User Formerly Known as 'Formerly DudeSnail'
  • * Esteemed Elder
  • Posts: 1500
  • Location: Port Wentworth, GA
  • 𝖋𝖚𝖈𝖐 𝖆𝖑𝖕𝖘
Re: Remapping CAPS+number to F1-10
« Reply #1 on: Thu, 23 January 2020, 10:54:35 »
Was planning to pop in and suggest Autohotkey, but just found out it still doesn't support linux somehow?  :confused:

Anyway, sorry for the false hope when you see this as having a reply

Offline maricn

  • Thread Starter
  • Posts: 5
Re: Remapping CAPS+number to F1-10
« Reply #2 on: Fri, 24 January 2020, 06:38:13 »
Was planning to pop in and suggest Autohotkey, but just found out it still doesn't support linux somehow?  :confused:

Anyway, sorry for the false hope when you see this as having a reply

Yeah, there's no autohotkey afaik, and all similar projects seem out of date and abandoned to my knowledge.

For the reference, I had the requested setup with Karabiner on OSX with this kind of config:
Code: [Select]
{
  "title": "Map (cl|fn) + number keys to function keys (rev 2)",
  "rules": [
    {
      "description": "Map fn + number keys to their corresponding function keys (rev 1)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "1",
            "modifiers": {
              "mandatory": [
                "fn"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f1",
              "modifiers": [
                "fn"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "2",
            "modifiers": {
              "mandatory": [
                "fn"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f2",
              "modifiers": [
                "fn"
              ]
            }
          ]
        } //, ...
      ]
    },
    {
      "description": "Map CL + number keys to their corresponding function keys (rev 1)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "1",
            "modifiers": {
              "mandatory": [
                "caps_lock"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f1",
              "modifiers": [
                "fn"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "2",
            "modifiers": {
              "mandatory": [
                "caps_lock"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f2",
              "modifiers": [
                "fn"
              ]
            }
          ]
        } //, ...
      ]
    },
    {
      "description": "Map fn + number keys to their corresponding media control keys (rev 2)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "1",
            "modifiers": {
              "mandatory": [
                "fn"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f1"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "2",
            "modifiers": {
              "mandatory": [
                "fn"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "f2"
            }
          ]
        } //, ...
      ]
    }
  ]
}

And that's what I would like to replicate on my debian (minus the dedicated "fn" key which doesn't have its own keycode in Appleless world).

Offline Tom_Kazansky

  • Posts: 409
  • Location: Vietnam
  • Oblivion Knight
Re: Remapping CAPS+number to F1-10
« Reply #3 on: Sat, 25 January 2020, 22:44:07 »
which board have you looked into?
I recommend a board that's compatible with QMK (maybe DZ60) as QMK let you remapping whatever you want. <= this is a solution on firmware level.
I don't like the software-level solution very much as you lose the keymap when the software is unavailable. (example: BIOS screen)

Offline maricn

  • Thread Starter
  • Posts: 5
Re: Remapping CAPS+number to F1-10
« Reply #4 on: Fri, 31 January 2020, 08:02:26 »
Yes, I've been looking into QMK boards, however, my work computer is a laptop, and for convenience purposes, I'd like to have the same mappings on its keyboard - so I don't have to drag a keyboard with me when I want to do some beanbag typing for 30 mins. I even plan to replace its Thinkpad X1C7 ISO with ANSI keyboard just so I don't have to cycle among different muscle memory modes.

In general, I want to find a way to use all my computers in pretty similar way, without leaving home row much and sharing same keybindings and shortcuts. And those F-buttons are just too damn far away. :)

Offline maricn

  • Thread Starter
  • Posts: 5
Re: Remapping CAPS+number to F1-10
« Reply #5 on: Fri, 31 January 2020, 08:15:20 »
OK, I just realized the correct xkb solution. I was trying out to map into different codes and FK1..12, but those are not F-row keys.

The solution with xkb is to map like so:
Code: [Select]
    key <AE01> { [   1, exclam, F1, F1 ] };
    key <AE02> { [   2, at, F2, F2 ] };
    key <AE03> { [   3, numbersign, F3, F3] };
    key <AE04> { [   4, dollar, F4, F4] };
    key <AE05> { [   5, percent, F5, F5] };
    key <AE06> { [   6, asciicircum, F6, F6] };
    key <AE07> { [   7, ampersand, F7, F7] };
    key <AE08> { [   8, asterisk, F8, F8] };
    key <AE09> { [   9, parenleft, F9, F9] };
    key <AE10> { [   0, parenright, KP_Home, KP_Home]};

And to add ISO_Level3_Shift code. In my case I use CAPS_LOCK for that and set it up in xmodmap:
Code: [Select]
nikola@work-x1c-mx19 ~ (master) » cat ~/.Xmodmap             
! remove Caps Lock
clear lock
! add ISO_Level3_Shift
keycode 66 = ISO_Level3_Shift

! change PrtSc
keycode 107 = Menu NoSymbol Menu

Hope someone finds that helpful!