wmii

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

commit 666c5cfa0573dacad05c084b2036a64af8cf1592
parent ca94ccabed5efb731fe6040504b0cc2b4283e490
Author: Kris Maglione <jg@suckless.org>
Date:   Mon, 26 Mar 2007 23:16:36 -0400

Tell hg that I've renamed the config scripts (SCM is a bitch).

Diffstat:
rc/rc.wmii | 241-------------------------------------------------------------------------------
rc/rc.wmii.rc | 241+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rc/welcome | 56--------------------------------------------------------
rc/welcome.sh | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rc/wmiirc | 239-------------------------------------------------------------------------------
rc/wmiirc.sh | 239+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 536 insertions(+), 536 deletions(-)

diff --git a/rc/rc.wmii b/rc/rc.wmii @@ -1,241 +0,0 @@ -#!/usr/bin/env wmii9rc -# WMII Configuration - -oldpath=$path -path=($PLAN9/bin $path) - -if(echo $0 | grep -vs '/rc.wmii$') { - echo Fatal: This file should only be run as rc.wmii >[1=2] - exits badname -} - -MODKEY=Mod1 -UP=k -DOWN=j -LEFT=h -RIGHT=l - -WMII_FONT='fixed' -WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F') -WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F') -WMII_BACKGROUND='#333333' - -WMII_TERM=(xterm) - -fn wmiimenu { - dmenu -b -fn $WMII_FONT \ - -nf $WMII_NORMCOLORS(1) -nb $WMII_NORMCOLORS(2) \ - -sf $WMII_FOCUSCOLORS(1) -sb $WMII_FOCUSCOLORS(2) -} - -fn 9menu { - wmii9menu -font $WMII_FONT \ - -^(nf nb br)^$WMII_NORMCOLORS \ - -^(sf sb br)^$WMII_FOCUSCOLORS $* -} - -fn config_whatis { - confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'} - prog=$1; shift - echo `{{path=$confpath whatis $prog} | grep -v '=|^fn '} $* -} - -# Source Variables, &c -local = `{config_whatis rc.wmii.local} -. <{awk '//; /^# Overrides/ { exit }' $local </dev/null} - -# Column Rules -wmiir write /colrules <<! -/./ -> 60+40 -! - -# Tagging Rules -wmiir write /tagrules <<! -/XMMS.*/ -> ~ -/MPlayer.*/ -> ~ -/.*/ -> ! -/.*/ -> 1 -! - -# Status Bar Info -fn status { - echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date} -} - -# View Titles -fn viewtitle { echo $* } - -# Events -fn Event-Start { - switch($1) { - case wmiirc - rm -f $progs_file - exit - } -} - -fn Event-Key { eval Key-$1 $1 } - -fn Event-CreateTag { echo $WMII_NORMCOLORS `{viewtitle $*} | wmiir create /lbar/$"* } -fn Event-DestroyTag { wmiir remove /lbar/$"* } -fn Event-FocusTag { wmiir xwrite /lbar/$"* $WMII_FOCUSCOLORS `{viewtitle $*} } -fn Event-UnfocusTag { wmiir xwrite /lbar/$"* $WMII_NORMCOLORS `{viewtitle $*} } -fn Event-UrgentTag { shift; wmiir xwrite /lbar/$"* '*'$"* } -fn Event-NotUrgentTag { shift; wmiir xwrite /lbar/$"* $"* } - -fn Event-LeftBarClick { shift; wmiir xwrite /ctl view $* } - -menulast = '' -fn Event-ClientMouseDown { - client = $1; button = $2 - if(~ $button 3) { - do=`{9menu -initial $menulast Nop Delete} - switch($do) { - case Delete - wmiir xwrite /client/$client/ctl kill - } - if(! ~ $#do 0) - menulast = $do; - } -} - -# Actions -fn Action { - action=$1; shift - if(whatis Action-$action | grep -s '^fn ') { - Action-$action $* & - };if not { - run_command `{config_whatis $action} $* & - } -} -fn Action-rehash { proglist $PATH >$progs_file } -fn Action-quit { wmiir xwrite /ctl quit } -fn Action-status { - flag x - - flag r - - 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 { - switch(`{wmiir read /keys | wc -l}) { - case 0 1 - initkeys - wmiir xwrite /ctl grabmod $MODKEY - case * - wmiir xwrite /keys $MODKEY-Control-t - wmiir xwrite /ctl grabmod Mod3 - } -} - -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} & } -fn Key-$MODKEY-Shift-t { - wmiir xwrite /client/`{wmiir read /client/sel/ctl}^/tags `{read_tags | wmiimenu} & -} - -for(i in `{seq 0 9}) { - 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/.*-//'} } -} - -# Functions -fn proglist { - /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' -} - -fn actionlist { - { proglist $WMII_CONFPATH - getfuns Action - } | sort | uniq -} - -fn initkeys { - getfuns Key | wmiir write /keys -} - -fn read_tags { - wmiir ls /tag | sed 's,/,,; /^sel$/d' -} - -fn run_command { - @{ rfork ns - path=$oldpath - eval exec $* - } -} - -# Source Overrides -. <{awk '/^# Overrides/, 0' $local </dev/null} - -# WM Configuration -wmiir write /ctl <<! -grabmod $MODKEY -border 2 -font $WMII_FONT -focuscolors $WMII_FOCUSCOLORS -normcolors $WMII_NORMCOLORS -! - -# Misc Setup -xsetroot -solid $WMII_BACKGROUND -Action status & -progs_file=$WMII_NS_DIR/proglist.$pid -proglist $PATH >$progs_file & - -# Tag Bar Setup -ifs='# -'{ for(bar in `{comm -23 <{wmiir ls /lbar} <{read_tags}}) - wmiir remove /lbar/$bar - seltag=`{wmiir read /tag/sel/ctl} - for(tag in `{read_tags}) { - if(~ $tag $seltag) - echo $WMII_FOCUSCOLORS `{viewtitle $tag} | wmiir create /lbar/$tag - if not - echo $WMII_NORMCOLORS `{viewtitle $tag} | wmiir create /lbar/$tag - } -} - -# Keygrab Setup -initkeys - -if(echo Start wmiirc | ! wmiir write /event >[2]/dev/null) - exit 1 - -# Event Loop -wmiir read /event | - while(*=`{read}) { - event = $1; shift - Event-$event $* - } >[2]/dev/null </dev/null diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc @@ -0,0 +1,241 @@ +#!/usr/bin/env wmii9rc +# WMII Configuration + +oldpath=$path +path=($PLAN9/bin $path) + +if(echo $0 | grep -vs '/rc.wmii$') { + echo Fatal: This file should only be run as rc.wmii >[1=2] + exits badname +} + +MODKEY=Mod1 +UP=k +DOWN=j +LEFT=h +RIGHT=l + +WMII_FONT='fixed' +WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F') +WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F') +WMII_BACKGROUND='#333333' + +WMII_TERM=(xterm) + +fn wmiimenu { + dmenu -b -fn $WMII_FONT \ + -nf $WMII_NORMCOLORS(1) -nb $WMII_NORMCOLORS(2) \ + -sf $WMII_FOCUSCOLORS(1) -sb $WMII_FOCUSCOLORS(2) +} + +fn 9menu { + wmii9menu -font $WMII_FONT \ + -^(nf nb br)^$WMII_NORMCOLORS \ + -^(sf sb br)^$WMII_FOCUSCOLORS $* +} + +fn config_whatis { + confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'} + prog=$1; shift + echo `{{path=$confpath whatis $prog} | grep -v '=|^fn '} $* +} + +# Source Variables, &c +local = `{config_whatis rc.wmii.local} +. <{awk '//; /^# Overrides/ { exit }' $local </dev/null} + +# Column Rules +wmiir write /colrules <<! +/./ -> 60+40 +! + +# Tagging Rules +wmiir write /tagrules <<! +/XMMS.*/ -> ~ +/MPlayer.*/ -> ~ +/.*/ -> ! +/.*/ -> 1 +! + +# Status Bar Info +fn status { + echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date} +} + +# View Titles +fn viewtitle { echo $* } + +# Events +fn Event-Start { + switch($1) { + case wmiirc + rm -f $progs_file + exit + } +} + +fn Event-Key { eval Key-$1 $1 } + +fn Event-CreateTag { echo $WMII_NORMCOLORS `{viewtitle $*} | wmiir create /lbar/$"* } +fn Event-DestroyTag { wmiir remove /lbar/$"* } +fn Event-FocusTag { wmiir xwrite /lbar/$"* $WMII_FOCUSCOLORS `{viewtitle $*} } +fn Event-UnfocusTag { wmiir xwrite /lbar/$"* $WMII_NORMCOLORS `{viewtitle $*} } +fn Event-UrgentTag { shift; wmiir xwrite /lbar/$"* '*'$"* } +fn Event-NotUrgentTag { shift; wmiir xwrite /lbar/$"* $"* } + +fn Event-LeftBarClick { shift; wmiir xwrite /ctl view $* } + +menulast = '' +fn Event-ClientMouseDown { + client = $1; button = $2 + if(~ $button 3) { + do=`{9menu -initial $menulast Nop Delete} + switch($do) { + case Delete + wmiir xwrite /client/$client/ctl kill + } + if(! ~ $#do 0) + menulast = $do; + } +} + +# Actions +fn Action { + action=$1; shift + if(whatis Action-$action | grep -s '^fn ') { + Action-$action $* & + };if not { + run_command `{config_whatis $action} $* & + } +} +fn Action-rehash { proglist $PATH >$progs_file } +fn Action-quit { wmiir xwrite /ctl quit } +fn Action-status { + flag x - + flag r - + 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 { + switch(`{wmiir read /keys | wc -l}) { + case 0 1 + initkeys + wmiir xwrite /ctl grabmod $MODKEY + case * + wmiir xwrite /keys $MODKEY-Control-t + wmiir xwrite /ctl grabmod Mod3 + } +} + +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} & } +fn Key-$MODKEY-Shift-t { + wmiir xwrite /client/`{wmiir read /client/sel/ctl}^/tags `{read_tags | wmiimenu} & +} + +for(i in `{seq 0 9}) { + 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/.*-//'} } +} + +# Functions +fn proglist { + /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' +} + +fn actionlist { + { proglist $WMII_CONFPATH + getfuns Action + } | sort | uniq +} + +fn initkeys { + getfuns Key | wmiir write /keys +} + +fn read_tags { + wmiir ls /tag | sed 's,/,,; /^sel$/d' +} + +fn run_command { + @{ rfork ns + path=$oldpath + eval exec $* + } +} + +# Source Overrides +. <{awk '/^# Overrides/, 0' $local </dev/null} + +# WM Configuration +wmiir write /ctl <<! +grabmod $MODKEY +border 2 +font $WMII_FONT +focuscolors $WMII_FOCUSCOLORS +normcolors $WMII_NORMCOLORS +! + +# Misc Setup +xsetroot -solid $WMII_BACKGROUND +Action status & +progs_file=$WMII_NS_DIR/proglist.$pid +proglist $PATH >$progs_file & + +# Tag Bar Setup +ifs='# +'{ for(bar in `{comm -23 <{wmiir ls /lbar} <{read_tags}}) + wmiir remove /lbar/$bar + seltag=`{wmiir read /tag/sel/ctl} + for(tag in `{read_tags}) { + if(~ $tag $seltag) + echo $WMII_FOCUSCOLORS `{viewtitle $tag} | wmiir create /lbar/$tag + if not + echo $WMII_NORMCOLORS `{viewtitle $tag} | wmiir create /lbar/$tag + } +} + +# Keygrab Setup +initkeys + +if(echo Start wmiirc | ! wmiir write /event >[2]/dev/null) + exit 1 + +# Event Loop +wmiir read /event | + while(*=`{read}) { + event = $1; shift + Event-$event $* + } >[2]/dev/null </dev/null diff --git a/rc/welcome b/rc/welcome @@ -1,56 +0,0 @@ -#!/bin/sh -# display a welcome message that contains the wmii tutorial - -xmessage -file - <<'EOF' -Welcome to wmii, the non-wimp environment of the Suckless Project. - -This is a small step by step tutorial, intended to make you a -little bit familiar with wmii. - -From here on, keypresses will be described such that M-a refers to -pressing $MODKEY and a at the same time. $MODKEY refers to a -configuratin variable which contains the Alt key by default. - -Let's go! - -- Start two xterms by pressing M-Return twice. -- Switch between the three windows: M-j, M-k, - M-h, M-l - If you prefer to use the mouse, then just move the pointer to - the desired window. -- Try the other column modes: M-s for stack mode, - M-m for max mode Press M-d to return to default - mode. -- Create a new column with: M-Shift-l - This moves the client rightwards. -- Tag the selected client with another tag: M-Shift-2 - IMPORTANT: before you do the next step, note that you - can select the current tag with M-1. -- Select the new tag: M-2 -- Select the floating area: M-Space -- Open the programs menu: M-p - Type 'xclock' and press Enter. -- Move the xclock window: Hold $MODKEY, left-click on the - window and move the cursor around. -- Resize the xclock window: Hold $MODKEY, right-click the - window and move the cursor around. -- Open the actions menu: M-a - Rerun wmiirc by selecting 'wmiirc'. -- We'll now have a look at the internal filesystem used by - wmii. Executing - wmiir ls / - in the shell of the terminal will list all the files in the - root directory. - Entries ending with / are directories. - If you are curious, you can now dig deeper into the - directory trees. For instance, - wmiir ls /rbar/ - will show you the content of the right half of the bar. - -We hope that these steps gave you an idea of how wmii works. -You can reread them at any time by pressing $MODKEY-a and -selecting 'welcome'. - -You should now take a look at the wmii(1) man page. A FAQ is -available at <http://wmii.suckless.org>. -EOF diff --git a/rc/welcome.sh b/rc/welcome.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# display a welcome message that contains the wmii tutorial + +xmessage -file - <<'EOF' +Welcome to wmii, the non-wimp environment of the Suckless Project. + +This is a small step by step tutorial, intended to make you a +little bit familiar with wmii. + +From here on, keypresses will be described such that M-a refers to +pressing $MODKEY and a at the same time. $MODKEY refers to a +configuratin variable which contains the Alt key by default. + +Let's go! + +- Start two xterms by pressing M-Return twice. +- Switch between the three windows: M-j, M-k, + M-h, M-l + If you prefer to use the mouse, then just move the pointer to + the desired window. +- Try the other column modes: M-s for stack mode, + M-m for max mode Press M-d to return to default + mode. +- Create a new column with: M-Shift-l + This moves the client rightwards. +- Tag the selected client with another tag: M-Shift-2 + IMPORTANT: before you do the next step, note that you + can select the current tag with M-1. +- Select the new tag: M-2 +- Select the floating area: M-Space +- Open the programs menu: M-p + Type 'xclock' and press Enter. +- Move the xclock window: Hold $MODKEY, left-click on the + window and move the cursor around. +- Resize the xclock window: Hold $MODKEY, right-click the + window and move the cursor around. +- Open the actions menu: M-a + Rerun wmiirc by selecting 'wmiirc'. +- We'll now have a look at the internal filesystem used by + wmii. Executing + wmiir ls / + in the shell of the terminal will list all the files in the + root directory. + Entries ending with / are directories. + If you are curious, you can now dig deeper into the + directory trees. For instance, + wmiir ls /rbar/ + will show you the content of the right half of the bar. + +We hope that these steps gave you an idea of how wmii works. +You can reread them at any time by pressing $MODKEY-a and +selecting 'welcome'. + +You should now take a look at the wmii(1) man page. A FAQ is +available at <http://wmii.suckless.org>. +EOF diff --git a/rc/wmiirc b/rc/wmiirc @@ -1,238 +0,0 @@ -#!/bin/sh -# Configure wmii -set -f - -# Configuration Variables -MODKEY=Mod1 -UP=k -DOWN=j -LEFT=h -RIGHT=l - -# Colors tuples are "<text> <background> <border>" -WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F' -WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F' -WMII_BACKGROUND='#333333' -WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*' - -set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS) - -WMII_MENU="dmenu -b -fn $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5" -WMII_9MENU="wmii9menu -font $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5 -br $6" -WMII_TERM="xterm" - -export WMII_MENU WMII_9MENU WMII_FONT WMII_TERM -export WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS - -# Column Rules -wmiir write /colrules <<EOF -/.*/ -> 58+42 -EOF - -# Tagging Rules -wmiir write /tagrules <<EOF -/XMMS.*/ -> ~ -/MPlayer.*/ -> ~ -/.*/ -> ! -/.*/ -> 1 -EOF - -# Event processing -# Status Bar Info -status() { - echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date) -} - -eventstuff() { - cat <<'EOF' -# Events -Event Start - case "$1" in - wmiirc) - exit; - esac -Event Key - fn=$(echo $@ | sed 's/[^a-zA-Z_0-9]/_/g') - Key_$fn $@ -Event CreateTag - echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@" -Event DestroyTag - wmiir remove "/lbar/$@" -Event FocusTag - wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$@" -Event UnfocusTag - wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$@" -Event UrgentTag - shift - wmiir xwrite "/lbar/$@" "*$@" -Event NotUrgentTag - shift - wmiir xwrite "/lbar/$@" "$@" -Event LeftBarClick - shift - wmiir xwrite /ctl view "$@" -# Actions -Action quit - wmiir xwrite /ctl quit -Action rehash - proglist $PATH >$PROGS_FILE -Action status - set +xv - if wmiir remove /rbar/status 2>/dev/null; then - sleep 2 - fi - echo "$WMII_NORMCOLORS" | wmiir create /rbar/status - while status | wmiir write /rbar/status; do - sleep 1 - done -Event ClientMouseDown - client=$1; button=$2 - case "$button" in - 3) - do=$($WMII_9MENU -initial "${menulast:-SomeRandomName}" Nop Delete) - case "$do" in - Delete) - wmiir xwrite /client/$client/ctl kill - esac - menulast=${do:-"$menulast"} - esac -EOF - cat <<EOF -# Key Bindings -Key $MODKEY-Control-t - case \$(wmiir read /keys | wc -l | tr -d ' \t\n') in - 0|1) - echo -n \$Keys | tr ' ' '\012' | wmiir write /keys - wmiir xwrite /ctl grabmod $MODKEY;; - *) - wmiir xwrite /keys $MODKEY-Control-t - wmiir xwrite /ctl grabmod Mod3;; - esac -Key $MODKEY-$LEFT - wmiir xwrite /tag/sel/ctl select left -Key $MODKEY-$RIGHT - wmiir xwrite /tag/sel/ctl select right -Key $MODKEY-$DOWN - wmiir xwrite /tag/sel/ctl select down -Key $MODKEY-$UP - wmiir xwrite /tag/sel/ctl select up -Key $MODKEY-space - wmiir xwrite /tag/sel/ctl select toggle -Key $MODKEY-d - wmiir xwrite /tag/sel/ctl colmode sel default -Key $MODKEY-s - wmiir xwrite /tag/sel/ctl colmode sel stack -Key $MODKEY-m - wmiir xwrite /tag/sel/ctl colmode sel max -Key $MODKEY-a - Action \$(actionlist | \$WMII_MENU) & -Key $MODKEY-p - sh -c "\$(\$WMII_MENU <\$PROGS_FILE)" & -Key $MODKEY-t - wmiir xwrite /ctl "view \$(tagsmenu)" & -Key $MODKEY-Return - $WMII_TERM & -Key $MODKEY-Shift-$LEFT - wmiir xwrite /tag/sel/ctl send sel left -Key $MODKEY-Shift-$RIGHT - wmiir xwrite /tag/sel/ctl send sel right -Key $MODKEY-Shift-$DOWN - wmiir xwrite /tag/sel/ctl send sel down -Key $MODKEY-Shift-$UP - wmiir xwrite /tag/sel/ctl send sel up -Key $MODKEY-Shift-space - wmiir xwrite /tag/sel/ctl send sel toggle -Key $MODKEY-Shift-c - wmiir xwrite /client/sel/ctl kill -Key $MODKEY-Shift-t - wmiir xwrite "/client/\$(wmiir read /client/sel/ctl)/tags" "\$(tagsmenu)" & -EOF - for i in 0 1 2 3 4 5 6 7 8 9; do - cat << EOF -Key $MODKEY-$i - wmiir xwrite /ctl view "$i" -Key $MODKEY-Shift-$i - wmiir xwrite /client/sel/tags "$i" -EOF - done -} - -IFS='' -eval $(eventstuff | wmiiloop) -unset IFS - -# 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 -n $Actions | tr ' ' '\012' - } | sort | uniq -} - -tagsmenu() { - wmiir ls /tag | sed "s|/||; /^sel$/d" | $WMII_MENU -} - -conf_which() { - prog=$(PATH="$WMII_CONFPATH:$PATH" which $1) - shift - if [ -n "$prog" ]; then - $prog - fi -} - -Action() { - action=$1; shift - if [ -n "$action" ]; then - Action_$action $@ || conf_which $action $@ - fi -} - -# Misc -PROGS_FILE="$WMII_NS_DIR/.proglist" -Action status & -proglist $PATH >$PROGS_FILE & - -xsetroot -solid "$WMII_BACKGROUND" & - -# WM Configuration -wmiir write /ctl << EOF -font $WMII_FONT -focuscolors $WMII_FOCUSCOLORS -normcolors $WMII_NORMCOLORS -grabmod $MODKEY -border 1 -EOF - -# 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 - -# Stop any running instances of wmiirc -echo Start wmiirc | wmiir write /event || exit 1 - -wmiir read /event | -while read event; do - set -- $event - event=$1; shift - Event_$event $@ 2>/dev/null -done- \ No newline at end of file diff --git a/rc/wmiirc.sh b/rc/wmiirc.sh @@ -0,0 +1,238 @@ +#!/bin/sh +# Configure wmii +set -f + +# Configuration Variables +MODKEY=Mod1 +UP=k +DOWN=j +LEFT=h +RIGHT=l + +# Colors tuples are "<text> <background> <border>" +WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F' +WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F' +WMII_BACKGROUND='#333333' +WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*' + +set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS) + +WMII_MENU="dmenu -b -fn $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5" +WMII_9MENU="wmii9menu -font $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5 -br $6" +WMII_TERM="xterm" + +export WMII_MENU WMII_9MENU WMII_FONT WMII_TERM +export WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS + +# Column Rules +wmiir write /colrules <<EOF +/.*/ -> 58+42 +EOF + +# Tagging Rules +wmiir write /tagrules <<EOF +/XMMS.*/ -> ~ +/MPlayer.*/ -> ~ +/.*/ -> ! +/.*/ -> 1 +EOF + +# Event processing +# Status Bar Info +status() { + echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date) +} + +eventstuff() { + cat <<'EOF' +# Events +Event Start + case "$1" in + wmiirc) + exit; + esac +Event Key + fn=$(echo $@ | sed 's/[^a-zA-Z_0-9]/_/g') + Key_$fn $@ +Event CreateTag + echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@" +Event DestroyTag + wmiir remove "/lbar/$@" +Event FocusTag + wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$@" +Event UnfocusTag + wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$@" +Event UrgentTag + shift + wmiir xwrite "/lbar/$@" "*$@" +Event NotUrgentTag + shift + wmiir xwrite "/lbar/$@" "$@" +Event LeftBarClick + shift + wmiir xwrite /ctl view "$@" +# Actions +Action quit + wmiir xwrite /ctl quit +Action rehash + proglist $PATH >$PROGS_FILE +Action status + set +xv + if wmiir remove /rbar/status 2>/dev/null; then + sleep 2 + fi + echo "$WMII_NORMCOLORS" | wmiir create /rbar/status + while status | wmiir write /rbar/status; do + sleep 1 + done +Event ClientMouseDown + client=$1; button=$2 + case "$button" in + 3) + do=$($WMII_9MENU -initial "${menulast:-SomeRandomName}" Nop Delete) + case "$do" in + Delete) + wmiir xwrite /client/$client/ctl kill + esac + menulast=${do:-"$menulast"} + esac +EOF + cat <<EOF +# Key Bindings +Key $MODKEY-Control-t + case \$(wmiir read /keys | wc -l | tr -d ' \t\n') in + 0|1) + echo -n \$Keys | tr ' ' '\012' | wmiir write /keys + wmiir xwrite /ctl grabmod $MODKEY;; + *) + wmiir xwrite /keys $MODKEY-Control-t + wmiir xwrite /ctl grabmod Mod3;; + esac +Key $MODKEY-$LEFT + wmiir xwrite /tag/sel/ctl select left +Key $MODKEY-$RIGHT + wmiir xwrite /tag/sel/ctl select right +Key $MODKEY-$DOWN + wmiir xwrite /tag/sel/ctl select down +Key $MODKEY-$UP + wmiir xwrite /tag/sel/ctl select up +Key $MODKEY-space + wmiir xwrite /tag/sel/ctl select toggle +Key $MODKEY-d + wmiir xwrite /tag/sel/ctl colmode sel default +Key $MODKEY-s + wmiir xwrite /tag/sel/ctl colmode sel stack +Key $MODKEY-m + wmiir xwrite /tag/sel/ctl colmode sel max +Key $MODKEY-a + Action \$(actionlist | \$WMII_MENU) & +Key $MODKEY-p + sh -c "\$(\$WMII_MENU <\$PROGS_FILE)" & +Key $MODKEY-t + wmiir xwrite /ctl "view \$(tagsmenu)" & +Key $MODKEY-Return + $WMII_TERM & +Key $MODKEY-Shift-$LEFT + wmiir xwrite /tag/sel/ctl send sel left +Key $MODKEY-Shift-$RIGHT + wmiir xwrite /tag/sel/ctl send sel right +Key $MODKEY-Shift-$DOWN + wmiir xwrite /tag/sel/ctl send sel down +Key $MODKEY-Shift-$UP + wmiir xwrite /tag/sel/ctl send sel up +Key $MODKEY-Shift-space + wmiir xwrite /tag/sel/ctl send sel toggle +Key $MODKEY-Shift-c + wmiir xwrite /client/sel/ctl kill +Key $MODKEY-Shift-t + wmiir xwrite "/client/\$(wmiir read /client/sel/ctl)/tags" "\$(tagsmenu)" & +EOF + for i in 0 1 2 3 4 5 6 7 8 9; do + cat << EOF +Key $MODKEY-$i + wmiir xwrite /ctl view "$i" +Key $MODKEY-Shift-$i + wmiir xwrite /client/sel/tags "$i" +EOF + done +} + +IFS='' +eval $(eventstuff | wmiiloop) +unset IFS + +# 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 -n $Actions | tr ' ' '\012' + } | sort | uniq +} + +tagsmenu() { + wmiir ls /tag | sed "s|/||; /^sel$/d" | $WMII_MENU +} + +conf_which() { + prog=$(PATH="$WMII_CONFPATH:$PATH" which $1) + shift + if [ -n "$prog" ]; then + $prog + fi +} + +Action() { + action=$1; shift + if [ -n "$action" ]; then + Action_$action $@ || conf_which $action $@ + fi +} + +# Misc +PROGS_FILE="$WMII_NS_DIR/.proglist" +Action status & +proglist $PATH >$PROGS_FILE & + +xsetroot -solid "$WMII_BACKGROUND" & + +# WM Configuration +wmiir write /ctl << EOF +font $WMII_FONT +focuscolors $WMII_FOCUSCOLORS +normcolors $WMII_NORMCOLORS +grabmod $MODKEY +border 1 +EOF + +# 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 + +# Stop any running instances of wmiirc +echo Start wmiirc | wmiir write /event || exit 1 + +wmiir read /event | +while read event; do + set -- $event + event=$1; shift + Event_$event $@ 2>/dev/null +done+ \ No newline at end of file