#[solved] Compose sequence in macros

1 messages · Page 1 of 1 (latest)

hallow grotto
#

I want to use Compose-o-a to output å. Here is my macro:

    macros {
        aa: aa {
            compatible = "zmk,behavior-macro";
            #binding-cells = <0>;
            bindings
                = <&macro_tap &kp K_MENU &kp O &kp A>
                ;
        };
    };

As @kindred yoke explained to me, composeis not part of the USB HID standard. So far, I'm happy only supporting Linux, and Xorg. So I setup my X to interpret menu as compose:

setxkbmap -option compose:menu

There are a few "menus" in keys.h, I've tried K_MENU, C_MENU, K_APPLICATION. Nothing works.

I've tested it with AltGr instead of "menu", on my laptop keyboard, and the 'å' comes out alright.

My reason for choosing "menu" is that it's what I've been using in kmonad, and I cannot see a reason my it wouldn't work here. There is a limited choice in X as to what to rebind composeto.

What is "menu", is it just missing from keys.h, what did I miss?

kindred yoke
#

Altgr is right GUI

hallow grotto
#

But I don't think I can map F22 to compose in X:

$ grep "compose:" /usr/share/X11/xkb/rules/base.lst
  compose:ralt         Right Alt
  compose:lwin         Left Win
  compose:lwin-altgr   3rd level of Left Win
  compose:rwin         Right Win
  compose:rwin-altgr   3rd level of Right Win
  compose:menu         Menu
  compose:menu-altgr   3rd level of Menu
  compose:lctrl        Left Ctrl
  compose:lctrl-altgr  3rd level of Left Ctrl
  compose:rctrl        Right Ctrl
  compose:rctrl-altgr  3rd level of Right Ctrl
  compose:caps         Caps Lock
  compose:caps-altgr   3rd level of Caps Lock
  compose:102          The "&lt; &gt;" key
  compose:102-altgr    3rd level of the "&lt; &gt;" key
  compose:paus         Pause
  compose:prsc         PrtSc
  compose:sclk         Scroll Lock
#

I could use scroll lock, but not managing to get menu to work got me curious.

#

Alright, sclk worked! Does that mean that whatever this menu is (apparently according to kmonad it's not the same as the contextual menu) just missing from keys.h?

warped epoch
hallow grotto
#

But onto my next question, is there a away to "unpress" a potential shift in a macro? My issue is this: sclk-o-a outputs 'å' alright. But if I use that macro while holding shift, I get Ⓐ instead. That is because the 'o' in the macro is shifted as well as the 'a'. I would like to force the 'o' in the macro to be lowercase.

#

I wonder if I could use a morph-mod for that, and two macros (one for å, one for Å). And not forwarding the shift with keep-mods

hallow grotto
#

mmm, these are my macros:

    macros {
        lower_aa: lower_aa {
            compatible = "zmk,behavior-macro";
            #binding-cells = <0>;
            bindings
                = <&macro_tap &kp CMP &kp O &kp A>
                ;
        };
        cap_aa: cap_aa {
            compatible = "zmk,behavior-macro";
            #binding-cells = <0>;
            bindings
                = <&macro_tap &kp CMP &kp O>
                , <&macro_press &kp LSHFT>
                , <&macro_tap &kp A>
                , <&macro_release &kp LSHFT>
                ;
        };
    };
#

and my mod-morph:

#
    behaviors {
        aa_mm: aa_mod_morph {
            compatible = "zmk,behavior-mod-morph";
            #binding-cells = <0>;
            bindings = <&lower_aa>, <&cap_aa>;
            mods = <(MOD_LSFT|MOD_RSFT)>;
        };
    };
#

I was under the impression that the modifiers in the mod-morph would not follow to the called macro, but I still get Ⓐ (the 'o' is capitalized, from me holding left shift)

warped epoch
#

Does the same happen if you hold down the mod morph key until the macro is finished?

hallow grotto
#

#

yes 🙂

warped epoch
#

Do you use macos with Karabiner elements?

hallow grotto
#

No, this is on Linux, x11. Using sclk as compose.

hallow grotto
#

I was thinking about ditching the mod-morph method, and use a combo for shift-v-p, that would trigger my Å. I would need to implement it for both shift keys, and that would break for Caps Lock, it would put requirements on press timing. Or I could use another modifier than 'v' to get capitalized compose characters (that's how I solved it in kmonad, which had this exact same issue).

#

but as a programmer, I would have liked the ability to write macros with steps such as saving the current state of shift, temporarily disabling it for the 'o', then restoring it for the 'a'.

#

like a &shift_override 0.

kindred yoke
#

Personally I find mixing ZMK with external tools to just make it much more confusing and like to have it all targeting a layout which has everything I need natively

hallow grotto
#

I'll try to explain:

#
  1. Why do I want my OS layout to be US:
    1.1 the Swedish layout is very programmer unfriendly. / is on shift+7. {} are on AltGr+7 and AltGr+0. Backslash is also stupid, backtick and tilde are deadkeys... but somehow we have symbols like § and ¤ and ½ at prime places.
    1.2 the relation between a key's character and the same key's shifted character is not the same in SE layout as US layout. Shifted , is ;. I want the US shifted key relations.
#
  1. Why I want compose sequences:
    I am still writing in Swedish in mails, chat, ... Så I need thö charactärs Å, Ä, Ö. These are obviously not available in the OS US layout. Also occasionally writing in French, so I want é, è, ç, ... The route I've taken this far is compose sequences. Unfortunately, as you pointed out, compose is not part of the USB HID standard, so it has to go through another key, and I need X to translate that other key to compose.
#

what I've been doing, is an international layer triggered by v, that has all these characters' compose sequences. Kmonad made this easy, it was builtin and å in my config resulted in the correct compose sequence.

#

The problem arises when I want a capital version of these characters. If v+p results in the compose sequence for å, then shift+v+p should result in the compose sequence for Å, right?

#

The thing is that with shift+v+p shifts all the keypresses in the compose sequence!

#

Instead of getting the required compose o A, the sequence becomes compose O A, and I get 'Ⓐ' instead of 'Å'.

#

So what I'm trying to achieve, is to output compose o a on v+p, and compose o A on shift+v+p.

hallow grotto
# kindred yoke Tbh I'm a bit confused about your exact requirements. But you can check for shif...

There's something I don't get about mod-morphs. The doc says that without keep-mods, the modifiers are not sent along with the morphed keycode. Yet with this mod-morph, I still get 'o' without shift, and 'O' with shift. What am I missing? Why does the shift modifier seem to be sent with the morphed key?

        unshft_o: unshifted_o {
            compatible = "zmk,behavior-mod-morph";
            #binding-cells = <0>;
            bindings = <&kp O>, <&kp O>;
            mods = <(MOD_LSFT|MOD_RSFT)>;
        };
#

oh wait a second. I use the shift key on my laptop keyboard (I only have 8 keys on my proof of concept board). Is that it? The shift needs to be on the board??

#

O M G

#

The unshifted o above, which you proposed @kindred yoke , works just fine.

#

so sorry

hallow grotto
#

Solution:

    macros {
        aa: aa {
            compatible = "zmk,behavior-macro";
            #binding-cells = <0>;
            bindings
                = <&macro_tap &kp CMP &unshft_o &kp A>
                ;
        };
    };
    behaviors {
        // Unshifted chars are useful to send compose sequences, so that
        // holding shift while sending the sequence does not affect that
        // character.
        unshft_o: unshifted_o {
            compatible = "zmk,behavior-mod-morph";
            #binding-cells = <0>;
            bindings = <&kp O>, <&kp O>;
            mods = <(MOD_LSFT|MOD_RSFT)>;
        };
    };

&aa results in å while unshifted, and in Å while shifted (as long as the shift key is on that board, and not a laptop keyboard).

#

[solved] Compose sequence in macros

#

This probably doesn't work for Caps Lock, but I'll live.

#

Thanks all!

kindred yoke
#

Unfortunately caps word doesn't interact nicely with mod morph

hallow grotto
#

I only use Caps Lock when I name C macros, I don't expect to use non-ASCII characters in C source any time soon 🙂