raboof / notion

Tiling tabbed window manager
https://notionwm.net/
GNU Lesser General Public License v2.1
268 stars 63 forks source link

mod_xkb/xkbion: Per-window num/caps/scroll-lock? #352

Open mjf opened 1 year ago

mjf commented 1 year ago

Hello, I tried to configure xkbion for num/caps/scroll-lock so that it works similarly to keyboard layout switching and the lock was on/off per program window in X.org:

xkbion_set {
    {
        name = "     ",
        hint = "xkb_num_off",
        action = function() mod_xkb.lock_modifiers(1, 0) end,
    },
    {
        name = " NUM ",
        hint = "xkb_num_on",
        action = function() mod_xkb.lock_modifiers(1, 2) end,
    },
    key = "Num_Lock",
    statusname = "xkb_num",
    atomname = "XKBION_NUM",
}

xkbion_set {
    {
        name = "      ",
        hint = "xkb_caps_off",
        action = function() mod_xkb.lock_modifiers(2, 0) end,
    },
    {
        name = " CAPS ",
        hint = "xkb_caps_on",
        action = function() mod_xkb.lock_modifiers(2, 2) end,
    },
    key = "Caps_Lock",
    statusname = "xkb_caps",
    atomname = "XKBION_CAPS",
}

xkbion_set {
    {
        name = "     ",
        hint = "xkb_scroll_off",
        action = function() mod_xkb.lock_modifiers(3, 0) end,
    },
    {
        name = " SCR ",
        hint = "xkb_scroll_on",
        action = function() mod_xkb.lock_modifiers(3, 2) end,
    },
    key = "Scroll_Lock",
    statusname = "xkb_scroll",
    atomname = "XKBION_SCROLL",
}

It does not behave as expected. The locks are on/off globally and the indicator are actually per window so they does not reflect the real state. How to fix this, please? It looks like the mod_xkb.lock_group() works somehow differently to mod_xkb.lock_modifiers() or I perhaps do something completely wrong.


OT: This is how I configured my keyboard layout switching which works per window:

xkbion_set {
    {
        name = "     ",
        hint = "xkb_group_0",
        action = function() mod_xkbevents.lock_group(0) end,
    },
    {
        name = " CZE ",
        hint = "xkb_group_1",
        action = function() mod_xkbevents.lock_group(1) end,
    },
    key = "Shift+ISO_Next_Group",
    statusname = "xkb_group",
    atomname = "XKBION_GROUP",
}

To clarify more further, I like to switch keyboard layouts using L_Shift+R_Shift (which is ISO_Next_Group in xev(1) output) and this was the only way I could achieve it to somewhat work with xkbion. But it's wrong, I think. If somebody has some idea how to get it really working (still there are some issues, see below), it would be splendid and very appreciated too! Thanks.

To keep keyboard layouts and lock states per window is excellent feature and it is one of the greatest features I can imagine for window manager. By the way, it would be even greater if I could, for example, tag some set of windows and switch keyboard layouts and lock states for them or if I could do it per frame etc. I think such functionality should be part of the Notion's core to handle it really properly (there are some issues with empty scratchpad for example etc). Also language and lock state indicators would be nice to have on tabs, I think.