[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

/etc/X11/window-managers (was Re: DEBIAN POLICY WEEKLY, #4 (October 23, 1997))



Christian Schwarz <schwarz@monet.m.isar.de> writes:

> Topic 12: X Window Manager policy
> 
> STATE: INPUT
> 
> Joey Hess wrote on Mon, 30 Jun 1997 to debian-devel:
> 
>      I maintain KDE, which includes a window manager, and I've been wondering how
>      other window managers handle registering themselves in
>      /etc/X11/window-managers. So I took a look at all th window managers.
> 
>      Some window managers add themselves to the top of the file, so they become the
>      default window manager. Others add themselves to the bottom of the file, so
>      the sysadmin doesn't get a chance to use them as a default window manager
>      without editing the file. And many window managers don't add themselves to the
>      file at all.
> 
>      Here's a survey I did:
> 
>      window manager    adds itself to /etc/X11/window-managers how
>      --------------    -------------------------------------------
>      kde               adds to bottom
>      afterstep         adds to bottom
>      fvwm              doesn't do so
>      fvwm2             doesn't seem to do so (complex postinst, I just grepped it
>      :-)
>      fvwm95            adds to top
>      gwm               doesn't do so
>      9wm               doesn't do so
>      ctwm              doesn't do so
>      wm2               doesn't do so
>      wmaker            doesn't do so
>      olvwm             if olvwm entry not already present, prompt to make
>                        default window manager or not, insert line in appropriate
>                        place.
> 
>      I think olvwm's behavior is the best of the lot, since it gives the sysadmin
>      a choice (and only asks once, not during upgrades, which is also very good
>      behavior). I wonder if it'd be a good idea for one of the X packages to
>      include a register-window-manager script that could be called from the
>      postinst's to handle this, so all window managers functioned exactly alike?
> 
> Linh Dang suggested:
> 
>      Why not make /etc/X11/window-managers a directory which contains scripts for
>      windows managers. Change /etc/X11/Xsession to start
>      /etc/X11/window-managers/default (which is a symlink). A fvwm script should
>      looks like:
> 
>      #!/bin/sh
>      exec fvwm -F /etc/X11/fvwm/system.fvwmrc
> 
> I'd prefer Joey's solution: xbase should install a script `install-wm' (or
> similar) which is called by all window manager's postinst scripts. The
> `install-wm' script will ask the sysadmin where to place the new wm (top or
> bottom of the file).
> 
> Any other ideas?

I've changed fvwm2 to do the same as olvmw, ie ask where to put it.

If someone does an "install-wm" script, they could life the code I
wrote.

Austin
------------------------------------------------------------

....

# add ourselves to /etc/X11/window-managers it we're not in it already
open(F, "<$WINMGRS") || die "Couldn't open $WINMGRS for read: $!\n";
@file = <F>;
@ret = grep(m!^/usr/X11R6/bin/fvwm2$!, @file);
&addWM("fvwm2", "/usr/X11R6/bin/fvwm2") if ($#ret == -1);

....

# add the line "$full" to /etc/X11/window-managers.  This assumes it's
# not already there.  Prompts asking whether "$short" should be made
# the default.
sub addWM
{
    local ($short, $full) = @_;
    local ($reply, $incomment, $placed);

    do {
	print "Should I make $short the default window manager? [Y/n] ";
	$reply = <STDIN>;
	chop($reply);
	$reply = "y" if ($reply eq "");
	$reply =~ tr/A-Z/a-z/;
	$reply = substr($reply, 0, 1);  # only first char counts
	print "Please anwser 'y' or 'n'\n"
	    if ($reply ne "y" && $reply ne "n");
    } until ($reply eq "y" || $reply eq "n");

    open(F, "<$WINMGRS") || die "Can't open $WINMGRS for read: $!\n";
    open(T, ">$WINMGRS.$$") || die "Can't open $WINMGRS.$$ for write: $!\n";

    $incomment = 0;	# was the prev line a comment line?
    $placed = 0;	# have we inserted the new line yet?
  line:
    while(<F>)
    {
	# skip comments
	if (/^\s*#/)
	{
	    print T;
	    $incomment = 1;
	    next line;
	}

	# should we make the WM the default?
	if ($incomment && ! $placed && $reply eq "y")
	{
	    print T "$full\n";
	    $placed = 1;
	}

	# in any case, put the non-comment line through to the output
	print T;
	$incomment = 0;
    }
    # place the WM line if we've got to the end of the file without doing so
    print T "$full\n" if (!$placed);

    close(F) || die "Error closing $WINMGRS: $!\n";
    close(T) || die "Error closing $WINMGRS.$$: $!\n";

    # swizzle the new copy into place atomically
    rename("$WINMGRS.$$", "$WINMGRS") ||
	die "Can't rename $WINMGRS.$$ to $WINMGRS: $!\n";
}


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: