aboutsummaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/chksession29
1 files changed, 9 insertions, 20 deletions
diff --git a/sbin/chksession b/sbin/chksession
index 77a067d..c21b034 100644
--- a/sbin/chksession
+++ b/sbin/chksession
@@ -17,7 +17,6 @@ Usage: $0 [OPTION]...
-f=FILE, --file=FILE: Specify an alternarte config files other
than /etc/X11/window-manager
-x=ENTRY, --xsession=ENTRY: Product window-managers script of ENTRY.
--r=ENTRY, --remove=ENTRY: remove an entry (product to stdin).
-k, --kdm: Product window-managers list for kdm sessions.
-g, --gdm: Product window-managers script for gdm sessions.
-h, --help: Product this help.
@@ -29,7 +28,7 @@ EOF
sub parse_file {
my $f=shift @_;
open F, $f or die "Can't open $f\n";
- local $/ = "--@@--";
+ local $/ = "";
while (<F>) {
$n = $1 if /^NAME=(.*)/m;
$e = $1 if /^EXEC=(.*)/m;
@@ -40,17 +39,6 @@ sub parse_file {
}
}
-sub remove_entry {
- my $e = shift @_;
- my $f = shift @_;
- open F, $f or die "Can't open $f\n";
- local $/ = "--@@--";
- while (<F>) {
- next if /^NAME=$e/m;
- print;
- }
-}
-
usage(1)
if @ARGV < 1;
@@ -69,10 +57,8 @@ while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) {
$kdm++;
} elsif (/^--test/ || /^-t/) {
$test++;
- } elsif (/^--file=([^ ]+)/ || /^-f=([^ ]+)/) {
- $file = $1;
- } elsif (/^--remove=([^ ]+)/ || /^-r=([^ ]+)/) {
- $remove=$1;
+ } elsif (/^--dir=([^ ]+)/ || /^-d=([^ ]+)/) {
+ $dir = $1;
} elsif (/^--help/ || /^-h/ || /^-\?/) {
usage(0);
} else {
@@ -81,9 +67,12 @@ while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) {
}
}
-$file = $test ? './window-managers' : '/etc/X11/window-managers' unless $file;
-die "$file don't exist\n" unless -r $file;
-$remove ? remove_entry($remove, $file) : parse_file ($file);
+$dir = $test ? './wmsession.d/' : '/etc/X11/wmsession.d/' unless $dir;
+opendir D, $dir or die "Can't open $dir\n";
+for (readdir(D)) {
+ my $file = $_;
+ parse_file ("$dir/$file");
+}
sub cat { my ($f) = @_; local *F; open F, $f; join '', <F> }
my ($e) = cat("/etc/sysconfig/desktop") =~ /(\S+)/;