root/config/wmiirc

Revision 10:1854f90bc0ba, 5.5 kB (checked in by Paul Bissex <pb@…>, 13 months ago)

added my wmiirc, FWIW

  • Property exe set to *
Line 
1#!/bin/sh -f
2# wmii (http://wmii.suckless.org/) configuration file
3# Crudely customized by Paul Bissex (pb@e-scribe.com)
4# Public copy lives at http://open.e-scribe.com/
5
6# Configuration Variables
7MODKEY=Mod4
8UP=Up
9DOWN=Down
10LEFT=Left
11RIGHT=Right
12
13# Colors tuples: "<text> <background> <border>"
14WMII_NORMCOLORS='#666677 #111111 #444444'
15WMII_FOCUSCOLORS='#ccccdd #444466 #444455'
16
17WMII_BACKGROUND='#111111'
18WMII_FONT='-*-lucida-bold-r-*-*-16-*-*-*-*-*-*-*'
19
20set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
21WMII_MENU="dmenu -b -fn $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5"
22WMII_9MENU="wmii9menu -font $WMII_FONT -nf $1 -nb $2 -sf $4 -sb $5 -br $6"
23WMII_TERM="xfterm4"
24
25# Column Rules
26wmiir write /colrules <<!
27/0/ -> 50+50
28/1/ -> 50+50
29/4/ -> 60+40
30/9/ -> 80+20
31/.*/ -> 56+44
32!
33
34# Tagging Rules
35# (It would be neat to have a set that says, "open these apps in tags of their own names"
36# for the screen-hogs like GIMP)
37wmiir write /tagrules <<!
38/XMMS.*/ -> ~
39/MPlayer.*/ -> ~
40/gimp.*/ -> gimp
41/.*/ -> !
42/.*/ -> 1
43!
44
45# Status Bar Info
46status() {
47        echo -n $(date +"Logged in as $USER ~ %A, %B %d ~ %l:%M%P")
48}
49
50# Event processing
51#  Processed later by `wmiiloop' and evaled.
52#  Duplicate the eval line and replace 'eval' with 'echo' for details.
53eventstuff() {
54        cat <<'!'
55        # Events
56        Event Start
57                case "$1" in
58                wmiirc)
59                        exit;
60                esac
61        Event Key
62                fn=$(echo "$@" | sed 's/[^a-zA-Z_0-9]/_/g')
63                Key_$fn "$@"
64        Event CreateTag
65                echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@"
66        Event DestroyTag
67                wmiir remove "/lbar/$@"
68        Event FocusTag
69                wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$@"
70        Event UnfocusTag
71                wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$@"
72        Event UrgentTag
73                shift
74                wmiir xwrite "/lbar/$@" "*$@"
75        Event NotUrgentTag
76                shift
77                wmiir xwrite "/lbar/$@" "$@"
78        Event LeftBarClick
79                shift
80                wmiir xwrite /ctl view "$@"
81        # Actions
82        Action quit
83                wmiir xwrite /ctl quit
84        Action rehash
85                proglist $PATH >$progsfile
86        Action status
87                set +xv
88                if wmiir remove /rbar/status 2>/dev/null; then
89                        sleep 2
90                fi
91                echo "$WMII_NORMCOLORS" | wmiir create /rbar/status
92                while status | wmiir write /rbar/status; do
93                        sleep 1
94                done
95        Event ClientMouseDown
96                client=$1; button=$2
97                case "$button" in
98                3)
99                        do=$($WMII_9MENU -initial "${menulast:-SomeRandomName}" Nop Delete)
100                        case "$do" in
101                        Delete)
102                                wmiir xwrite /client/$client/ctl kill
103                        esac
104                        menulast=${do:-"$menulast"}
105                esac
106        # Key Bindings
107        Key $MODKEY-Control-t
108                case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
109                0|1)
110                        echo -n \$Keys | tr ' ' '\012' | wmiir write /keys
111                        wmiir xwrite /ctl grabmod $MODKEY;;
112                *)
113                        wmiir xwrite /keys $MODKEY-Control-t
114                        wmiir xwrite /ctl grabmod Mod3;;
115                esac
116        Key $MODKEY-space
117                wmiir xwrite /tag/sel/ctl select toggle
118        Key $MODKEY-d
119                wmiir xwrite /tag/sel/ctl colmode sel default
120        Key $MODKEY-s
121                wmiir xwrite /tag/sel/ctl colmode sel stack
122        Key $MODKEY-m
123                wmiir xwrite /tag/sel/ctl colmode sel max
124        Key $MODKEY-a
125                Action $(actionlist | $WMII_MENU) &
126        Key $MODKEY-p
127                sh -c "$($WMII_MENU <$progsfile)" &
128        Key $MODKEY-t
129                wmiir xwrite /ctl "view $(tagsmenu)" &
130        Key $MODKEY-Return
131                $WMII_TERM &
132        Key $MODKEY-Shift-space
133                wmiir xwrite /tag/sel/ctl send sel toggle
134        Key $MODKEY-Shift-c
135                wmiir xwrite /client/sel/ctl kill
136        Key $MODKEY-Shift-t
137                wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" "$(tagsmenu)" &
138        Key $MODKEY-$LEFT
139                wmiir xwrite /tag/sel/ctl select left
140        Key $MODKEY-$RIGHT
141                wmiir xwrite /tag/sel/ctl select right
142        Key $MODKEY-$DOWN
143                wmiir xwrite /tag/sel/ctl select down
144        Key $MODKEY-$UP
145                wmiir xwrite /tag/sel/ctl select up
146        Key $MODKEY-Shift-$LEFT
147                wmiir xwrite /tag/sel/ctl send sel left
148        Key $MODKEY-Shift-$RIGHT
149                wmiir xwrite /tag/sel/ctl send sel right
150        Key $MODKEY-Shift-$DOWN
151                wmiir xwrite /tag/sel/ctl send sel down
152        Key $MODKEY-Shift-$UP
153                wmiir xwrite /tag/sel/ctl send sel up
154        Key Menu
155                sh -c "$($WMII_MENU <$progsfile)" &
156!
157        for i in 0 1 2 3 4 5 6 7 8 9; do
158                cat <<!
159        Key $MODKEY-$i
160                wmiir xwrite /ctl view "$i"
161        Key $MODKEY-Shift-$i
162                wmiir xwrite /client/sel/tags "$i"
163!
164        done
165}
166
167# WM Configuration
168wmiir write /ctl << EOF
169font $WMII_FONT
170focuscolors $WMII_FOCUSCOLORS
171normcolors $WMII_NORMCOLORS
172grabmod $MODKEY
173border 1
174EOF
175
176# Feed events to `wmiiloop' for processing
177eval "$(eventstuff | sed 's/^[  ]//' | { . wmiiloop; })"
178
179# Functions
180Action() {
181        action=$1; shift
182        if [ -n "$action" ]; then
183                Action_$action "$@" \
184                || conf_which $action "$@"
185        fi
186}
187
188proglist() {
189        paths=$(echo "$@" | sed 'y/:/ /')
190        ls -lL $paths 2>/dev/null \
191                | awk '$1 ~ /^[^d].*x/ { print $NF }' \
192                | sort | uniq
193}
194
195# Misc
196progsfile="$WMII_NS_DIR/.proglist"
197Action status &
198proglist $PATH >$progsfile &
199
200xsetroot -solid "$WMII_BACKGROUND" &
201
202export WMII_MENU WMII_9MENU WMII_FONT WMII_TERM
203export WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS
204
205# Setup Tag Bar
206wmiir ls /lbar |
207while read bar; do
208        wmiir remove "/lbar/$bar"
209done
210seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
211wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
212while read tag; do
213        if [ "X$tag" = "X$seltag" ]; then
214                echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/lbar/$tag"
215        else
216                echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/lbar/$tag"
217        fi
218done
219
220# More functions
221tagsmenu() {
222        wmiir ls /tag | sed 's|/||; /^sel$/d' | $WMII_MENU
223}
224
225actionlist() {
226        {       proglist $WMII_CONFPATH
227                echo -n $Actions | tr ' ' '\012'
228        } | sort | uniq
229}
230
231conf_which() {
232        which=$(which which)
233        prog=$(PATH="$WMII_CONFPATH" $which $1)
234        shift
235        if [ -n "$prog" ]; then
236                $prog
237        fi
238}
239
240# Stop any running instances of wmiirc
241echo Start wmiirc | wmiir write /event || exit 1
242
243wmiir read /event |
244while read event; do
245        set -- $event
246        event=$1; shift
247        Event_$event $@
248done 2>/dev/null
Note: See TracBrowser for help on using the browser.