summaryrefslogtreecommitdiff
path: root/.wmii/wmiirc
diff options
context:
space:
mode:
Diffstat (limited to '.wmii/wmiirc')
-rwxr-xr-x.wmii/wmiirc115
1 files changed, 30 insertions, 85 deletions
diff --git a/.wmii/wmiirc b/.wmii/wmiirc
index f211d7f..82c424b 100755
--- a/.wmii/wmiirc
+++ b/.wmii/wmiirc
@@ -1,95 +1,30 @@
#!/bin/bash
# Let any running instances of wmiirc know that we're starting
-
-echo ' ==> Starting wmiirc'
wmiir xwrite /event Start
-export WMII_NAMESPACE=`wmiir namespace`
-mount9p=/opt/plan9/bin/9pfuse
+. "$HOME/.wmii/include.sh"
+echo ' ==> Starting wmiirc'
+mount9p=/opt/plan9/bin/9pfuse
mkdir -p $WMII_NAMESPACE/mnt
$mount9p $WMII_NAMESPACE/{wmii,mnt}
-export WMII_DIR=$WMII_NAMESPACE/mnt
-
-# a -- a work-around for buggy IO append in 9pfuse
-# useing '|a' should be just like using '>>', but will work
-# when 9pfuse decides to bug out.
-a() {
- f="${1/#${WMII_DIR}/}"
- if [ "$f" = "$1" ]; then
- cat >> "$1"
- else
- if wmiir ls "$f" &>/dev/null; then
- wmiir write "$f"
- else
- wmiir create "$f"
- fi
- fi
-}
-# I like wmiir's setsid better than linux-utils'
-setsid() { wmiir setsid "$@"; }
-WMII_FONT='xft:Monospace-8'
-WMII_TERM=x-terminal-emulator
-
-. $HOME/.wmii/wmiirc_local
-# Configuration Variables
+
+MODKEY=Mod4 # super
UP=p
DOWN=n
LEFT=b
RIGHT=f
# Colors tuples: "<text> <background> <border>"
-. $HOME/.wmii/theme-solarized-dark
+. `conffile theme-solarized-dark`
# Menu history
-hist="${WMII_CONFPATH%%:*}/history"
+hist="`conffile history`"
# Tagging Rules
-echo '/Emacs|Navigator/ -> +sel' |a $WMII_DIR/tagrules
-echo '/panel/ -> /.*/' |a $WMII_DIR/tagrules
-
-if [ -f "${WMII_CONFPATH%%:*}/wmiirc_local" ]; then
- . "${WMII_CONFPATH%%:*}/wmiirc_local"
-fi
-
-path_ls() {
- find -L `echo "$@"|sed 'y/:/ /'` -maxdepth 1 -type f -executable -printf '%f\n' 2>/dev/null| sort -u
-}
-
-path_which() {
- mypath=$1
- prog=$2
- which=`which which`
- PATH="$mypath" "$which" -- "$prog" 2>/dev/null
-}
-
-
-lstags() {
- ls $WMII_DIR/tag | sed '/^sel$/d'
-}
-
-scansection() {
- file=`path_which "$WMII_CONFPATH" wmiirc`
- sec=$1
- tmp=`mktemp`
- if [ -n "$sec" ]; then
- < "$file" sed -n "/^\s*$sec\s*()/,/##\s*End $sec/p" | sed '1d;$d'> $tmp
- else
- < "$file" sed "/\s*}\s*##\s*End\s/d" > $tmp
- fi
- < $tmp sed -n '/##/p'|sed -r 's/^\s*(.*)\)\s*## ?/\t\1\t/;s/\s*## ?//'
- rm $tmp
-}
-
-Action() {
- prog=`path_which "$WMII_CONFPATH" $1`; shift
- if [ -n "$prog" ]; then
- "$prog" "$@"
- return $?
- else
- return 1
- fi
-}
+echo '/Emacs|Navigator/ -> +sel' >> $WMII_DIR/tagrules
+echo '/Eclipse/ -> +sel' >> $WMII_DIR/tagrules
+echo '/panel/ -> /.*/' >> $WMII_DIR/tagrules
Event() {
event=$1; shift;
@@ -107,10 +42,14 @@ Event() {
## WMII-meta events
Quit) ## No args
- fusermount -u $WMII_DIR
- exit $?;;
+ echo ' ==> Stopping wmiirc'
+ echo " -> unmounting WMII_DIR=$WMII_DIR..."
+ # might complain about /etc/mtab if the x server has already stopped
+ fusermount -u "$WMII_DIR" 2>>/dev/null
+ echo " -> rmdir'ing WMII_DIR=$WMII_DIR..."
+ rmdir "$WMII_DIR";;
Warning) ## $@=string
- notify-send "wmii warning: $@";;
+ notify-send "wmii warning: $*";;
Key) ## $1=keystroke
Key "$@";;
@@ -171,7 +110,7 @@ Event() {
## Tag events
CreateTag) ## $1=tag
- echo "$WMII_NORMCOLORS" $@ |a $WMII_DIR/lbar/$1;;
+ echo "$WMII_NORMCOLORS" $@ |a $WMII_DIR/lbar/$1;;
DestroyTag) ## $1=tag
rm $WMII_DIR/lbar/$1;;
FocusTag) ## $1=tag
@@ -264,7 +203,7 @@ Key() {
$MODKEY-x) ## Open program menu
setsid $(wimenu -h "${hist}.progs" -n 5000 <$progsfile) & ;;
$MODKEY-Return) ## Launch a terminal
- setsid $WMII_TERM & ;;
+ setsid x-terminal-emulator & ;;
## Other
$MODKEY-Control-t) ## Toggle all other key bindings
@@ -293,11 +232,11 @@ Key() {
} ## End Key
# WM Configuration
-echo font $WMII_FONT |a $WMII_DIR/ctl
+echo font xft:Monospace-8 |a $WMII_DIR/ctl
echo focuscolors $WMII_FOCUSCOLORS |a $WMII_DIR/ctl
-echo normcolors $WMII_NORMCOLORS |a $WMII_DIR/ctl
-echo grabmod $MODKEY |a $WMII_DIR/ctl
-echo border 1 |a $WMII_DIR/ctl
+echo normcolors $WMII_NORMCOLORS |a $WMII_DIR/ctl
+echo grabmod $MODKEY |a $WMII_DIR/ctl
+echo border 1 |a $WMII_DIR/ctl
xsetroot -solid "$WMII_BACKGROUND" &
progsfile=$WMII_NAMESPACE/.proglist
@@ -319,7 +258,13 @@ done
Action autostart 2>/dev/null &
+if [ -f "`conffile wmiirc_local`" ]; then
+ . "`conffile wmiirc_local`"
+fi
+
+trap "Event Quit" EXIT
+
# use wmiir so it doesn't look like an open file
-wmiir read /event | while read event; do
+wmiir read /event 2>/dev/null | while read event; do
Event $event
done