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

Full-featured alternative to xcape #122

Open
rafaeln opened this issue May 31, 2020 · 4 comments
Open

Full-featured alternative to xcape #122

rafaeln opened this issue May 31, 2020 · 4 comments

Comments

@rafaeln
Copy link

rafaeln commented May 31, 2020

I stopped using xcape a while ago because it wasn't working anymore in my system and I recently found out about dual-function-keys. It allows me to do all I was doing before with xcape and a little bit more. In particular, I've been able to map Space to AltGr when pressed alongside other keys and to Space when tapped, then I mapped AltGr to Meta when pressed alongside other keys and to Backspace when tapped. One feature it has which xcape doesn't is I can tap the Space key twice to get repeated Spaces, or the AltGr twice to get multiple Backspaces. Under Ubuntu 18.04 I am required to compile dual-function-keys, but the process was mostly painless and the instructions given in the repo were flawless.

@zeorin
Copy link

zeorin commented Jun 25, 2020

@rafaeln
Copy link
Author

rafaeln commented Jun 25, 2020

I actually use both caps2esc as well as dual-function-keys. They are all plugins to the interception framework, which by the way you also need to compile. There is also a third interesting plugin, space2meta, which I now don't use anymore. If you follow along the README.md on each of the projects' github page you can figure out how to set up your system to suit your desires. As an example, my recipe that works on my Ubuntu 18.04 boxes is the following, which is not meant to be copied and pasted to anyone's terminal, not even mine, since there is meta-code in there such as which is not going to make any sense to bash. Anyways, what I have been able to achieve is: caps lock gives me escape when tapped and ctrl when chorded, space gives me space when tapped and altgr when chorded, right alt gives me backspace when tapped and meta when chorded, right shift gives me > when tapped and shift when chorded and left shift gives me < when tapped and shift when chorded. Also, the part concerning right and left shift only works out this way if I'm using my personalized Dvorak keyboard layout. If I use querty us, I get _ and + instead of < and >.

sudo apt install libudev-dev libyaml-cpp-dev libevdev-dev cmake
cd
mkdir src
cd src
git clone https://gitlab.com/interception/linux/tools
git clone https://gitlab.com/interception/linux/plugins/caps2esc
git clone https://gitlab.com/interception/linux/plugins/dual-function-keys
for dir in tools caps2esc ; do
  cd $dir
  mkdir build
  cd build
  cmake ..
  make
  sudo make install
  cd ../..
done
cd dual-function-keys
make && sudo make install
sudo su
cat > /etc/udevmon.yaml
- JOB: "intercept -g $DEVNODE | caps2esc | dual-function-keys -c /home/rafael/.dual-function-keys.yaml | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_SPACE, KEY_RIGHTALT, KEY_LEFTSHIFT, KEY_RIGHTSHIFT]
<ctrl-d>
cat > /etc/systemd/system/udevmon.service
[Unit]
Description=udevmon
Wants=systemd-udev-settle.service
After=systemd-udev-settle.service

[Service]
ExecStart=/usr/bin/nice -n -20 /usr/local/bin/udevmon -c /etc/udevmon.yaml

[Install]
WantedBy=multi-user.target
<ctrl-d>
cat > /home/rafael/.dual-function-keys.yaml
TIMING:
  TAP_MILLISEC: 200
  DOUBLE_TAP_MILLISEC: 150

MAPPINGS:
  - KEY: KEY_SPACE
    TAP: KEY_SPACE
    HOLD: KEY_RIGHTALT
  - KEY: KEY_RIGHTALT
    TAP: KEY_BACKSPACE
    HOLD: KEY_RIGHTMETA
  - KEY: KEY_LEFTSHIFT
    TAP: [ KEY_LEFTSHIFT, KEY_MINUS , ]
    HOLD: KEY_LEFTSHIFT
  - KEY: KEY_RIGHTSHIFT
    TAP: [ KEY_RIGHTSHIFT, KEY_EQUAL , ]
    HOLD: KEY_RIGHTSHIFT
<ctrl-d>
sudo systemctl enable --now udevmon

@bbatsov
Copy link

bbatsov commented Jul 6, 2020

FYI - I wrote a short article on setting up dual-function-keys https://emacsredux.com/blog/2020/07/05/remap-enter-to-control-in-gnu-linux-2020-edition/

@pataquets
Copy link

Thank you everyone for the information.
Just adding KMonad which can already do this and much more, although it requires more configuration.
Going further with the 'space as control' use-case, I've successfully implemented home row mods.
Just my 2c.

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

No branches or pull requests

4 participants