DoK : |
הסבר מפורט למדי שכתבתי בויקי כאן באתר
אתם כמובן מוזמנים לערוך ולשפר. |
קוד: |
#! /usr/bin/perl $hebmodel ="\tOption \t\"XkbModel\"\t\"pc105\""; $heblayout="\tOption \t\"XkbLayout\"\t\"us,il\""; $heboptios="\tOption \t\"XkbOptions\"\t\"grp:alt_shift_toggle,grp_led:scroll\""; $file=shift (@ARGV); open FILE, $file or die "Cannot open $file: $!"; $kbd=0; #search the file for keywords while (<FILE>) { SWITCH: { /kbd/ && do { $kbd=1; last SWITCH; }; /XkbModel/ && do { $model=join (" ", split " ", $_); last SWITCH; }; /XkbLayout/ && do { $layout=join (" ", split " ", $_); last SWITCH; }; /XkbOptions/ && do { $option=join (" ", split " ", $_); last SWITCH; }; } } die "No keyboard option found" if (!$kbd); print ("Current kbd options found:\n"); if ($model) { print ($model ,"\n"); } if ($layout) { print ($layout,"\n"); } if ($options) { print ($options,"\n"); } print ("continue [Y]?"); if (defined ($_ = <STDIN>)) { die "Execution stopped\n" if (!/Y/); } open FILE, $file or die "Cannot open $file: $!"; while (<FILE>) { #filter the unwanted configuration lines next if (/XkbModel/ || /XkbLayout/ || /XkbOptions/); print; #write new configuration after 'kbd' if (/kbd/) { print ($hebmodel, "\n"); print ($heblayout, "\n"); print ($heboptios, "\n"); next; } } |