#!/usr/bin/perl # ckbcomp -- translate XKB layout to loadkeys or kbdcontrol format # Copyright © 2005,2006 Anton Zinoviev # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # If you have not received a copy of the GNU General Public License # along with this program, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use warnings 'all'; use strict; my $debug_flag = 1; sub debug { if ($debug_flag) { print STDERR "@_"; } } sub warning { print STDERR "WARNING: @_"; } ########### ARGUMENTS ############################################### my $charmap; my $acm; my $verbosity = 0; my $installdir=$0; $installdir =~ s|/[^/]*$||g; if ($installdir =~ m|/bin$|) { $installdir =~ s|/bin$||; } else { $installdir .= "/.."; } if ( $installdir eq '' || ! -d "$installdir/bin") { $installdir = '/usr'; } my @xdirs = ('/etc/console-setup/ckb', "$installdir/etc/console-setup/ckb", '/usr/local/share/X11/xkb', '/usr/share/X11/xkb', '/etc/X11/xkb'); my $keycodes; my $symbols; my $rules; my $model; my @layouts; my @variants = (); my @options = (); my $compact = 0; my $backspace = ''; my $freebsd = 0; while (@ARGV) { $_ = shift @ARGV; if (s/^-//) { if (/^charmap$/) { if ($charmap) { die "$0: No more than one -charmap option is allowed\n"; } $charmap = $ARGV[0]; shift @ARGV; } elsif (/^v(erbose)?$/) { if ($verbosity) { die "$0: No more than one -verbose option is allowed\n"; } if ($ARGV[0] =~ /^[0-9]|10$/) { $verbosity = $ARGV[0]; shift @ARGV; } else { $verbosity = 5; } } elsif (/^I(.*)$/) { @xdirs = ($1, @xdirs); } elsif (/^keycodes$/) { if ($keycodes) { die "$0: No more than one -keycodes option is allowed\n"; } $keycodes = $ARGV[0]; shift @ARGV; } elsif (/^symbols$/) { if ($symbols) { die "$0: No more than one -symbols option is allowed\n"; } $symbols = $ARGV[0]; shift @ARGV; } elsif (/^rules$/) { if ($rules) { die "$0: No more than one -rules option is allowed\n"; } $rules = $ARGV[0]; shift @ARGV; } elsif (/^model$/) { if ($model) { die "$0: No more than one -model option is allowed\n"; } $model = $ARGV[0]; $model =~ s/[[:space:]]//g; shift @ARGV; } elsif (/^layout$/) { if (@layouts) { die "$0: No more than one -layout option is allowed\n"; } $ARGV[0] =~ s/[[:space:]]//g; @layouts = split (/,/, $ARGV[0], -1); shift @ARGV; } elsif (/^variant$/) { if (@variants) { die "$0: No more than one -variant option is allowed\n"; } $ARGV[0] =~ s/[[:space:]]//g; @variants = split (/,/, $ARGV[0], -1); shift @ARGV; } elsif (/^option$/) { $ARGV[0] =~ s/[[:space:]]//g; @options = (@options, split (/,/, $ARGV[0], -1)); shift @ARGV; } elsif (/^help$|^-help$|^\?$/) { print < [ [