small script to generate dvorak.xmodmap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

small script to generate dvorak.xmodmap

Julian Fondren
setxkbmap hasn't worked for !x86 archs for me, on any OS.  Probably
I'm doing something wrong, but if so it's unobvious.  In any case, the
included bit of Perl will print out xmodmap instructions to convert a
qwerty environment to a dvorak one.

The saved qwerty.xmodmap is needed for any changes -- unless you want
to horribly mangle your keymap, or unless you'd prefer to make
incremential changes to the produced dvorak.xmodmap

Not sharing my dvorak.xmodmap : there are too many completely useless
.xmodmap floating around the net.

Enjoy.

---- usage ----
mkdir ~/var; cd ~/var
xmodmap -pke > qwerty.xmodmap
./gendvorak > dvorak.xmodmap
xmodmap dvorak.xmodmap

---- file begins ----
#! /usr/bin/env perl
my %d = qw(a a A A b n B N c i C I d h D H
           e d E D f y F Y g u G U h j H J
           i g I G j c J C k v K V l p L P
           m m M M n l N L o s O S p r P R
           q x Q X r o R O s ; S : t k T K
           u f U F v . V > w , W < x b X B
           y t Y T z / Z ?
           [ - { _ ] = } + - ' _ " / [ ? {
           = ] + } ' q " Q , w < W . e > E
           ; z : Z);
my %ns = qw(- minus _ underscore = equal + plus [ bracketleft ] bracketright
            { braceleft } braceright ; semicolon : colon ' apostrophe " quotedbl
            , comma < less . period > greater / slash ? question);
use strict;
use warnings;
my %qd = map { exists($ns{$_}) ? $ns{$_} : $_ } reverse(%d);

open my $f, "$ENV{HOME}/var/qwerty.xmodmap" or die $!;
while (<$f>) {
  chomp;
  next unless /^keycode \s+ (\d+) \s+ = \s+ (.+)/x;
  print "keycode $1 = @{[map { exists($qd{$_}) ? $qd{$_} : $_ }
split(' ',$2)]}\n";
}