#!/usr/bin/perl -l =head1 DESCRIPTION Naive program for B<Window Manager> selection: (over)writes one's F<`~/.xinitrc'>. Data for the program is appended literally at the end of it, after the __END__ token and has the form C<< <key>:<name>:<cmd> >> where <key> is the key to be selected by the user, preferably consisting of one or at most a few chars, <name> is the name of the Window Manager and <cmd> is the command to be put in F<`~/.xinitrc +'>. <key> is case-insensitive and shown uppercase. In the unlikely event that any item contains literal C<:>'s, any longe +r string of colons can be used as a separator instead, like thus: C<L::LCM:Cool!::exec lcmwm> Lines with no colons are silently ignored. No additional checking is performed. =cut use strict; use warnings; my ($q,%wm,%saw)='Q'; # Quit Key while (<DATA>) { chomp; my $sep; $sep |= $_ for /:+/g; $sep or next; my ($k,$n,$cmd)=split /$sep/; $k=uc $k; (warn "$0: Cannot use [$k] as a key for `$n'"), next if $k eq $q; (warn "$0: Duplicate key [$k]. Skipping `$n'"), next if $saw{$k}++; $wm{$k}=[$n,$cmd]; } { print "Choose Window Manager:"; print "[$_] $wm{$_}[0]" for sort keys %wm; print "[$q] <QUIT>"; chomp(my $in=uc <STDIN>); last if $in eq $q; exists $wm{$in} or (warn "Invalid choice: [$in]\n"), redo; open my $fh, '>', "$ENV{HOME}/.xinitrc" or die "Can't write to ~/.xinitrc: $!\n"; print $fh $wm{$in}[1]; print <<"EOT"; `~/.xinitrc' successfully updated for use with $wm{$in}[0]! Do you want to start X now? [y/Y] to do so, anything else to quit. EOT exec 'startx' if uc <STDIN> eq "Y\n"; } __END__ G:Gnome:exec gnome-session K:KDE:exec startkde B:Blackbox:exec blackbox E:Enlightenment:exec enlightenment F:FVWM:exec fvwm I:IceWM:exec icewm-session S:Sawfish:exec sawfish W:Window Maker:exec wmaker A:Waimea:exec waimea X:XFce3:exec xfwm X4:XFce4:exec startxfce4 U:Fluxbox:exec fluxbox L:evilwm:exec evilwm

In reply to wmchoose by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.