2007-05-10 22:30:22 +04:00
|
|
|
#!sh
|
|
|
|
# WMII Configuration
|
2007-06-26 03:51:10 +04:00
|
|
|
load std string regex expr echo
|
2007-05-10 22:30:22 +04:00
|
|
|
|
2007-06-26 03:51:10 +04:00
|
|
|
argv0 = $0
|
|
|
|
|
|
|
|
#mount -Aa {os dial unix!/tmp/ns.kris.:1/wmii >[1=0]} / || raise mount
|
|
|
|
#mount -Aa {styxmon {os rc -c 'dial $WMII_ADDRESS' >[1=0]}} / || raise mount
|
|
|
|
mount -Aa {os rc -c 'dial $WMII_ADDRESS' >[1=0]} / || raise mount
|
2007-05-10 22:30:22 +04:00
|
|
|
|
|
|
|
MODKEY=Mod1
|
|
|
|
UP=k
|
|
|
|
DOWN=j
|
|
|
|
LEFT=h
|
|
|
|
RIGHT=l
|
|
|
|
|
|
|
|
WMII_FONT=fixed
|
2007-06-26 03:51:10 +04:00
|
|
|
WMII_FONT='drift,-*-fixed-*-*-*-*-9-*-*-*-*-*-*-*'
|
2007-05-10 22:30:22 +04:00
|
|
|
WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
|
|
|
|
WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
|
|
|
|
WMII_BACKGROUND='#333333'
|
|
|
|
|
|
|
|
WMII_TERM=urxvt
|
|
|
|
|
|
|
|
fn wmiimenu {
|
2007-06-26 03:51:10 +04:00
|
|
|
(nf nb nil sf sb nil) := ($WMII_NORMCOLORS $WMII_FOCUSCOLORS)
|
|
|
|
os -d ${hostenv HOME} (
|
|
|
|
dmenu -b -fn $WMII_FONT
|
|
|
|
-nf $nf -nb $nb -sf $sf -sb $sb)
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn 9menu {
|
2007-06-26 03:51:10 +04:00
|
|
|
os -d ${hostenv HOME} (
|
|
|
|
wmii9menu -font ${hd ${split , $WMII_FONT}}
|
2007-05-10 22:30:22 +04:00
|
|
|
-^(nf nb br)^$WMII_NORMCOLORS
|
|
|
|
-^(sf sb br)^$WMII_FOCUSCOLORS $*)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Column Rules
|
|
|
|
echo '/./ -> 60+40' >/colrules
|
|
|
|
|
|
|
|
# Tagging Rules
|
2007-06-26 03:51:10 +04:00
|
|
|
echo '
|
|
|
|
/Firefox/ -> www
|
2007-05-10 22:30:22 +04:00
|
|
|
/XMMS.*/ -> ~
|
|
|
|
/MPlayer.*/ -> ~
|
|
|
|
/.*/ -> !
|
|
|
|
/.*/ -> 1
|
2007-06-26 03:51:10 +04:00
|
|
|
' >/tagrules
|
2007-05-10 22:30:22 +04:00
|
|
|
|
|
|
|
subfn seq {
|
2007-06-26 03:51:10 +04:00
|
|
|
result=${expr $* seq}
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
subfn hostenv {
|
|
|
|
arg := $"*
|
2007-06-26 03:51:10 +04:00
|
|
|
result="{os rc -c 'echo -n $'^$arg </dev/null}
|
|
|
|
}
|
|
|
|
|
|
|
|
subfn ftl {
|
|
|
|
result=${tl $*}
|
|
|
|
result=$"result
|
|
|
|
}
|
|
|
|
|
|
|
|
subfn lines {
|
|
|
|
ifs := "{echo}
|
|
|
|
arg = $*
|
|
|
|
result = `{$arg}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn dprint {
|
|
|
|
arg := $*
|
|
|
|
or {~ $#debug 0} {~ $debug '' 0} { echo $arg }
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Status Bar Info
|
|
|
|
fn status {
|
|
|
|
echo ${re mg '[0-9]+\.[0-9]+' "{os uptime}} '|' `{date}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Events
|
|
|
|
fn Event-Start {
|
2007-06-26 03:51:10 +04:00
|
|
|
if {~ $1 wmiirc} {
|
2007-05-10 22:30:22 +04:00
|
|
|
rm -f $progs_file
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn Event-Key {
|
2007-06-26 03:51:10 +04:00
|
|
|
dprint Key-$1
|
2007-05-10 22:30:22 +04:00
|
|
|
Key-$1 $1
|
|
|
|
}
|
|
|
|
|
2007-06-26 03:51:10 +04:00
|
|
|
fn Event-CreateTag { echo $WMII_NORMCOLORS $* > /lbar/$"* }
|
2007-05-10 22:30:22 +04:00
|
|
|
fn Event-DestroyTag { rm /lbar/$"* }
|
|
|
|
fn Event-FocusTag { echo $WMII_FOCUSCOLORS $* > /lbar/$"* }
|
|
|
|
fn Event-UnfocusTag { echo $WMII_NORMCOLORS $* > /lbar/$"* }
|
2007-06-26 03:51:10 +04:00
|
|
|
fn Event-UrgentTag { echo '*'${ftl $*} > /lbar/${ftl $*} }
|
|
|
|
fn Event-NotUrgentTag { echo ${tl $*} > /lbar/${ftl $*} }
|
2007-05-10 22:30:22 +04:00
|
|
|
|
2007-06-26 03:51:10 +04:00
|
|
|
fn Event-LeftBarClick {
|
|
|
|
(button name) := $*
|
|
|
|
if {~ $button 1} { echo view $name >/ctl }
|
|
|
|
}
|
|
|
|
fn Event-LeftBarMouseDown {
|
|
|
|
(button name) := $*
|
|
|
|
if {~ $button 3} { echo view "{9menu ${lines read_tags}} >/ctl & }
|
|
|
|
}
|
2007-05-10 22:30:22 +04:00
|
|
|
lastcmd=''
|
|
|
|
fn Event-ClientMouseDown {
|
|
|
|
(client button) := $*
|
2007-06-26 03:51:10 +04:00
|
|
|
if {~ $button 3} {
|
|
|
|
lastcmd = `{9menu -initial $lastcmd Nop Delete Fullscreen}
|
|
|
|
cmp := {~ $lastcmd $*}
|
|
|
|
if {$cmp Nop} {
|
|
|
|
} {$cmp Delete} { echo kill >/client/$client/ctl
|
|
|
|
} {$cmp Fullscreen} { echo Fullscreen >/client/$client/ctl
|
|
|
|
}
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Actions
|
|
|
|
fn Action {
|
|
|
|
(action args) := $*
|
2007-06-26 03:51:10 +04:00
|
|
|
if {~ "{whatis Action-$action >[2]/dev/null} 'load std; fn '*} {
|
2007-05-10 22:30:22 +04:00
|
|
|
Action-$action $args
|
|
|
|
} {
|
2007-06-26 03:51:10 +04:00
|
|
|
run_command ${config_whatis $action} $args
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fn Action-quit { echo quit >>/ctl }
|
|
|
|
fn Action-rehash {
|
|
|
|
flag x -
|
|
|
|
proglist ${hostenv PATH} >$progs_file
|
|
|
|
}
|
|
|
|
fn Action-status {
|
2007-06-26 03:51:10 +04:00
|
|
|
flag x -
|
|
|
|
if {rm /rbar/status >[2]/dev/null} { sleep 1 }
|
2007-05-10 22:30:22 +04:00
|
|
|
echo $WMII_NORMCOLORS >/rbar/status
|
2007-06-26 03:51:10 +04:00
|
|
|
while {status >/rbar/status} { sleep 1 }
|
|
|
|
}
|
|
|
|
fn Action-sh.wmii {
|
|
|
|
os -b inferno $argv0 &
|
|
|
|
exit
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Key Bindings
|
|
|
|
fn Key-$MODKEY-Control-t {
|
|
|
|
if { ~ `{wc -l /keys} 0 1} {
|
|
|
|
initkeys
|
|
|
|
grabmod $MODKEY >/ctl
|
|
|
|
} {
|
|
|
|
echo $MODKEY-Control-t >/keys
|
|
|
|
echo grabmod Mod3 >/ctl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn Key-$MODKEY-$LEFT { echo select left >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-$RIGHT { echo select right >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-$UP { echo select up >/tag/sel/ctl }
|
2007-06-26 03:51:10 +04:00
|
|
|
fn Key-$MODKEY-$DOWN { echo select down >/tag/sel/ctl }
|
2007-05-10 22:30:22 +04:00
|
|
|
|
|
|
|
fn Key-$MODKEY-Shift-$LEFT { echo send sel left >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-Shift-$RIGHT { echo send sel right >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-Shift-$DOWN { echo send sel down >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-Shift-$UP { echo send sel up >/tag/sel/ctl }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-space { echo select toggle >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-Shift-space { echo send sel toggle >/tag/sel/ctl }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-d { echo colmode sel default >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-s { echo colmode sel stack >/tag/sel/ctl }
|
|
|
|
fn Key-$MODKEY-m { echo colmode sel max >/tag/sel/ctl }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-Shift-c { echo kill >/client/sel/ctl }
|
|
|
|
|
|
|
|
fn Key-$MODKEY-a { Action `{actionlist | wmiimenu} & }
|
2007-06-26 03:51:10 +04:00
|
|
|
fn Key-$MODKEY-p { run_command rc -c "{wmiimenu <$progs_file} & }
|
2007-05-10 22:30:22 +04:00
|
|
|
fn Key-$MODKEY-Return { run_command $WMII_TERM & }
|
|
|
|
fn Key-$MODKEY-t { echo view `{read_tags | wmiimenu} >/ctl & }
|
|
|
|
fn Key-$MODKEY-Shift-t {
|
|
|
|
sel := "{cat /client/sel/ctl}
|
|
|
|
read_tags | wmiimenu >/client/$sel/tags
|
|
|
|
}
|
|
|
|
|
2007-06-26 03:51:10 +04:00
|
|
|
fn next_tag {
|
|
|
|
os awk -v curtag'='${lines sed 1q /tag/sel/ctl} '
|
|
|
|
NR==1 {first = $0}
|
|
|
|
$0==curtag { if(getline) print $0; else print first; exit }'
|
|
|
|
}
|
|
|
|
fn Key-$MODKEY-n {
|
|
|
|
echo view `{read_tags | next_tag} >/ctl
|
|
|
|
}
|
|
|
|
fn Key-$MODKEY-b {
|
|
|
|
echo view `{read_tags | tail -r | next_tag} >/ctl
|
|
|
|
}
|
|
|
|
|
2007-05-10 22:30:22 +04:00
|
|
|
for(i in ${seq 0 9}) {
|
|
|
|
fn Key-$MODKEY-$i { echo view ${tl ${splitr $1 -}} >/ctl }
|
|
|
|
fn Key-Shift-$MODKEY-$i { echo ${tl ${splitr $1 -}} >/client/sel/tags}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
fn proglist {
|
2007-06-26 03:51:10 +04:00
|
|
|
os find ${split : $"*} -maxdepth 1 -type f | sed 's,.*/,,' | sort | uniq
|
|
|
|
#for(d in /n/local^${split : $"*}) {
|
|
|
|
# fs filter {mode -d} $d
|
|
|
|
#} | sed 's,.*/,,' | sort | uniq
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn getfuns {
|
2007-06-26 22:16:22 +04:00
|
|
|
ls -p /env | sed -n 's/^fn-' ^ $1 ^ '-//p'
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn actionlist {
|
|
|
|
{ rescue '*' {} {
|
|
|
|
proglist ${hostenv WMII_CONFPATH}
|
|
|
|
}
|
|
|
|
getfuns Action
|
|
|
|
} | sort | uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
fn initkeys {
|
|
|
|
getfuns Key >/keys
|
|
|
|
}
|
|
|
|
|
|
|
|
fn read_tags {
|
|
|
|
ls -p /tag | grep -v '^sel$'
|
|
|
|
}
|
|
|
|
|
|
|
|
subfn config_whatis {
|
2007-06-26 03:51:10 +04:00
|
|
|
result=${lines os rc -c 'PATH=$WMII_CONFPATH which $*' $*}
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run_command {
|
2007-06-26 03:51:10 +04:00
|
|
|
os -b -d ${hostenv HOME} $* &
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# WM Configuration
|
|
|
|
{
|
|
|
|
echo grabmod $MODKEY
|
|
|
|
echo border 2
|
|
|
|
echo font $WMII_FONT
|
|
|
|
echo focuscolors $WMII_FOCUSCOLORS
|
|
|
|
echo normcolors $WMII_NORMCOLORS
|
|
|
|
} >/ctl
|
|
|
|
|
|
|
|
# Misc Setup
|
|
|
|
os xsetroot -solid $WMII_BACKGROUND
|
|
|
|
Action status &
|
|
|
|
progs_file=/tmp/proglist.${pid}
|
|
|
|
Action rehash &
|
|
|
|
|
|
|
|
# Tag Bar Setup
|
2007-06-26 22:16:22 +04:00
|
|
|
seltag=${lines sed 1q /tag/sel/ctl}
|
2007-06-26 03:51:10 +04:00
|
|
|
comm -13 ${pipe from {read_tags}} ${pipe from {ls -p /lbar/*}} |
|
|
|
|
getlines { rm /lbar/$line }
|
2007-05-10 22:30:22 +04:00
|
|
|
read_tags | getlines {
|
|
|
|
if {~ $line $seltag} {
|
2007-06-26 03:51:10 +04:00
|
|
|
echo $WMII_FOCUSCOLORS $line
|
2007-05-10 22:30:22 +04:00
|
|
|
} {
|
2007-06-26 03:51:10 +04:00
|
|
|
echo $WMII_NORMCOLORS $line
|
|
|
|
} >/lbar/$line
|
2007-05-10 22:30:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Keygrab Setup
|
|
|
|
initkeys
|
|
|
|
|
|
|
|
echo Start wmiirc >/event
|
|
|
|
|
|
|
|
# Event Loop
|
|
|
|
getlines {
|
|
|
|
(event args) := ${split ' ' $line}
|
2007-06-26 03:51:10 +04:00
|
|
|
dprint Event-$event: $args
|
|
|
|
rescue '*' { dprint Exception: $exception } {
|
|
|
|
if {whatis Event-$event >/dev/null >[2=1]} {
|
|
|
|
Event-$event $args
|
|
|
|
}
|
|
|
|
} </dev/null
|
|
|
|
dprint loop
|
2007-05-10 22:30:22 +04:00
|
|
|
} </event
|
2007-06-26 22:16:22 +04:00
|
|
|
|