Saturday, November 06, 2021

Remap keys on Ubuntu keyboard.

 I finally found the right way to remap keys in Ubuntu. 

This only works for later versions of udev so check your version.

> udevadm --version

Should be 240+

> sudo systemd-hwdb update   # if it's not

First find the keyboard to remap

> sudo evtest

pick the keyboard by event id. Note the id (say it's 4)

press keys you want to remap and note the 'value' on the MSC_SCAN line on the key you want to change

press the key you want to map to and note the KEY_XXXX code

We will need the modalias, so 
> cat /sys/class/input/event4/device/modalias

Now you need to make a file
> sudo gedit  /etc/udev/hwdb.d/10-my-modifiers.hwdb 

Here is mine:

evdev:input:b0011v0001p0001*
 KEYBOARD_KEY_db=leftalt
 KEYBOARD_KEY_38=leftmeta


The format needs to be exact. There is one space before KEYBOARD_XXX.
The key codes are lowercase.

So now you need to load the config
> sudo udevadm trigger
> udevadm info /dev/input/event4 | grep KEYBOARD

You should see your mappings are active.

Now even if you reboot your mappings should still be there. 









Thursday, May 13, 2021

Do I have anything I should have pushed?

I have a code folder. Under that I have subfolders for each repo I use. 

Do I have any work in any of these folders that needs pushing? 

 for /d %d in (*) do (pushd %d && git branch && popd || popd)

all on master.. so nope.


Friday, July 10, 2020

Refactoring In React: Class based components to Functional

I have a react class component I wanted to change to a functional one (to make refactoring easier)... I tried converting it.. but at the end the tests no longer ran. 

I wanted a way to incrementally convert it from one form to the other, so I could take smaller steps and run the tests after each step.

I wrapped the existing class based Component in a functional one. Renaming the existing one to InnerX and naming the functional one X.  Then I passed app props though to the existing InnerX. This adds no functionality but wrapping the component. I then moved the state from InnerX to X and passed it down via props. Then one at a time moved each function, running tests after each step... passing them as props. Any time anything failed I could rollback a step and try a different function with less dependencies.

Anyway... I share as it seems to be a useful technique if you are stuck.

Wednesday, July 08, 2020

OSx "Run As Admin" Context Menu

Create a new Automator workflow and set it up as above and save as "Run As Admin".

Now you can access this via context menu > Services > Run As Admin

GitHub Projects