You are not logged in.
So heres the thing, I pretty much suck at scripting .
I get by in tiling wm's simply by observing, modifying, and eventually learning through trial and error.
So Ive been playing around with wmii lately and Ive hacked up my wmiirc to do what I want as best I can with what limited knowledge I have, but I need more.
First problem, Im trying to make wmii have custom tag titles while still using alt + 0-9 instead of using alt + t and typing the title every time.
heres what I did to achieve this
#!
# for i in 0 1 2 3 4 5 6 7 8 9; do
# cat <<!
#Key $MODKEY-$i # Move to the numbered view
# wmiir xwrite /ctl view "$i"
#Key $MODKEY-Shift-$i # Retag selected client with the numbered tag
# wmiir xwrite /client/sel/tags "$i"
#!
# done
Key $MODKEY-1
wmiir xwrite /ctl view "web"
Key $MODKEY-Shift-1
wmiir xwrite /client/sel/tags "web"
Key $MODKEY-2
wmiir xwrite /ctl view "ctrl"
Key $MODKEY-Shift-2
wmiir xwrite /client/sel/tags "ctrl"
Key $MODKEY-3
wmiir xwrite /ctl view "stat"
Key $MODKEY-Shift-3
wmiir xwrite /client/sel/tags "stat"
Key $MODKEY-4
wmiir xwrite /ctl view "msg"
Key $MODKEY-Shift-4
wmiir xwrite /client/sel/tags "msg"
Key $MODKEY-5
wmiir xwrite /ctl view "img"
Key $MODKEY-Shift-5
wmiir xwrite /client/sel/tags "img"
Key $MODKEY-6
wmiir xwrite /ctl view "vid"
Key $MODKEY-Shift-6
wmiir xwrite /client/sel/tags "vid"
Key $MODKEY-7
wmiir xwrite /ctl view "misc"
Key $MODKEY-Shift-7
wmiir xwrite /client/sel/tags "misc"
Key $MODKEY-8
wmiir xwrite /ctl view "misc1"
Key $MODKEY-Shift-8
wmiir xwrite /client/sel/tags "misc1"
Key $MODKEY-9
wmiir xwrite /ctl view "misc2"
Key $MODKEY-Shift-9
wmiir xwrite /client/sel/tags "misc2"
Key $MODKEY-0
wmiir xwrite /ctl view "misc3"
Key $MODKEY-Shift-0
wmiir xwrite /client/sel/tags "misc3"
!
Now this does work, but the problem is that now tags are listed on the tag bar alphabetically rather then numerically like I intended. Example alt + 1 (which is now web) actually ends up being the last tag in the list rather then the first because web starts with w.
I.E [crtl][msg][stat][web] instead of [web][ctrl][stat][msg] like I intended.
So I guess the question is how can I fix this so theyre listed in accordance with the key thats pressed rather then alphabetically? Is this possible in wmii?
Also I dont want to change the keys (i.e. make web 9 instead of 1 so its last on the keyboard too). I like the web=1,ctr=2l,stat=3,msg=4 layout that I chose in my config, I just dont like how theyre out of order on the bar.
Next problem, I want to autostart specific applications on specific tags and in a specific arrangement.
heres what I did to achieve this
# Autostart (this is ghetto, I know)
echo -n view ctrl | wmiir write /ctl;urxvtc -e ssh 192.168.1.55 -p 228 &
urxvtc -e ssh laurie@192.168.1.60 -p 228 &
sleep 1.5 && urxvtc &
sleep 2 && wmiir xwrite /tag/sel/ctl send sel right &
sleep 2.5 && echo -n view stat | wmiir write /ctl;urxvtc -e vifm &
sleep 2.5 && urxvtc -e alsamixer &
sleep 3 && urxvtc -e htop &
sleep 3.5 && wmiir xwrite /tag/sel/ctl send sel left &
sleep 4 && echo -n view msg | wmiir write /ctl;pidgin &
sleep 3.5 && echo -n view web | wmiir write /ctl;wmiir xwrite /tag/sel/ctl colmode sel stack;uzbl-browser &
This also works, but it seems a bit too hackish if you ask me. It also takes a while to go through the tags and open things one at a time like this. Surely there must be a way to achieve the same results without all the sleep and manual client placement commands. Im looking for a way to open everything simultaneously and have it go directly where its supposed to.
So what would be the better way to do this?
And lastly heres the complete wmiirc for reference. If anybody has any tips or suggestions about anything please share.
#!/bin/dash -f
# Configure wmii
wmiiscript=wmiirc # For wmii.sh
. wmii.sh
# Configuration Variables
MODKEY=Mod1
UP=k
DOWN=j
LEFT=h
RIGHT=l
# Bars
noticetimeout=5
noticebar=/rbar/!notice
# Colors tuples: "<text> <background> <border>"
export WMII_NORMCOLORS='#a7a15e #262626 #3e3e3e'
export WMII_FOCUSCOLORS='#262626 #a7a15e #3e3e3e'
export WMII_BACKGROUND='#262626'
set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
# Font
export WMII_FONT='xft:Terminus-8'
#export WMII_FONT='-dec-terminal-bold-*-*-*-*-*-*-*-*-*-*-*'
# Terminal
export WMII_TERM="urxvtc"
# Menu history
hist="${WMII_CONFPATH%%:*}/history"
histnum=5000
# Column Rules
wmiir write /colrules <<!
/.*/ -> 58+42
# /.*/ -> 62+38 # Golden Ratio
!
# Tagging Rules
wmiir write /rules <<!
# Apps with system tray icons like to their main windows
# Give them permission.
#/^Pidgin:/ allow=+activate
# Float Apps
/MPlayer/ floating=on
/feh/ floating=on
/gimp/ floating=on
/^Pidgin:/ floating=on
# 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
status() {
echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date +%a' '%b' '%d' '%r)
}
# Generic overridable startup details
startup() { witray & }
local_events() { true;}
wi_runconf -s wmiirc_local
startup
echo $WMII_NORMCOLORS | wmiir create $noticebar
# Event processing
events() {
cat <<'!'
# Events
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 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_newline"
resp=$(wihack -transient $client \
xmessage -nearmouse -buttons Kill,Wait -print \
-fn "${WMII_FONT%%,*}" "$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 = $!
# Menus
Menu Client-3-Delete
wmiir xwrite /client/$1/ctl kill
Menu Client-3-Kill
wmiir xwrite /client/$1/ctl slay
Menu Client-3-Fullscreen
wmiir xwrite /client/$1/ctl Fullscreen on
Event ClientMouseDown
wi_fnmenu Client $2 $1 &
Menu LBar-3-Delete
tag=$1; clients=$(wmiir read "/tag/$tag/index" | awk '/[^#]/{print $2}')
for c in $clients; do
if [ "$tag" = "$(wmiir read /client/$c/tags)" ]; then
wmiir xwrite /client/$c/ctl kill
else
wmiir xwrite /client/$c/tags -$tag
fi
if [ "$tag" = "$(wi_seltag)" ]; then
newtag=$(wi_tags | awk -v't='$tag '
$1 == t { if(!l) getline l
print l
exit }
{ l = $0 }')
wmiir xwrite /ctl view $newtag
fi
done
Event LeftBarMouseDown
wi_fnmenu LBar "$@" &
# Actions
Action showkeys
echo "$KeysHelp" | xmessage -file - -fn ${WMII_FONT%%,*}
Action quit
wmiir xwrite /ctl quit
Action exec
wmiir xwrite /ctl exec "$@"
Action rehash
wi_proglist $PATH >$progsfile
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
# Key Bindings
KeyGroup Moving around
Key $MODKEY-$LEFT # Select the client to the left
wmiir xwrite /tag/sel/ctl select left
Key $MODKEY-$RIGHT # Select the client to the right
wmiir xwrite /tag/sel/ctl select right
Key $MODKEY-$UP # Select the client above
wmiir xwrite /tag/sel/ctl select up
Key $MODKEY-$DOWN # Select the client below
wmiir xwrite /tag/sel/ctl select down
Key $MODKEY-space # Toggle between floating and managed layers
wmiir xwrite /tag/sel/ctl select toggle
KeyGroup Moving through stacks
Key $MODKEY-Control-$UP # Select the stack above
wmiir xwrite /tag/sel/ctl select up stack
Key $MODKEY-Control-$DOWN # Select the stack below
wmiir xwrite /tag/sel/ctl select down stack
KeyGroup Moving clients around
Key $MODKEY-Shift-$LEFT # Move selected client to the left
wmiir xwrite /tag/sel/ctl send sel left
Key $MODKEY-Shift-$RIGHT # Move selected client to the right
wmiir xwrite /tag/sel/ctl send sel right
Key $MODKEY-Shift-$UP # Move selected client up
wmiir xwrite /tag/sel/ctl send sel up
Key $MODKEY-Shift-$DOWN # Move selected client down
wmiir xwrite /tag/sel/ctl send sel down
Key $MODKEY-Shift-space # Toggle selected client between floating and managed layers
wmiir xwrite /tag/sel/ctl send sel toggle
KeyGroup Client actions
Key $MODKEY-f # Toggle selected client's fullsceen state
wmiir xwrite /client/sel/ctl Fullscreen toggle
Key $MODKEY-Shift-c # Close client
wmiir xwrite /client/sel/ctl kill
KeyGroup Changing column modes
Key $MODKEY-d # Set column to default mode
wmiir xwrite /tag/sel/ctl colmode sel default-max
Key $MODKEY-s # Set column to stack mode
wmiir xwrite /tag/sel/ctl colmode sel stack-max
Key $MODKEY-m # Set column to max mode
wmiir xwrite /tag/sel/ctl colmode sel stack+max
KeyGroup Running programs
Key $MODKEY-a # Open wmii actions menu
action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) &
Key $MODKEY-p # Open program menu
eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" &
Key $MODKEY-Return # Launch a terminal
eval wmiir setsid $WMII_TERM &
KeyGroup Other
Key $MODKEY-Control-t # Toggle all other key bindings
case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
0|1)
echo -n "$Keys" | wmiir write /keys
wmiir xwrite /ctl grabmod $MODKEY;;
*)
wmiir xwrite /keys $MODKEY-Control-t
wmiir xwrite /ctl grabmod Mod3;;
esac
KeyGroup Tag actions
Key $MODKEY-t # Change to another tag
wmiir xwrite /ctl view $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
Key $MODKEY-Shift-t # Retag the selected client
# Assumes left-to-right order of evaluation
wmiir xwrite /client/$(wi_selclient)/tags $(wi_tags | wimenu -h "${hist}.tags" -n 50) &
#!
# for i in 0 1 2 3 4 5 6 7 8 9; do
# cat <<!
#Key $MODKEY-$i # Move to the numbered view
# wmiir xwrite /ctl view "$i"
#Key $MODKEY-Shift-$i # Retag selected client with the numbered tag
# wmiir xwrite /client/sel/tags "$i"
#!
# done
Key $MODKEY-1
wmiir xwrite /ctl view "web"
Key $MODKEY-Shift-1
wmiir xwrite /client/sel/tags "web"
Key $MODKEY-2
wmiir xwrite /ctl view "ctrl"
Key $MODKEY-Shift-2
wmiir xwrite /client/sel/tags "ctrl"
Key $MODKEY-3
wmiir xwrite /ctl view "stat"
Key $MODKEY-Shift-3
wmiir xwrite /client/sel/tags "stat"
Key $MODKEY-4
wmiir xwrite /ctl view "msg"
Key $MODKEY-Shift-4
wmiir xwrite /client/sel/tags "msg"
Key $MODKEY-5
wmiir xwrite /ctl view "img"
Key $MODKEY-Shift-5
wmiir xwrite /client/sel/tags "img"
Key $MODKEY-6
wmiir xwrite /ctl view "vid"
Key $MODKEY-Shift-6
wmiir xwrite /client/sel/tags "vid"
Key $MODKEY-7
wmiir xwrite /ctl view "misc"
Key $MODKEY-Shift-7
wmiir xwrite /client/sel/tags "misc"
Key $MODKEY-8
wmiir xwrite /ctl view "misc1"
Key $MODKEY-Shift-8
wmiir xwrite /client/sel/tags "misc1"
Key $MODKEY-9
wmiir xwrite /ctl view "misc2"
Key $MODKEY-Shift-9
wmiir xwrite /client/sel/tags "misc2"
Key $MODKEY-0
wmiir xwrite /ctl view "misc3"
Key $MODKEY-Shift-0
wmiir xwrite /client/sel/tags "misc3"
!
}
wi_events events local_events
# WM Configuration
wmiir write /ctl <<!
font $WMII_FONT
focuscolors $WMII_FOCUSCOLORS
normcolors $WMII_NORMCOLORS
grabmod $MODKEY
border 1
!
# Misc
progsfile="$(wmiir namespace)/.proglist"
action status &
wi_proglist $PATH >$progsfile &
wmiir xwrite /ctl "colmode default"
xsetroot -solid "$WMII_BACKGROUND" &
# Autostart (this is ghetto, i know)
echo -n view ctrl | wmiir write /ctl;urxvtc -e ssh 192.168.1.55 -p 228 &
urxvtc -e ssh laurie@192.168.1.60 -p 228 &
sleep 1.5 && urxvtc &
sleep 2 && wmiir xwrite /tag/sel/ctl send sel right &
sleep 2.5 && echo -n view stat | wmiir write /ctl;urxvtc -e vifm &
sleep 2.5 && urxvtc -e alsamixer &
sleep 3 && urxvtc -e htop &
sleep 3.5 && wmiir xwrite /tag/sel/ctl send sel left &
sleep 4 && echo -n view msg | wmiir write /ctl;pidgin &
sleep 3.5 && echo -n view web | wmiir write /ctl;wmiir xwrite /tag/sel/ctl colmode sel stack;uzbl-browser &
# Setup Tag Bar
IFS="$wi_newline"
wmiir rm $(wmiir ls -p /lbar) >/dev/null
seltag=$(wmiir read /tag/sel/ctl | sed 1q)
unset IFS
wi_tags | while read tag
do
if [ "$tag" = "$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag"
else
echo "$WMII_NORMCOLORS" "$tag"
fi | wmiir create "/lbar/$tag"
done
wi_eventloop
Also I should mention this is wmii-hg. I like hg better then 3.9 because in 3.9 the columns are all screwed up.
I.E I like fixed column sizes where the right column is always smaller then the left no matter which side you move the client to. (difficult to explain)
Last edited by tjwoosta (2010-07-01 03:23:06)
Offline