2007-02-23 06:36:50 +03:00
|
|
|
#!/usr/local/plan9/bin/rc
|
|
|
|
# WMII Configuration
|
|
|
|
|
|
|
|
oldpath=$path
|
|
|
|
path=($PLAN9/bin $path)
|
|
|
|
|
|
|
|
MODKEY=Mod1
|
|
|
|
UP=k
|
|
|
|
DOWN=j
|
|
|
|
LEFT=h
|
|
|
|
RIGHT=l
|
|
|
|
|
|
|
|
WMII_FONT='fixed'
|
2007-02-24 07:09:58 +03:00
|
|
|
WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
|
|
|
|
WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
|
2007-02-23 06:36:50 +03:00
|
|
|
WMII_BACKGROUND='#333333'
|
|
|
|
|
2007-02-23 22:05:46 +03:00
|
|
|
WMII_TERM=(xterm)
|
2007-02-23 21:48:21 +03:00
|
|
|
|
|
|
|
fn wmiimenu {
|
2007-02-24 07:09:58 +03:00
|
|
|
dmenu -b -fn $WMII_FONT \
|
|
|
|
-nf $WMII_NORMCOLORS(1) -nb $WMII_NORMCOLORS(2) \
|
|
|
|
-sf $WMII_FOCUSCOLORS(1) -sb $WMII_FOCUSCOLORS(2)
|
2007-02-23 21:48:21 +03:00
|
|
|
}
|
2007-02-23 06:36:50 +03:00
|
|
|
|
2007-02-26 12:27:03 +03:00
|
|
|
fn 9menu {
|
2007-02-26 12:46:55 +03:00
|
|
|
wmii9menu -teleport -font $WMII_FONT \
|
2007-02-26 12:27:03 +03:00
|
|
|
-nf $WMII_NORMCOLORS(1) -nb $WMII_NORMCOLORS(2) \
|
|
|
|
-sf $WMII_FOCUSCOLORS(1) -sb $WMII_FOCUSCOLORS(2) \
|
|
|
|
-br $WMII_FOCUSCOLORS(3) $*
|
|
|
|
}
|
|
|
|
|
2007-02-25 22:17:56 +03:00
|
|
|
fn config_whatis {
|
|
|
|
confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'}
|
|
|
|
prog=$1; shift
|
|
|
|
echo `{{path=$confpath whatis $prog} | grep -v '=|^fn '} $*
|
|
|
|
}
|
|
|
|
|
2007-02-26 07:29:16 +03:00
|
|
|
# Source Variables, &c
|
2007-02-25 22:17:56 +03:00
|
|
|
local = `{config_whatis rc.wmii.local}
|
2007-02-26 07:29:16 +03:00
|
|
|
. <{awk '// /^# Overrides/ { exit }' $local}
|
2007-02-25 07:36:16 +03:00
|
|
|
|
2007-02-23 06:36:50 +03:00
|
|
|
# Column Rules
|
|
|
|
wmiir write /colrules <<!
|
|
|
|
/./ -> 60+40
|
|
|
|
!
|
|
|
|
|
|
|
|
# Tagging Rules
|
|
|
|
wmiir write /tagrules <<!
|
|
|
|
/Firefox/ -> www
|
|
|
|
/XMMS.*/ -> ~
|
|
|
|
/MPlayer.*/ -> ~
|
|
|
|
/.*/ -> !
|
|
|
|
/.*/ -> 1
|
|
|
|
!
|
|
|
|
|
|
|
|
# Status Bar Info
|
|
|
|
fn status {
|
|
|
|
echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Events
|
|
|
|
fn Event-Start {
|
2007-02-26 07:29:16 +03:00
|
|
|
switch($1) {
|
|
|
|
case wmiirc
|
2007-02-23 06:36:50 +03:00
|
|
|
rm -f $progs_file
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
}
|
2007-02-26 07:29:16 +03:00
|
|
|
|
|
|
|
fn Event-Key { eval Key-$1 $1 }
|
|
|
|
|
|
|
|
fn Event-CreateTag { echo $WMII_NORMCOLORS $* | wmiir create /lbar/$"* }
|
|
|
|
fn Event-DestroyTag { wmiir remove /lbar/$"* }
|
|
|
|
fn Event-FocusTag { wmiir xwrite /lbar/$"* $WMII_FOCUSCOLORS $* }
|
|
|
|
fn Event-UnfocusTag { wmiir xwrite /lbar/$"* $WMII_NORMCOLORS $* }
|
|
|
|
fn Event-UrgentTag { shift; wmiir xwrite /lbar/$"* '*'$"* }
|
|
|
|
fn Event-NotUrgentTag { shift; wmiir xwrite /lbar/$"* $"* }
|
|
|
|
|
|
|
|
fn Event-LeftBarClick { shift; wmiir xwrite /ctl view $* }
|
2007-02-26 12:27:03 +03:00
|
|
|
fn Event-ClientMouseDown {
|
|
|
|
client = $1; button = $2
|
|
|
|
if(~ $button 3)
|
2007-02-26 12:55:54 +03:00
|
|
|
switch(`{9menu Nop Delete}) {
|
2007-02-26 12:27:03 +03:00
|
|
|
case Delete
|
|
|
|
wmiir xwrite /client/$client/ctl kill
|
|
|
|
}
|
|
|
|
}
|
2007-02-23 06:36:50 +03:00
|
|
|
|
|
|
|
# Actions
|
|
|
|
fn Action {
|
|
|
|
action=$1; shift
|
|
|
|
if(whatis Action-$action | 9 grep -s '^fn ') {
|
|
|
|
Action-$action $* &
|
2007-02-26 07:29:16 +03:00
|
|
|
};if not {
|
2007-02-23 06:36:50 +03:00
|
|
|
run_command `{config_whatis $action} $* &
|
|
|
|
}
|
|
|
|
}
|
2007-02-26 07:29:16 +03:00
|
|
|
fn Action-rehash { proglist $PATH >$progs_file }
|
|
|
|
fn Action-quit { wmiir xwrite /ctl quit }
|
2007-02-23 06:36:50 +03:00
|
|
|
fn Action-status {
|
|
|
|
if(wmiir remove /rbar/status >[2]/dev/null)
|
|
|
|
sleep 2
|
|
|
|
echo $WMII_NORMCOLORS | wmiir create /rbar/status
|
|
|
|
while(status | wmiir write /rbar/status)
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Key Bindings
|
|
|
|
fn Key-$MODKEY-Control-t {
|
2007-02-26 07:29:16 +03:00
|
|
|
switch(`{wmiir read /keys | wc -l}) {
|
|
|
|
case 0 1
|
2007-02-23 06:36:50 +03:00
|
|
|
initkeys
|
|
|
|
wmiir xwrite /ctl grabmod $MODKEY
|
2007-02-26 07:29:16 +03:00
|
|
|
case *
|
|
|
|
wmiir xwrite /keys $MODKEY-Control-t
|
2007-02-23 06:36:50 +03:00
|
|
|
wmiir xwrite /ctl grabmod Mod3
|
|
|
|
}
|
|
|
|
}
|
2007-02-26 07:29:16 +03:00
|
|
|
|
|
|
|
fn Key-$MODKEY-$LEFT { wmiir xwrite /tag/sel/ctl select left }
|
|
|
|
fn Key-$MODKEY-$RIGHT { wmiir xwrite /tag/sel/ctl select right }
|
|
|
|
fn Key-$MODKEY-$DOWN { wmiir xwrite /tag/sel/ctl select down }
|
|
|
|
fn Key-$MODKEY-$UP { wmiir xwrite /tag/sel/ctl select up }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-Shift-$LEFT { wmiir xwrite /tag/sel/ctl send sel left }
|
|
|
|
fn Key-$MODKEY-Shift-$RIGHT { wmiir xwrite /tag/sel/ctl send sel right }
|
|
|
|
fn Key-$MODKEY-Shift-$DOWN { wmiir xwrite /tag/sel/ctl send sel down }
|
|
|
|
fn Key-$MODKEY-Shift-$UP { wmiir xwrite /tag/sel/ctl send sel up }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-space { wmiir xwrite /tag/sel/ctl select toggle }
|
|
|
|
fn Key-$MODKEY-Shift-space { wmiir xwrite /tag/sel/ctl send sel toggle }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-d { wmiir xwrite /tag/sel/ctl colmode sel default }
|
|
|
|
fn Key-$MODKEY-s { wmiir xwrite /tag/sel/ctl colmode sel stack }
|
|
|
|
fn Key-$MODKEY-m { wmiir xwrite /tag/sel/ctl colmode sel max }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-Shift-c { wmiir xwrite /client/sel/ctl kill }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-a { Action `{actionlist | wmiimenu} & }
|
|
|
|
fn Key-$MODKEY-p { run_command `{wmiimenu <$progs_file} & }
|
|
|
|
fn Key-$MODKEY-Return { run_command $WMII_TERM & }
|
|
|
|
fn Key-$MODKEY-t { wmiir xwrite /ctl view `{read_tags | wmiimenu} & }
|
2007-02-23 06:36:50 +03:00
|
|
|
fn Key-$MODKEY-Shift-t {
|
2007-02-23 22:05:46 +03:00
|
|
|
wmiir xwrite /client/`{wmiir read /client/sel/ctl}^/tags `{read_tags | wmiimenu} &
|
2007-02-23 23:11:39 +03:00
|
|
|
}
|
2007-02-23 22:05:46 +03:00
|
|
|
|
2007-02-23 06:36:50 +03:00
|
|
|
for(i in `{seq 0 9}) {
|
2007-02-26 07:29:16 +03:00
|
|
|
fn Key-$MODKEY-$i { wmiir xwrite /ctl view `{echo $1 | sed 's/.*-//'} }
|
|
|
|
fn Key-Shift-$MODKEY-$i {wmiir xwrite /client/sel/tags `{echo $1 | sed 's/.*-//'} }
|
2007-02-23 06:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
fn proglist {
|
2007-02-26 07:29:16 +03:00
|
|
|
/bin/ls -lL `{echo $* | sed 'y/ /:'} >[2]/dev/null \
|
|
|
|
| awk '$1 ~ /^[^d].*x/ { print $NF }' \
|
|
|
|
| sort | uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
fn getfuns {
|
|
|
|
env | sed -n 's/^fn#'^$1^'-([^=]+).*/\1/p'
|
2007-02-23 06:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn actionlist {
|
2007-02-26 07:29:16 +03:00
|
|
|
{ proglist $WMII_CONFPATH
|
|
|
|
getfuns Action
|
2007-02-23 06:36:50 +03:00
|
|
|
} | sort | uniq
|
|
|
|
}
|
|
|
|
|
2007-02-26 07:29:16 +03:00
|
|
|
fn initkeys {
|
|
|
|
getfuns Key | wmiir write /keys
|
|
|
|
}
|
|
|
|
|
2007-02-23 06:36:50 +03:00
|
|
|
fn read_tags {
|
|
|
|
wmiir ls /tag | sed 's,/,,; /^sel$/d'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_command {
|
2007-02-26 07:29:16 +03:00
|
|
|
@{ rfork ens
|
|
|
|
path=$oldpath
|
|
|
|
eval exec $* </dev/null
|
|
|
|
}
|
2007-02-23 06:36:50 +03:00
|
|
|
}
|
|
|
|
|
2007-02-26 07:29:16 +03:00
|
|
|
# Source Overrides
|
|
|
|
. <{awk '/^# Overrides/, 0' $local}
|
2007-02-24 03:50:02 +03:00
|
|
|
|
|
|
|
# WM Configuration
|
|
|
|
wmiir write /ctl <<!
|
|
|
|
grabmod $MODKEY
|
|
|
|
border 2
|
|
|
|
font $WMII_FONT
|
|
|
|
focuscolors $WMII_FOCUSCOLORS
|
|
|
|
normcolors $WMII_NORMCOLORS
|
|
|
|
!
|
|
|
|
|
2007-02-23 06:36:50 +03:00
|
|
|
# Misc Setup
|
|
|
|
xsetroot -solid $WMII_BACKGROUND
|
|
|
|
Action status &
|
|
|
|
progs_file=$WMII_NS_DIR/proglist.$pid
|
|
|
|
proglist $PATH >$progs_file &
|
|
|
|
|
2007-02-26 07:29:16 +03:00
|
|
|
# Tag Bar Setup
|
2007-02-23 09:53:08 +03:00
|
|
|
ifs='#
|
2007-02-26 07:29:16 +03:00
|
|
|
'{ for(bar in `{wmiir ls /lbar})
|
2007-02-23 06:36:50 +03:00
|
|
|
wmiir remove /lbar/$bar
|
|
|
|
seltag=`{wmiir read /tag/sel/ctl}
|
2007-02-26 07:29:16 +03:00
|
|
|
for(tag in `{read_tags}) {
|
2007-02-23 06:36:50 +03:00
|
|
|
if(~ $tag $seltag)
|
2007-02-23 08:07:30 +03:00
|
|
|
echo $WMII_FOCUSCOLORS $tag | wmiir create /lbar/$tag
|
2007-02-23 06:36:50 +03:00
|
|
|
if not
|
|
|
|
echo $WMII_NORMCOLORS $tag | wmiir create /lbar/$tag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-26 07:29:16 +03:00
|
|
|
# Keygrab Setup
|
|
|
|
initkeys
|
2007-02-23 06:36:50 +03:00
|
|
|
|
|
|
|
if(echo Start wmiirc | ! wmiir write /event >[2]/dev/null)
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
# Event Loop
|
|
|
|
wmiir read /event |
|
|
|
|
while(*=`{read}) {
|
|
|
|
event = $1; shift
|
2007-02-26 07:29:16 +03:00
|
|
|
Event-$event $* >[2]/dev/null
|
2007-02-23 06:36:50 +03:00
|
|
|
}
|