aboutsummaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@mandriva.org>1999-12-22 02:22:14 +0000
committerChmouel Boudjnah <chmouel@mandriva.org>1999-12-22 02:22:14 +0000
commitefda392f90e6257cbf262361b557d92ebddfaea3 (patch)
tree968c68295d5eacfa6f40fe412640d451091559f8 /sbin
parenta347d25db6b5c471aec82a42447d116c69484a1d (diff)
downloadcommon-data-efda392f90e6257cbf262361b557d92ebddfaea3.tar
common-data-efda392f90e6257cbf262361b557d92ebddfaea3.tar.gz
common-data-efda392f90e6257cbf262361b557d92ebddfaea3.tar.bz2
common-data-efda392f90e6257cbf262361b557d92ebddfaea3.tar.xz
common-data-efda392f90e6257cbf262361b557d92ebddfaea3.zip
"Seethechangelog"
Diffstat (limited to 'sbin')
-rw-r--r--sbin/chksession127
-rwxr-xr-xsbin/fndSession128
2 files changed, 139 insertions, 116 deletions
diff --git a/sbin/chksession b/sbin/chksession
new file mode 100644
index 0000000..4ef57e5
--- /dev/null
+++ b/sbin/chksession
@@ -0,0 +1,127 @@
+#!/usr/bin/perl
+# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
+# Copyright under GPL blah blah blah.
+## you'll don't find much info here, see --help.
+
+my @lf;
+
+sub usage {
+ my $e = shift @_;
+ $0 =~ s|.*/||;
+ print { $e ? STDERR : STDOUT } << "EOF";
+Usage: $0 [OPTION]...
+
+ -F --first: Print only first available entry.
+ -t, --test: Go in test mode.
+ -l, --list: List window-managers.
+ -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.
+
+EOF
+ exit($e);
+}
+
+sub parse_file {
+ my $f=shift @_;
+ open F, $f or die "Can't open $f\n";
+ local $/ = "--@@--";
+ while (<F>) {
+ $n = $1 if /^NAME=(.*)/m;
+ $e = $1 if /^EXEC=(.*)/m;
+ $d = $1 if /^DESC=(.*)/m;
+ $i = $1 if /^ICON=(.*)/m;
+ $s = $1 while /SCRIPT:(.*?)$/gs; chomp $s;
+ if (-x $e) { $script{$n} = $s; $exec{$n} = $e; $desc{$n} = $d; $icon{$n} = $i; push @lf, $n; }
+ }
+}
+
+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;
+
+while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) {
+ $_ = shift;
+ if (/^--xsession=([^ ]+)/ || /^-x=([^ ]+)/) {
+ $xsession = $1;
+ } elsif (/^--first/ || /^-F/) {
+ $first++;
+ } elsif (/^--gdm/ || /^-g/) {
+ $gdm++;
+ } elsif (/^--list/ || /^-l/) {
+ $list++;
+ } elsif (/^--kdmsess/ || /^-k/) {
+ $kdm++;
+ } elsif (/^--test/ || /^-t/) {
+ $test++;
+ } elsif (/^--file=([^ ]+)/ || /^-f=([^ ]+)/) {
+ $file = $1;
+ } elsif (/^--remove=([^ ]+)/ || /^-r=([^ ]+)/) {
+ $remove=$1;
+ } elsif (/^--help/ || /^-h/ || /^-\?/) {
+ usage(0);
+ } else {
+ print STDERR "Unrecognized switch: $_\n";
+ usage(1);
+ }
+}
+
+$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);
+
+if ($kdm) {
+ $session="SessionTypes=";
+ for(@lf) { $session .= /$lf[-1]/ ? "$_;failsafe;default" : "$_;" }
+ print "$session\n";
+ exit(0);
+}
+
+
+if ($gdm) {
+ my $d = '/etc/X11/gdm/Sessions/';
+ chdir $d;
+
+ #Any better way ?
+ opendir D, $d;
+ for ( readdir(D)) { next if /^\.\.?/;next if /^Failsafe/; chmod 0644, $_; }
+ closedir D;
+
+ for my $file (@lf) {
+ open FH, ">/etc/X11/gdm/Sessions/$file" or die "Can't write to /etc/X11/gdm/Sessions/$file\n";
+ print FH "#!/bin/sh";
+ print FH $script{$file};
+ close FH;
+ chmod 0755, $file;
+ }
+ unlink 'Default';
+ symlink shift @lf, 'Default';
+}
+
+if ($xsession) {
+ if ($script{$xsession}) {
+ print "#!/bin/sh\n";
+ print $script{$xsession}
+ } else {
+ print "xterm -geometry 100x25+0+0 &\n";
+ -x '/usr/X11R6/bin/icewm' ? print "icewm\n" : print "xterm -geometry 67x14+384+446\n";
+ }
+ exit (0);
+}
+
+print shift @lf, "\n" if $first;
+if ($list) { my $p; for(@lf) { $p .= /$lf[-1]/ ? "$_ default failsafe" : "$_ " } print "$p\n"; }
diff --git a/sbin/fndSession b/sbin/fndSession
index 6cbcb1e..1f7ec8b 100755
--- a/sbin/fndSession
+++ b/sbin/fndSession
@@ -1,122 +1,18 @@
#!/bin/sh
-# fndSession (c) MandrakeSoft
-# Chmouel Boudjnah <chmouel@mandrakesoft.com>
+# fndSession (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
+## FindSession for kdm and gdm.
-LIST="SessionTypes"
-
-[ -x /usr/bin/kde ] && {
-LIST="$LIST=KDE"; FIRST=yes
-}
-[ -x /usr/bin/gnome-session ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;Gnome"
- else
- LIST="$LIST=Gnome"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/afterstep ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;AfterStep"
- else
- LIST="$LIST=AfterStep"
- FIRST="yes"
- fi
-}
-
-
-[ -e /usr/share/apps/switchdesk/Xclients.anotherlevel ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;AnotherLevel"
- else
- LIST="$LIST=AnotherLevel"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/bbdrake ] && {
- if [ "$FIRST" = "yes" ] ; then
- LIST="$LIST;BlackBox"
- FIRST="yes"
- fi
-}
-
-# Work but some end users don't understant how it works. So, we disable it.
-#[ -x /usr/X11R6/bin/bbdrake_kde ] && {
-# if [ "$FIRST" = "yes" ] ; then
-# LIST="$LIST;BlackBox/KDE"
-# FIRST="yes"
-# fi
-#}
-
-[ -x /usr/bin/enlightenment ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;Enlightenment"
- else
- LIST="$LIST=Enlightenment"
- FIRST="yes"
- fi
+[ -x /usr/sbin/chksession ] || {
+ echo "I can't find /usr/sbin/chksession"
+ echo "check your installation"
+ exit 1
}
-[ -x /usr/X11R6/bin/fvwm ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;FVWM"
- else
- LIST="$LIST=FVWM"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/fvwm2 ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;FVWM2"
- else
- LIST="$LIST=FVWM2"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/icewm ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;IceWM"
- else
- LIST="$LIST=IceWM"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/mwm ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;MWM"
- else
- LIST="$LIST=MWM"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/wmaker ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;WindowMaker"
- else
- LIST="$LIST=WindowMaker"
- FIRST="yes"
- fi
-}
-
-[ -x /usr/X11R6/bin/startxfce ] && {
- if [ "$FIRST" = "yes" ];then
- LIST="$LIST;XFCE"
- else
- LIST="$LIST=XFCE"
- FIRST="yes"
- fi
-}
+if [ -e /usr/share/config/kdmrc ];then
+LIST="`/usr/sbin/chksession -k`" perl -pi -e 's|^SessionTypes=.*|$ENV{LIST}|'\
+ /usr/share/config/kdmrc
+fi
-if [ $FIRST = "yes" ];then
- LIST="$LIST;default;FailSafe;"
-else
- LIST="$LIST=default;DailSafe;"
+if [ -d /etc/X11/gdm/Sessions ];then
+ /usr/sbin/chksession -g
fi
-sed "s/^SessionTypes.*/"$LIST"/" /usr/share/config/kdmrc > /tmp/$$.kdmrc && \
-mv /tmp/$$.kdmrc /usr/share/config/kdmrc