changeset:   1934:62e6ee8e4acc
tag:         tip
user:        Kris Maglione <jg_AT_suckless.org>
date:        Thu Feb 22 16:20:40 2007 -0500
summary:     Made rc/newrc moderately less ugly.
diff -r de155f806fb7 -r 62e6ee8e4acc rc/newrc
--- a/rc/newrc	Thu Feb 22 15:53:34 2007 -0500
+++ b/rc/newrc	Thu Feb 22 16:20:40 2007 -0500
@@ -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 @@ border 1
 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 @@ EOF
 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
Received on Thu Feb 22 2007 - 22:22:51 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:46 UTC