Friday, January 10, 2014

Wednesday, January 8, 2014

Emulating media keys with xmodmap

I got a new keyboard for Christmas, a mechanical one made using the same process as the old IBM model M ones.

The only issue is that I actually use my media keys to play/pause etc... and this keyboard has none, so using xmodmap and information from the Debian wiki and askubuntu I was able to remap the numeric keypad keys which I never use anyway to emulate multimedia keys.

The following sets "5" to play/pause, 8/2 to volume up/down, 4/6 to previous/next and 7 to mute/unmute.

File "xmodmaprc"
keycode 79 = XF86AudioMute
keycode 88 = XF86AudioLowerVolume
keycode 80 = XF86AudioRaiseVolume
keycode 84 = XF86AudioPlay
keycode 83 = XF86AudioPrev
keycode 85 = XF86AudioNext
Command to run
xmodmap xmodmaprc

Tuesday, January 7, 2014

Using comm to find unique or common lines between 2 files

Use comm to compare files and show only lines that are unique, requires files to be sorted.

With no options, produce three-column output.  Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

Any of the columns can be supressed by adding -1, -2 or -3.

Example: Compare fileA.txt and fileB.txt and show only lines that are unique to fileA.txt
comm -2 -3 <(sort fileA.txt) <(sort fileB.txt)