Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow capslock and swapescape #50

Closed
binamkayastha opened this issue Mar 6, 2020 · 5 comments
Closed

Allow capslock and swapescape #50

binamkayastha opened this issue Mar 6, 2020 · 5 comments
Labels
good first issue Good for newcomers

Comments

@binamkayastha
Copy link

binamkayastha commented Mar 6, 2020

Amazing application!
The only really annoy thing thing is that swapescape no longer works:
setxkbmap -option caps:swapescape

I think this has to do with how setxkbmap actually works, but I was wondering if there was a way to:
A) avoid conflicts with setxkbmap
B) allows us to swap capslock and escape key through kinto (I've tried mucking around in the user_config.json but to no avail)

@rbreaves
Copy link
Owner

rbreaves commented Mar 6, 2020

Thanks & for which keyboard type? Windows and Mac will likely need the same or similar xkb option added, but Chromebooks would need a different config, at least I think they will. Below I posted a solution that I know works on Windows and Mac style keyboards, but I am not sure about Chromebooks.

@rbreaves
Copy link
Owner

rbreaves commented Mar 6, 2020

The latest commit now includes the capslock and escape swap option.. I've actually been wanting to apply it any ways. I am not going to update the setup installer just yet - and until I do that I won't be mentioning it in the release notes or incrementing the release number.

7e67693

How you apply is like the following, after the Kinto install that you have already done you will not be editing your user_config.json file at all, but the xkb files rather in your user profile.

What you'll need to do.

To quickly summarize though, just append "+mac_gui(swapescape)" to your ~/.xkb/keymap/mac_gui and mac_term files under the options section so that xkbcomp will apply it via the Kintox11 app.

  1. Bring down the latest master
  2. Copy ./.xkb/symbols/mac_gui
# root of the kinto master install directory
cp ./.xkb/symbols/mac_gui ~/.xkb/symbols/mac_gui
  1. Edit your keymap files (aka appending +mac_gui(swapescape) )
    vi ~/.xkb/keymap/kbd.mac.gui
    Change
xkb_keymap {
...
	xkb_symbols   { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)"	};
...
};

to

xkb_keymap {
...
	xkb_symbols   { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)+mac_gui(swapescape)"	};
...
};

Do the samething with term.
vi ~/.xkb/keymap/kbd.mac.term

You can do the browser files too if you want.. probably don't really need to though.

Next time you change from a gui to term app the changes will be applied, if not then something syntactically went wrong. Can test that with the run command in the user_config.json or something like

setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY
# or
setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY

Also what I did for the commit, so you or others can potentially import additional options.

  1. Pull the option(s) you want out of the source file(s).
    cd /usr/share/X11/xkb/symbols/ & find the file
    or
    vi usr/share/X11/xkb/symbols/capslock
  2. Extract
...
hidden partial modifier_keys
xkb_symbols "swapescape" {
    key <CAPS> { [ Escape ] };
    key <ESC>  { [ Caps_Lock ] };
};
...
  1. Added the partial to the mac_gui file (could also go into term, but in reality the term keymap can also reference mac_gui and in this case I let it be so).
    vi ~/.xkb/symbols/mac_gui
    Add partial anywhere in file (this was done in the latest commit.

@rbreaves rbreaves closed this as completed Mar 6, 2020
rbreaves referenced this issue Mar 6, 2020
- Added capslock swap option to mac_gui
@binamkayastha
Copy link
Author

Oh my gosh you're a beast! Thank you so much, it worked for me.
I have a windows keyboard, and don't own a chromebook so I can't check if it works there :(

The amount of mental relief that this program gives me is absolutely phenomenal.

@raicem
Copy link

raicem commented Jun 18, 2020

Hi! Thank for this amazing tool @rbreaves. Makes my life so much easier.

Just wanted to document how to swap capslock and esc after upgrading to the latest version with xkeysnail for dummies like me.

If your old capslock and esc configuration was in xkb, it will not work now that you are using xkeysnail. Therefore you have to update your xkeysnail configuration. Luckily, it's very easy. This configuration lives in the ~/.config/kinto/kinto.py file. You can take a look at how to configure this config file from here and here.

If you just want to swap capslock and esc, here is what I added to my kinto.py config file.

https://gist.github.com/raicem/9991bd6c0b4e4590e4167ff72df2b870

This just swaps it. You can also do things like, if the capslock is pressed and released it behaves like esc but if you hold capslock button it behaves like a normal capslock key. I saw that option here: https://gist.github.com/ponimas/6c39c66232be04d0e421a9d054db648d#file-xkeysnail-py-L21

@rbreaves
Copy link
Owner

I plan to add a wizard of some kind in the near future that will step people through setting up individual modifiers manually (if they want to) or have the script auto-detect and guess the proper layout. After either option I plan to ask the user if they'd like to re-assign the capslock key to another function.

Only thing I am not 100% sure about is whether this will be terminal based, GUI or possibly both. I have done some ground work on a terminal based wizard that uses symbols for keys and the spacebar and emojis that actually looks pretty decent. I accidentally merged into master even, so it could be previewed by just running ./keycheck.py - it will not actually set or change anything it was just me laying out how I would want to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants