Coder Social home page Coder Social logo

capsesc's Introduction

remaps caps lock to escape through a user-space keyboard driver. this should make it behave as escape even in programs that use the keyboard scan codes to handle key presses such as games.

I made this because I got tired of having to press actual ESC in some games and virtual machines which would then trigger caps lock because of setxkbmap -option caps:escape .

based on my stupidlayers project.

usage

use evtest to figure out which /dev/input/event* device is your keyboard. for me it's /dev/input/event3

gcc main.c -o capsesc
sudo ./capsesc /dev/input/event3

if you run this by hand on the keyboard that gets captured you might end up with the enter key getting stuck from missing the release event. just press enter again to stop it

ideally you want a udev rule that automatically runs capsesc when the keyboard is plugged in, here's an example for void linux (assumes you copied capsesc to /usr/bin)

note that the rules.d directory might be different in other distros

sudo tee /usr/lib/udev/rules.d/30-capsesc.rules << "EOF"
ACTION=="add", \
KERNEL=="event[0-9]*", \
ATTRS{name}=="SONiX USB DEVICE", \
RUN+="/bin/sh -c 'echo /usr/bin/capsesc /dev/input/%k | at now'"
EOF

sudo xbps-install at
sudo ln -s /etc/sv/at /var/service
sudo sv start at
sudo udevadm control --reload
sudo udevadm control --reload-rules

you can also just make a script that finds the device and run it in your xinitrc or something, but it won't stick if you unplug the keyboard

example of finding a device by name (what I have in my xinitrc):

sudo killall capsesc
for x in /dev/input/event*; do
  devname=$(cat $(echo $x | sed 's|dev|sys/class|g')/device/name)
  if [ "$devname" = "SONiX USB DEVICE" ]; then
    sudo capsesc $x &
    break
  fi
done

keep in mind that if you put this in .xinitrc you must have no password required on sudo

capsesc's People

Contributors

francesco149 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.