diff options
Diffstat (limited to 'klipper/klipper-1-2.pl')
-rw-r--r-- | klipper/klipper-1-2.pl | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/klipper/klipper-1-2.pl b/klipper/klipper-1-2.pl new file mode 100644 index 000000000..b9cd337fb --- /dev/null +++ b/klipper/klipper-1-2.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +my ($section, %data); + +#read in all the data, split it up into hashes. Thanks again to malte for much input +while (<>) { + if (/\[(.*)\]/) { + $sections{$section} = {%data} if $section; + $section = $1; + undef %data; + next; + } + $data{$1} = $2 if /^([^=]*)=(.*)$/; +} + +$sections{$section} = {%data} if $section; + +# not used up to now +# $version = $sections{'General'}->{'Version'}; + +# if "Action description" is not available, we have a new, fresh configuration +# without any need for conversion. +if ( ! $sections{'Action_0'}->{'Action description'} ) { + exit; +} + +$numActions = $sections{'General'}->{'Number of Actions'}; +for my $i (0..($numActions - 1)) { + my $actionGroup = "Action_$i"; + my $numCommands = $sections{$actionGroup}->{'Number of commands'}; + + print "[$actionGroup]\n"; + # rename some keys + print "Description=$sections{$actionGroup}->{'Action description'}\n"; + print "Regexp=$sections{$actionGroup}->{'Action regexp'}\n"; + print "Number of commands=$numCommands\n"; + + # move the command entries from "Action_x" to "Action_x/Command_y" + for my $k (0..($numCommands - 1)) { + my $command = "Command_$k"; + my $commandGroup = "$actionGroup/$command"; + print "\n[$commandGroup]\n"; + my $value = $sections{$actionGroup}->{"$command: commandline"}; + print "Commandline=$value\n"; + $value = $sections{$actionGroup}->{"$command: description"}; + print "Description=$value\n"; + $value = $sections{$actionGroup}->{"$command: enabled"}; + print "Enabled=$value\n"; + } + print "\n"; +} + +©Section( "General" ); +©Section( "Global Keys" ); + +sub copySection() +{ + my ($group) = @_; + print "\n[$group]\n"; + while (($key,$value) = each(%{$sections{$group}})) { + print "$key=$value\n"; + } +} |