Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

18 May 2019

Finally Stable Caps to Ctrl Mapping

Over the years, I have tried so many ways on Linux to map Caps Lock to Ctrl:
  • Xorg config (that didn't work on a tty console)
  • Inputrc (really weird rules that depended on initial state)
  • Gnome keyboard config
Finally there is a stable way to remap Caps Lock to Ctrl.  It is relatively simple and it is at the lowest level in Linux.

Thanks to this page for all the details: https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes but it took a lot of effort to parse out what actually needed to be done.

Here is a distilled version:

0) Make sure Caps Lock is OFF

1) Create the following file:

/etc/udev/hwdb.d/10-caps-modifier.hwdb
---
evdev:atkbd:dmi:*            # built-in keyboard: match all AT keyboards for now
  KEYBOARD_KEY_3a=leftctrl   # bind capslock to leftctrl

2) Run  the following command:

$ systemd-hwdb update

3) Run the following command to make the remapping take immediate effect:

$ udevadm trigger

This was tested on Ubuntu 18.04.2 LTS running Xfce.  The remapping works great in tty consoles, and the X input system.

04 March 2013

xcl: X Clipboard Helper

As a pragmatic command-line user, I just found a new way to easily interact with the clipboard.

Yes, yes, I knew about 'xclip' before now -- but it was just way too hard to use because it made me type (and remember) lots of options for simple clipboard operations.

Introducing 'xcl', a simple, helpful wrapper around 'xclip':

This uses a little-known trick from bash (really from the 'test' or '[' builtin), which allows me to detect whether a file descriptor is attached to a live terminal.

Hope this is helpful to you.

27 November 2012

X Clipboard Cleaner

Ever copy/paste from a web page and have the web page's style mess up the document you are pasting into?

That's pretty common for me.

Chrome/Firefox both preserve HTML style when copying text to the clipboard, and the following are common targets:

  • email
  • HTML-enabled editor widget
  • word processor document
My old process was:
  1. copy text/link from web page
  2. open up a text editor
  3. paste inside the text editor
  4. copy the same text again, this time without the style
  5. paste into the target location
I finally got sick of doing this manually all the time, so I wrote a script and put it in my app launcher bar.

Here is a gist with a script you can download: