From a416099e9a9852005fe6cf5c53ff89b323c7faf2 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Sun, 16 Apr 2000 22:45:04 +0000 Subject: Add file. --- bin/DrakWM | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100755 bin/DrakWM (limited to 'bin') 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 , +# 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 () { + $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); +} -- cgit v1.2.1