Sync wmiirc with rc.wmii.

This commit is contained in:
Kris Maglione 2008-01-21 18:22:42 -05:00
parent 2999577155
commit c2e18957f9
3 changed files with 47 additions and 16 deletions

View File

@ -9,27 +9,31 @@ Keys=""
Actions=""
Events=""
wi_nl='
'
_wi_script() {
cat <<'!'
BEGIN {
arg[1] = "Nop"
narg = 1;
body = "";
}
function addevent() {
if(arg[1] == "Key")
keys[arg[2]] = 1;
var = arg[1] "s"
printf "%s=\"$%s\n%s\"\n", var, var, arg[2]
gsub("[^a-zA-Z_0-9]", "_", arg[2]);
if(body != "")
printf "%s_%s() { %s\n }\n", arg[1], arg[2], body
for(i=2; i <= narg; i++) {
printf "%s=\"$%s\n%s\"\n", var, var, arg[i]
gsub("[^a-zA-Z_0-9]", "_", arg[i]);
if(body != "") {
printf "%s_%s() { %s\n }\n", arg[1], arg[i], body
body = sprintf("%s_%s \"$@\"", arg[1], arg[2])
}
}
}
/^(Event|Key|Action)[ \t]/ {
addevent()
split($0, arg)
narg = NF
body = ""
}
/^[ \t]/ {
@ -129,8 +133,8 @@ wi_eventloop() {
wmiir read /event | while read wi_event
do
OIFS="$IFS"; IFS="$(echo)"
wi_args=$(echo "$wi_event" | sed 's/^[^ ]+ //')
OIFS="$IFS"; IFS="$wi_nl"
wi_arg=$(echo "$wi_event" | sed 's/^[^ ]* //')
IFS="$OIFS"
set -- $wi_event
event=$1; shift

View File

@ -71,9 +71,11 @@ fn Event-FocusTag {
fn Event-UnfocusTag {
wmiir xwrite /lbar/$"* $wmiinormcol $*}
fn Event-UrgentTag {
shift; wmiir xwrite /lbar/$"* '*'$"*}
shift
wmiir xwrite /lbar/$"* '*'$"*}
fn Event-NotUrgentTag {
shift; wmiir xwrite /lbar/$"* $"*}
shift
wmiir xwrite /lbar/$"* $"*}
fn Event-Unresponsive {
client = $1; shift

View File

@ -9,6 +9,10 @@ DOWN=j
LEFT=h
RIGHT=l
# Bars
noticetimeout=5
noticebar=/rbar/!notice
# Colors tuples: "<text> <background> <border>"
WMII_NORMCOLORS='#000000 #c1c48b #81654f'
WMII_FOCUSCOLORS='#000000 #81654f #000000'
@ -37,6 +41,8 @@ status() {
echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date)
}
echo $WMII_NORMCOLORS | wmiir create $noticebar
# Event processing
wi_events -s ' ' <<'!'
# Events
@ -54,9 +60,26 @@ wi_events -s ' ' <<'!'
Event NotUrgentTag
shift
wmiir xwrite "/lbar/$@" "$@"
Event LeftBarClick
Event LeftBarClick LeftBarDND
shift
wmiir xwrite /ctl view "$@"
Event Unresponsive
{
client=$1; shift
msg="The following client is not responding. What would you like to do?$wi_nl"
resp=$(wihack -transient $client \
xmessage -nearmouse -buttons Kill,Wait -print \
"$msg $(wmiir read /client/sel/label)")
if [ "$resp" = Kill ]; then
wmiir xwrite /client/$client/ctl slay &
fi
}&
Event Notice
wmiir xwrite $noticebar $wi_arg
kill $xpid 2>/dev/null # Let's hope this isn't reused...
{ sleep $noticetimeout; wmiir xwrite $noticebar ' '; }&
xpid = $!
# Actions
Action quit
wmiir xwrite /ctl quit
@ -166,8 +189,10 @@ Action status &
wi_proglist $PATH >$progsfile &
# Setup Tag Bar
(IFS="$(echo)"; wmiir rm $(wmiir ls /lbar | sed 's,^,/lbar/,'))
seltag="$(wmiir read /tag/sel/ctl | sed 1q)"
OIFS="$IFS"; IFS="$wi_nl"
wmiir rm $(wmiir ls /lbar | sed 's,^,/lbar/,')
seltag=$(wmiir read /tag/sel/ctl | sed 1q)
IFS="$OIFS"
wi_tags | while read tag
do
if [ "$tag" = "$seltag" ]; then