mirror of
https://github.com/0intro/wmii
synced 2024-11-26 07:39:37 +03:00
242 lines
5.7 KiB
Plaintext
Executable File
242 lines
5.7 KiB
Plaintext
Executable File
#!/usr/bin/env wmii9rc
|
|
scriptname=$0
|
|
oldpath=$path; path=($PLAN9/bin $path)
|
|
. wmii.rc wmiirc # Include utility functions
|
|
|
|
# WMII Configuration
|
|
|
|
# Keys
|
|
MODKEY=Mod1
|
|
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'
|
|
|
|
# Programs
|
|
WMII_TERM=(xterm)
|
|
|
|
# Column Rules
|
|
wmiir write /colrules <<!
|
|
/gimp/ -> 17+83+41
|
|
/.*/ -> 62+38 # Golden Ratio
|
|
!
|
|
|
|
# Tagging Rules
|
|
wmiir write /tagrules <<!
|
|
/MPlayer|VLC/ -> ~
|
|
!
|
|
|
|
# Status Bar Info
|
|
fn status {
|
|
echo -n `{uptime | sed 's/.*://; s/,//g'} \
|
|
'|' `{date}
|
|
}
|
|
|
|
# End Configuration
|
|
|
|
# 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/:/ /'}
|
|
|
|
# Events
|
|
fn sigexit {
|
|
rm -f $progs_file
|
|
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 {
|
|
shift; wmiir xwrite /lbar/$"* '*'$"*}
|
|
fn Event-NotUrgentTag {
|
|
shift; wmiir xwrite /lbar/$"* $"*}
|
|
|
|
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 \
|
|
$msg $wi_nl '' `{wmiir read /client/sel/label}}
|
|
if(~ $resp Kill)
|
|
wmiir xwrite /client/$client/ctl slay }&}
|
|
echo $wmiinormcol | wmiir create $noticebar
|
|
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 Event-ClientMouseDown {
|
|
client = $1; button = $2
|
|
if(~ $button 3) {
|
|
do=`{wi_9menu -initial $menulast Nop Delete Fullscreen}
|
|
switch($do) {
|
|
case Delete
|
|
wmiir xwrite /client/$client/ctl kill
|
|
case Fullscreen
|
|
wmiir xwrite /client/$client/ctl Fullscreen on
|
|
}
|
|
if(! ~ $do '')
|
|
menulast = $do;}}
|
|
menulast = Nop
|
|
|
|
# Actions
|
|
fn Action-rehash {
|
|
comm -23 <{ls $WMII_NS_DIR/proglist.* >[2]/dev/null | awk -F'\.' '{print $NF}'} \
|
|
<{ps | awk '{print $2}'} |
|
|
while(id=`{read})
|
|
rm $WMII_NS_DIR/proglist.$id
|
|
wi_proglist $PATH >$progs_file}
|
|
fn Action-quit {
|
|
wmiir xwrite /ctl quit}
|
|
fn Action-exec {
|
|
wmiir xwrite /ctl exec $*}
|
|
fn Action-status {
|
|
flag x -; flag r -
|
|
if(wmiir remove /rbar/status >[2]/dev/null)
|
|
sleep 2
|
|
echo $wmiinormcol | wmiir create /rbar/status
|
|
while(status | wmiir write /rbar/status)
|
|
sleep 1
|
|
}
|
|
|
|
# Source Variables, &c
|
|
if(~ $0 rc.wmii.local */rc.wmii.local)
|
|
wi_notice This file should not be named rc.wmii.local
|
|
if not
|
|
. `{wi_script -f rc.wmii.local}
|
|
|
|
# Key Bindings
|
|
fn key {
|
|
key=()
|
|
for(k in Key-$*) if(! wi_fn-p $k) key = ($key $k)
|
|
~ $#key 0}
|
|
|
|
# This is... ugly.
|
|
|
|
key $MODKEY-Control-t || fn $key {
|
|
switch(`{wmiir read /keys | wc -l}) {
|
|
case 0 1
|
|
wmiir xwrite /ctl $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-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}
|
|
key $MODKEY-s || fn $key {
|
|
wmiir xwrite /tag/sel/ctl colmode sel stack}
|
|
key $MODKEY-m || fn $key {
|
|
wmiir xwrite /tag/sel/ctl colmode sel max}
|
|
|
|
key $MODKEY-Shift-c || fn $key {
|
|
wmiir xwrite /client/sel/ctl kill}
|
|
|
|
key $MODKEY-a || fn $key {
|
|
Action `{wi_actions | wi_menu} &}
|
|
key $MODKEY-p || fn $key {
|
|
ifs=() { wi_runcmd -t `{wi_menu <$progs_file} & }}
|
|
key $MODKEY-Return || fn $key {
|
|
wi_runcmd $WMII_TERM &}
|
|
|
|
key $MODKEY-t || fn $key {
|
|
wmiir xwrite /ctl view `{wi_tags | wi_menu} &}
|
|
key $MODKEY-Shift-t || fn $key {
|
|
sel = `{wmiir read /client/sel/ctl | sed 1q} \
|
|
wmiir xwrite /client/$sel/tags `{wi_tags | wi_menu} &}
|
|
|
|
key $MODKEY-^`{seq 0 9} || fn $key {
|
|
wmiir xwrite /ctl view `{echo $1 | sed 's/.*-//'}}
|
|
key Shift-$MODKEY-^`{seq 0 9} || fn $key {
|
|
wmiir xwrite /client/sel/tags `{echo $1 | sed 's/.*-//'}}
|
|
|
|
#` WM Configuration
|
|
wmiir write /ctl <<!
|
|
view 1
|
|
grabmod $MODKEY
|
|
border 2
|
|
font $wmiifont
|
|
focuscolors $wmiifocuscol
|
|
normcolors $wmiinormcol
|
|
!
|
|
xsetroot -solid $wmiibackground
|
|
|
|
# Source Overrides
|
|
Action overridekeys
|
|
|
|
# Misc Setup
|
|
progs_file=$WMII_NS_DIR/proglist.$pid
|
|
Action status
|
|
Action rehash
|
|
|
|
# Tag Bar Setup
|
|
ifs=$wi_nl{
|
|
oldbars=`{comm -23 <{wmiir ls /lbar} <{wi_tags}}
|
|
if(! ~ $oldbars '')
|
|
wmiir rm /lbar/^$oldbars
|
|
seltag=`{wmiir read /tag/sel/ctl | sed 1q}
|
|
for(tag in `{wi_tags}) {
|
|
if(~ $tag $seltag)
|
|
echo $wmiifocuscol $tag | wmiir create /lbar/$tag
|
|
if not
|
|
echo $wmiinormcol $tag | wmiir create /lbar/$tag}}
|
|
|
|
wi_eventloop
|
|
|