wmii/alternative_wmiircs/plan9port/wmiirc

291 lines
7.2 KiB
Plaintext
Raw Normal View History

2009-10-16 11:28:54 +04:00
#!/bin/sh -f
p="$PATH"
which rc >/dev/null || PATH="$PLAN9:$p"
which rc >/dev/null || PATH="/usr/local/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/local/9/bin:$p"
which rc >/dev/null || PATH="/opt/plan9/bin:$p"
which rc >/dev/null || PATH="/opt/9/bin:$p"
which rc >/dev/null || PATH="/usr/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/9/bin:$p"
test $#* '=' 0 || exec rc $0
2009-04-04 02:59:23 +04:00
cd
scriptname=$0
oldpath=$path; path=($PLAN9/bin $path)
. wmii.rc wmiirc # Include utility functions
# WMII Configuration
# Keys
2009-10-10 22:57:00 +04:00
MODKEY=Mod4
2007-07-17 00:52:35 +04:00
UP=k
DOWN=j
LEFT=h
RIGHT=l
# Bars
noticetimeout=5
noticebar=/rbar/!notice
# Theme
wmiifont='drift,-*-fixed-*-*-*-*-9-*-*-*-*-*-*-*'
wmiifont='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
wmiinormcol=`{echo '#000000 #c1c48b #81654f'}
wmiifocuscol=`{echo '#000000 #81654f #000000'}
wmiibackground='#333333'
wmiifloatbackground='#222222'
fn setbackground { xsetroot -solid $* }
2007-07-17 00:52:35 +04:00
# Programs
2007-07-17 00:52:35 +04:00
WMII_TERM=(xterm)
# Column Rules
wmiir write /colrules <<!
/gimp/ -> 17+83+41
/.*/ -> 62+38 # Golden Ratio
!
# Tagging Rules
wmiir write /rules <<!
# MPlayer and VLC don't float by default, but should.
/MPlayer|VLC/ floating=True
# ROX puts all of its windows in the same group, so they open
# with the same tags. Disable grouping for ROX Filer.
/^ROX-Filer:/ group=0
!
# Status Bar Info
fn status {
2010-05-28 19:05:01 +04:00
echo -n `{uptime | sed 's/.*://; s/,//g'} '|' \
`{date} }
# Generic overridable startup details
fn startup { witray & }
# End Configuration
2007-06-27 06:39:03 +04:00
# For the time being, this file follows the lisp bracing
# convention. i.e.:
# if(frob this) {
# frob that
# if(frob theother) {
# unfrob this
# unfrob that}}
# Comments welcome.
confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'}
2007-06-27 06:39:03 +04:00
2007-07-17 00:52:35 +04:00
# Events
fn sigexit {
rm -f $progs_file
2010-05-28 19:05:01 +04:00
wi_cleankeys}
fn Event-CreateTag {
echo $wmiinormcol $* | wmiir create /lbar/$"*}
fn Event-DestroyTag {
wmiir remove /lbar/$"*}
fn Event-FocusTag {
wmiir xwrite /lbar/$"* $wmiifocuscol $*}
fn Event-UnfocusTag {
wmiir xwrite /lbar/$"* $wmiinormcol $*}
fn Event-UrgentTag {
2008-01-22 02:22:42 +03:00
shift
wmiir xwrite /lbar/$"* '*'$"*}
fn Event-NotUrgentTag {
2008-01-22 02:22:42 +03:00
shift
wmiir xwrite /lbar/$"* $"*}
fn Event-AreaFocus {
if(~ $1 '~')
setbackground $wmiifloatbackground
if not
setbackground $wmiibackground }
fn Event-Unresponsive {
client = $1; shift
@{
msg = 'The following client is not responding. What would you like to do?'
resp = `{wihack -transient $client \
xmessage -nearmouse -buttons Kill,Wait -print \
2009-10-10 00:40:33 +04:00
$msg $wi_newline '' `{wmiir read /client/$client/label}}
if(~ $resp Kill)
2008-04-02 03:26:46 +04:00
wmiir xwrite /client/$client/ctl slay
}&}
fn Event-Notice {
wmiir xwrite $noticebar $wi_arg
/bin/kill $xpid >[2]/dev/null # Let's hope this isn't reused...
{ sleep $noticetimeout; wmiir xwrite $noticebar ' ' }& # Bug...
xpid = $apid}
fn Event-LeftBar^(Click DND) {
shift; wmiir xwrite /ctl view $*}
fn ClientMenu-3-Delete {
wmiir xwrite /client/$1/ctl kill}
fn ClientMenu-3-Kill {
wmiir xwrite /client/$1/ctl slay}
fn ClientMenu-3-Fullscreen {
wmiir xwrite /client/$1/ctl Fullscreen on}
fn Event-ClientMouseDown {
wi_fnmenu Client $2 $1 &}
fn LBarMenu-3-Delete {
tag=$1; clients=`{wmiir read /tag/$tag/index | awk '/[^#]/{print $2}'}
for(c in $clients) {
if(~ $tag `{wmiir read /client/$c/tags})
wmiir xwrite /client/$c/ctl kill
if not
wmiir xwrite /client/$c/tags -$tag}
if(~ $tag `{wi_seltag}) {
newtag = `{wi_tags | awk -v't='$tag '
$1 == t { if(!l) getline l
print l
exit }
{ l = $0 }'}
wmiir xwrite /ctl view $newtag}}
fn Event-LeftBarMouseDown {
wi_fnmenu LBar $* &}
# Actions
2007-07-17 00:52:35 +04:00
fn Action-rehash {
2008-02-05 02:33:57 +03:00
comm -23 <{ls `{namespace}^/proglist.* >[2]/dev/null | awk -F'.' '{print $NF}'} \
<{ps | awk '{print $2}'} |
while(id=`{read})
2008-02-05 02:33:57 +03:00
rm `{namespace}^/proglist.$id
wi_proglist $PATH >$progs_file}
fn Action-quit {
wmiir xwrite /ctl quit}
fn Action-exec {
wmiir xwrite /ctl exec $*}
fn Action-status {
2007-07-17 00:52:35 +04:00
flag x -; flag r -
if(wmiir remove /rbar/status >[2]/dev/null)
2007-03-01 23:20:53 +03:00
sleep 2
echo $wmiinormcol | wmiir create /rbar/status
while(status | wmiir write /rbar/status)
sleep 1
}
2007-06-27 06:39:03 +04:00
# Source Variables, &c
if(~ $0 ('' */)wmiirc_local.rc)
wi_notice This file should not be named wmiirc_local.rc
if not
. `{wi_script -f wmiirc_local.rc}
2008-04-05 02:43:53 +04:00
echo $wmiinormcol | wmiir create $noticebar
2010-05-28 19:05:01 +04:00
startup
2007-06-27 06:39:03 +04:00
# Key Bindings
_keys = `{wi_getfuns Key}
2007-07-17 00:52:35 +04:00
fn key {
key=()
2008-10-28 05:37:36 +03:00
for(k) if(! ~ $k $_keys) key = ($key Key-$k)
~ $#key 0}
2007-07-17 00:52:35 +04:00
# This is... ugly.
2007-07-17 00:52:35 +04:00
key $MODKEY-Control-t || fn $key {
switch(`{wmiir read /keys | wc -l}) {
case 0 1
2008-04-02 03:26:46 +04:00
wmiir xwrite /keys $keys
wmiir xwrite /ctl grabmod $MODKEY
case *
ifs=() { keys=`{wmiir read /keys} }
wmiir xwrite /keys $MODKEY-Control-t
wmiir xwrite /ctl grabmod Mod3
}}
key $MODKEY-$LEFT || fn $key {
wmiir xwrite /tag/sel/ctl select left}
key $MODKEY-$RIGHT || fn $key {
wmiir xwrite /tag/sel/ctl select right}
key $MODKEY-$DOWN || fn $key {
wmiir xwrite /tag/sel/ctl select down}
key $MODKEY-$UP || fn $key {
wmiir xwrite /tag/sel/ctl select up}
key $MODKEY-Control-$DOWN || fn $key {
wmiir xwrite /tag/sel/ctl select down stack}
key $MODKEY-Control-$UP || fn $key {
wmiir xwrite /tag/sel/ctl select up stack}
key $MODKEY-Shift-$LEFT || fn $key {
wmiir xwrite /tag/sel/ctl send sel left}
key $MODKEY-Shift-$RIGHT || fn $key {
wmiir xwrite /tag/sel/ctl send sel right}
key $MODKEY-Shift-$DOWN || fn $key {
wmiir xwrite /tag/sel/ctl send sel down}
key $MODKEY-Shift-$UP || fn $key {
wmiir xwrite /tag/sel/ctl send sel up}
key $MODKEY-f || fn $key {
wmiir xwrite /client/sel/ctl Fullscreen toggle}
key $MODKEY-space || fn $key {
wmiir xwrite /tag/sel/ctl select toggle}
key $MODKEY-Shift-space || fn $key {
wmiir xwrite /tag/sel/ctl send sel toggle}
key $MODKEY-d || fn $key {
wmiir xwrite /tag/sel/ctl colmode sel default-max}
key $MODKEY-s || fn $key {
wmiir xwrite /tag/sel/ctl colmode sel stack-max}
key $MODKEY-m || fn $key {
wmiir xwrite /tag/sel/ctl colmode sel stack+max}
key $MODKEY-Shift-c || fn $key {
wmiir xwrite /client/sel/ctl kill}
key $MODKEY-a || fn $key {
Action `{wi_actions | wimenu -h $hist.action -n $histlen} &}
key $MODKEY-p || fn $key {
2008-10-16 22:39:36 +04:00
ifs=() { cmd = `{wimenu -h $hist.prog -n $histlen <$progs_file} }
2008-10-16 07:59:17 +04:00
wi_runcmd $cmd & }
key $MODKEY-Return || fn $key {
wi_runcmd $WMII_TERM &}
key $MODKEY-t || fn $key {
2009-05-27 21:22:24 +04:00
tag=`{wi_tags | wimenu -h $hist.tag -n 50} && wmiir xwrite /ctl view $tag &}
2007-07-17 00:52:35 +04:00
key $MODKEY-Shift-t || fn $key {
2009-05-27 21:22:24 +04:00
sel=`{wi_selclient} {
tag=`{wi_tags | wimenu -h $hist.tag -n 50} && wmiir xwrite /client/$sel/tags $tag } &}
key $MODKEY-^`{seq 0 9} || fn $key {
wmiir xwrite /ctl view `{echo $1 | sed 's/.*-//'}}
2007-07-17 00:52:35 +04:00
key Shift-$MODKEY-^`{seq 0 9} || fn $key {
wmiir xwrite /client/sel/tags `{echo $1 | sed 's/.*-//'}}
#` WM Configuration
wmiir write /ctl <<!
grabmod $MODKEY
border 2
font $wmiifont
focuscolors $wmiifocuscol
normcolors $wmiinormcol
!
setbackground $wmiibackground
# Source Overrides
Action overridekeys
# Misc Setup
2008-02-05 02:33:57 +03:00
progs_file=`{namespace}^/proglist.$pid
hist=`{echo $WMII_CONFPATH | sed 's,:.*,/,'}^/history
2008-10-15 03:00:58 +04:00
histlen=5000
2008-06-01 02:42:13 +04:00
Action status &
Action rehash &
# Tag Bar Setup
2009-10-10 00:40:33 +04:00
ifs=$wi_newline {
rc -c 'wmiir rm /lbar/^$*' >[2]/dev/null \
`{comm -23 <{wmiir ls /lbar} \
<{wi_tags}}
seltag=`{wi_seltag}
for(tag in `{wi_tags}) {{
if(~ $tag $seltag)
echo $wmiifocuscol $tag
if not
echo $wmiinormcol $tag
} | wmiir create /lbar/$tag}}
wi_eventloop