summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Xconfig/parse.pm2
-rw-r--r--lib/Xconfig/xfree.pm31
2 files changed, 30 insertions, 3 deletions
diff --git a/lib/Xconfig/parse.pm b/lib/Xconfig/parse.pm
index 1454b56..9a5ff1c 100644
--- a/lib/Xconfig/parse.pm
+++ b/lib/Xconfig/parse.pm
@@ -153,7 +153,7 @@ my %kind_names = (
WacomEraser => [ qw(Port) ], #-/
ServerLayout => [ qw(Identifier) ],
);
-my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout XkbOptions XkbCompat Load ModulePath BusID PreferredMode);
+my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout XkbOptions XkbCompat Load Disable ModulePath BusID PreferredMode);
%kind_names = map_each { lc $::a => [ map { lc } @$::b ] } %kind_names;
@want_string = map { lc } @want_string;
diff --git a/lib/Xconfig/xfree.pm b/lib/Xconfig/xfree.pm
index 6b52ff5..b70948b 100644
--- a/lib/Xconfig/xfree.pm
+++ b/lib/Xconfig/xfree.pm
@@ -493,6 +493,12 @@ sub get_modules {
my $Module = raw_export_section($raw_Module, ['Load']);
@{$Module->{Load} || []};
}
+sub get_disabled_modules {
+ my ($raw_X) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') or return;
+ my $Module = raw_export_section($raw_Module, ['Disable']);
+ @{$Module->{Disable} || []};
+}
sub add_load_module {
my ($raw_X, $module) = @_;
my $raw_Module = $raw_X->get_Section('Module') || $raw_X->add_Section('Module', {});
@@ -509,18 +515,39 @@ sub add_load_module {
comment_on_line => $comment && " # $comment",
} if !member($module, $raw_X->get_modules);
}
+sub add_disable_module {
+ my ($raw_X, $module) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') || $raw_X->add_Section('Module', {});
+
+ push @{$raw_Module->{Disable}}, { val => $module } if !member($module, $raw_X->get_disabled_modules);
+}
sub remove_load_module {
my ($raw_X, $module) = @_;
my $raw_Module = $raw_X->get_Section('Module') or return;
if (my @l = grep { $_->{val} ne $module } @{$raw_Module->{Load}}) {
$raw_Module->{Load} = \@l;
} else {
- $raw_X->remove_Section('Module');
+ delete $raw_Module->{Load};
+ }
+}
+sub remove_disable_module {
+ my ($raw_X, $module) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') or return;
+ if (my @l = grep { $_->{val} ne $module } @{$raw_Module->{Disable}}) {
+ $raw_Module->{Disable} = \@l;
+ } else {
+ delete $raw_Module->{Disable};
}
}
sub set_load_module {
my ($raw_X, $module, $bool) = @_;
- $bool ? add_load_module($raw_X, $module) : remove_load_module($raw_X, $module);
+ if ($bool) {
+ remove_disable_module($raw_X, $module);
+ add_load_module($raw_X, $module);
+ } else {
+ remove_load_module($raw_X, $module);
+ add_disable_module($raw_X, $module);
+ }
}