~ubuntu-branches/ubuntu/oneiric/localization-config/oneiric

« back to all changes in this revision

Viewing changes to conffiles.d/sarge/ltsp-xfree86-kbd

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2004-12-10 19:10:18 UTC
  • Revision ID: james.westby@ubuntu.com-20041210191018-wdjfbljdie570dld
Tags: 0.109
* Translations
  - Added Finnish by Tapio Lehtonen. Closes: #281040
  - Fixed Spanish translation (was too long). Closes: #284570

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# This script configures XFree86 for LTSP in skolelinux.
 
3
 
 
4
use strict;
 
5
use warnings;
 
6
 
 
7
require '/usr/lib/localization-config/sarge/xfree86-kbd';
 
8
 
 
9
BEGIN {
 
10
    my @f = split(m%/%, $0); pop @f;
 
11
    push @INC, join("/", @f);
 
12
}
 
13
 
 
14
my %lang_map = get_lang_map();
 
15
 
 
16
my $debug = 0;
 
17
 
 
18
my $LTS_CONF = "/opt/ltsp/i386/etc/lts.conf";
 
19
 
 
20
# If no locale is given as argument, quit
 
21
my $lang = $ARGV[0] or die "No language given";
 
22
 
 
23
# Print the supported locale entries.
 
24
if ("supported" eq $lang) {
 
25
    for $lang (sort keys %lang_map) {
 
26
        print "$lang\n";
 
27
    }
 
28
    exit 0;
 
29
}
 
30
 
 
31
if ( ! -f $LTS_CONF ) {
 
32
    print STDERR "warning: ltsp-xfree86-kbd: Doing nothing, lts.conf is missing.\n" if $debug;
 
33
    exit 0;
 
34
}
 
35
 
 
36
# Udate lts.conf, replacing "XkbLayout" line.
 
37
if(defined(my $conf = $lang_map{$lang})) {
 
38
    my $layout = $conf->{'LAYOUT'};
 
39
    my $options = $conf->{'XKBOPTIONS'};
 
40
    open(CFG, "< $LTS_CONF") || die "Unable to read $LTS_CONF";
 
41
    my @lines = <CFG>;
 
42
    close(CFG);
 
43
    chomp @lines;
 
44
    @lines = map { if (m/^(\s*XkbLayout\s*=\s*)(.+)$/)
 
45
                   { "\"$1$layout\""; }
 
46
                   else { $_; }
 
47
               } @lines;
 
48
    # the following is disabled for now, since LTSP 3.0 does not
 
49
    # support this option.
 
50
    # @lines = map { if (m/^(\s*XkbOptions\s*=\s*)(.+)$/)
 
51
    #                { "\"$1$options\""; }
 
52
    #                else { $_; }
 
53
    #            } @lines;
 
54
    open(CFG, "> $LTS_CONF.new") || die "Unable to write $LTS_CONF.new.";
 
55
    print CFG join("\n",@lines, "") || die "Unable to write to $LTS_CONF.new.";
 
56
    close(CFG) || die "Unable to close $LTS_CONF.new.";
 
57
    rename("$LTS_CONF.new", $LTS_CONF) ||
 
58
        die "Unable to rename $LTS_CONF.new to $LTS_CONF."; 
 
59
} else {
 
60
    die "$0: No support for language '$lang'\n";
 
61
}