aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@mandriva.org>2000-04-16 22:45:04 +0000
committerChmouel Boudjnah <chmouel@mandriva.org>2000-04-16 22:45:04 +0000
commita416099e9a9852005fe6cf5c53ff89b323c7faf2 (patch)
tree78e87842c18d3c671c6826f6ba405d6b94588ca5 /bin
parent360aa9a6d797035bf024fde81511919d12051aa4 (diff)
downloadcommon-data-a416099e9a9852005fe6cf5c53ff89b323c7faf2.tar
common-data-a416099e9a9852005fe6cf5c53ff89b323c7faf2.tar.gz
common-data-a416099e9a9852005fe6cf5c53ff89b323c7faf2.tar.bz2
common-data-a416099e9a9852005fe6cf5c53ff89b323c7faf2.tar.xz
common-data-a416099e9a9852005fe6cf5c53ff89b323c7faf2.zip
Add file.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/DrakWM121
1 files changed, 121 insertions, 0 deletions
diff --git a/bin/DrakWM b/bin/DrakWM
new file mode 100755
index 0000000..469d752
--- /dev/null
+++ b/bin/DrakWM
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+# -*- Mode: cperl -*-
+# Copyright (C) 2000 by Chmouel Boudjnah <chmouel@mandrakesoft.com>,
+# MandrakeSoft Inc.
+# Redistribution of this file is permitted under the terms of the GNU
+# Public License (GPL)
+######################
+# Description: Launch window manager according to
+# /etc/X11/window-manager with various options.
+
+use Getopt::Long;
+
+my ($wm, $command, $window_mgr_file);
+my (@lf);
+
+my @getopt_args = ('l|list-active-session',
+ 'm|window-manager-file=s',
+ 'g|with-file-manager=s',
+ 'p|picture=s',
+ 'x|with-xterm',
+ 'h|help',
+ 'F|fallback',
+ );
+GetOptions(\%options, @getopt_args) || usage(1);
+usage() if $options{h};
+
+$window_mgr_file = $options{'m'} ? $options{'m'} : '/etc/X11/window-managers';
+die "$window_mgr_file don't exist\n" unless -r $window_mgr_file;
+parse_file($window_mgr_file);
+
+if ($options{l}){
+ print "\t\t\tActive Sessions:\n";
+ list_sessions();
+ exit(0);
+}
+
+unless ($ARGV[0]) {
+ print STDERR "\n\t\tYou need to specify a Window Manager\n\n";
+ usage(1);
+} else { $wm = $ARGV[0] }
+
+
+if (!$exec{$wm} && !$options{F}) {
+ print STDERR "I can't find an entry for $wm\n";
+ print STDERR "This is the list of active sessions:\n\n";
+ list_sessions(1);
+ print STDERR "\nVerify your installation or adjust $window_mgr_file\n";
+ exit 1;
+}
+
+# Launching
+if ($options{p} and $options{b}) {
+ print STDERR "option -p and -b are incompatible\n";
+ exit 1;
+} else {
+ system("xsetroot", "-solid", $options{b}) if $options{b};
+}
+
+if ($options{g} =~ /KFM/i) {
+ system("kfm &");
+} elsif ($options{g} =~ /GMC/i) {
+ system("gmc &");
+} elsif ($options{g} =~ /SFM/i) { #Special Pixel.
+ system("sfm &");
+} else {
+ if ($options{g}) {
+ print STDERR "You need to specify KFM or GMC to --with-filemanager";
+ exit(1);
+ }
+}
+
+if ( $options{p} and ! -x '/usr/X11R6/bin/xsetbg') {
+ print STDERR "Can't find xli installed, please adjust your installation\n";
+ exit(1);
+} else { system("xsetbg", $options{p}) if $options{p}; }
+if ($options{x}) {
+ my $xterm = $ENV{XTERM} ? $ENV{XTERM} : "xterm -bg black -fg white";
+ system("$xterm &");
+}
+
+# END
+$command = $script{$wm} ? $script{$wm} : $script{shift @lf};
+exec ("/bin/sh", "-c", "$command");
+
+sub parse_file {
+ my $f=shift @_;
+ local *F;
+ my ($e, $s, $n, $i, $d);
+ 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;
+ if (-x $e) { $script{$n} = $s; $exec{$n} = $e; push @lf, $n; }
+ }
+}
+
+sub list_sessions{my $e=shift @_;for(@lf){print{$e ? STDERR : STDOUT}"$_\n";}}
+
+sub usage {
+ my $e = shift @_;
+ (my $basename = $0) =~ s|.*/||;
+ print { $e ? STDERR : STDOUT } << "EOF";
+Usage: $0 [-Fxh] [ -b color ] [ window-manager session]
+Window-Manager launcher
+
+ -b=COLOR --background=COLOR: Specify a background color.
+ -g --with-file-manager: Launch with a filemanager [ KFM | GMC ]
+ -x --with-xtermM: Display an xterm.
+ -p=PIC --picture=PIC: Pictures to display in background.
+ -l --list-active-session: List active sessions.
+ -F --fallback: Try to fallback between window-managers
+ if failing to launch the specified one.
+ -h --help: Display this message.
+
+EOF
+ exit($e);
+}