wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit a5825ff3d7b9811558b8507f83ba4cd7583ffa6f
parent 61f889a81c7f6557df3671a23bedb7188b672d15
Author: Kris Maglione <jg@suckless.org>
Date:   Thu, 22 Feb 2007 16:20:40 -0500

Made rc/newrc moderately less ugly.

Diffstat:
rc/newrc | 135++++++++++++++++++++++++++++++++++++++++++-------------------------------------
1 file changed, 72 insertions(+), 63 deletions(-)

diff --git a/rc/newrc b/rc/newrc @@ -29,7 +29,7 @@ WMII_TERM="xterm" export WMII_MENU WMII_FONT WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS WMII_TERM -# WM CONFIGURATION +# WM Configuration wmiir write /ctl << EOF font $WMII_FONT focuscolors $WMII_FOCUSCOLORS @@ -38,12 +38,12 @@ grabmod $MODKEY border 1 EOF -# COLUMN RULES +# Column Rules wmiir write /colrules <<EOF /.*/ -> 58+42 EOF -# TAGGING RULES +# Tagging Rules wmiir write /tagrules <<EOF /XMMS.*/ -> ~ /Gimp.*/ -> gimp @@ -54,7 +54,32 @@ EOF PROGS_FILE="$WMII_NS_DIR/.dmenu.proglist" +# Stop any running instances of wmiirc +if ! echo Start wmiirc | wmiir write /event +then + exit 1 +fi + +# Setup Tag Bar +wmiir ls /lbar | +while read bar +do + wmiir remove "/lbar/$bar" +done + +seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)" +wmiir ls /tag | sed -e 's|/||; /^sel$/d' | +while read tag +do + if [ "X$tag" = "X$seltag" ]; then + echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/lbar/$tag" + else + echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/lbar/$tag" + fi +done + { cat <<EOF +# Events Event Start if test "\$1" = "wmiirc" then @@ -128,12 +153,47 @@ Key $MODKEY-Shift-t EOF for i in 0 1 2 3 4 5 6 7 8 9; do cat << EOF -Key $MODKEY-$i) +Key $MODKEY-$i wmiir xwrite /ctl view "\$(echo \$key | sed 's/.*-//')" Key $MODKEY-Shift-$i wmiir xwrite /client/sel/tags "\$(echo \$key | sed 's/.*-//')" EOF done + +cat <<EOF +# Functions + +proglist() { + paths=\$(echo "\$@" | sed 'y/:/ /') + ls -lL \$paths 2>/dev/null | + awk '\$1 ~ /^[^d].*x/ { print \$NF }' | + sort | uniq +} + +actionlist() { + { + proglist $WMII_CONFPATH + echo \$ACTIONS | tr ' ' '\012' + } | sort | uniq +} + +conf_which () { + prog=\$1; shift + if [ -n "\$prog" ]; then + echo \$(PATH="$WMII_CONFPATH:$PATH" which \$prog) "\$@" + fi +} + +tagsmenu() { + wmiir ls /tag | sed "s|/||; /^sel\$/d" | $WMII_MENU +} + +# Misc +\$(conf_which status) & +xsetroot -solid "$WMII_BACKGROUND" & +proglist $PATH >$PROGS_FILE & +EOF + } | awk ' # Event Loop BEGIN { @@ -152,6 +212,10 @@ done actions[arg[2]] = body } } + /^#/ && $2 != "Events", 0 { + print + next + } /^(Event|Key|Action)[ \t]/ { addevent() split($0, arg) @@ -161,8 +225,10 @@ done body = body"\n"$0 } END { - for(key in keys) + for(key in keys) { print key | writekeys + print key >"/dev/fd/2" + } print "ACTIONS=\"\"" for(action in actions) { gsub("\"", "\\\"", action) @@ -187,61 +253,4 @@ done print body fflush() } - }' | { - cat << EOF; cat -# FUNCTIONS -proglist() { - paths=\$(echo "\$@" | sed 'y/:/ /') - ls -lL \$paths 2>/dev/null | - awk '\$1 ~ /^[^d].*x/ { print \$NF }' | - sort | uniq -} - -actionlist() { - { - proglist $WMII_CONFPATH - echo \$ACTIONS | tr ' ' '\012' - } | sort | uniq -} - -conf_which () { - prog=\$1; shift - if [ -n "\$prog" ]; then - echo \$(PATH="$WMII_CONFPATH:$PATH" which \$prog) "\$@" - fi -} - -tagsmenu() { - wmiir ls /tag | sed "s|/||; /^sel\$/d" | $WMII_MENU -} - -# MISC -\$(conf_which status) & -xsetroot -solid "$WMII_BACKGROUND" & -proglist $PATH >$PROGS_FILE & - -# Stop any running instances of wmiirc -if ! echo Start wmiirc | wmiir write /event -then - exit 1 -fi - -# SETUP TAG BAR -wmiir ls /lbar | -while read bar -do - wmiir remove "/lbar/\$bar" -done - -seltag="\$(wmiir read /tag/sel/ctl 2>/dev/null)" -wmiir ls /tag | sed -e 's|/||; /^sel$/d' | -while read tag -do - if [ "X\$tag" = "X\$seltag" ]; then - echo "$WMII_FOCUSCOLORS" "\$tag" | wmiir create "/lbar/\$tag" - else - echo "$WMII_NORMCOLORS" "\$tag" | wmiir create "/lbar/\$tag" - fi -done -EOF - } | sh + }' | sh