#!/bin/sh -f # # Modified wmiirc from User Guide # for wmii 3.9.2 # # By Ben Smith # bensmith87@gmail.com # # Please contact if you have any improvements # # How to setup # * Setup the wallpaper to point to a picture # * Setup the actiondir to point to a directory that contains executable scripts for things you want to do # * Change the terminal() function to call your faviourite emulator # * Add any programs to the tagrules that you use # * Install mpd and mpc, or remove mpd function, loop and key events from this script # * Setup gmail login using .netrc file in home directory, or remove mail code from this script # * Install aumix # # How to use # * Mod-Enter - new terminal # * Mod-p - programs list # * Mod-a - actions menu # * Mod-t - change to different tag # * Mod-Shift-t - move client to different tag # * Mod-[0-9] - move to the nth tag # * Click on client head # * Right click # * Delete - delete client # * Remove - remove client from view # * Kill - kill client # * Scroll - select client above or below in column # * Click tag - swap to this view # * Click mail widget # * Left mouse - Open browser with gmail # * Click mpd widget # * Left mouse - toggle play pause # * Right click - open ncmpcpp # * Scroll - change song # * Click vol widget # * Left click - toggle mute # * Scroll - change volume # * Click clock # * Left click - show calendar up=k down=j left=h right=l modkey=Mod4 focuscolors='#000000 #cd6d37 #000000' normcolors='#000000 #848484 #000000' font="-misc-fixed-medium-r-*-*-13-*-*-*-*-60-*-*" wallpaper="/home/ben/pictures/wallpaper.png" feh --bg-tile $wallpaper & actiondir="/home/ben/.wmii" startview=comm proglist() { IFS=: set -- $1 find -L $@ -maxdepth 1 -perm /111 | sed '1d; s,.*/,,' | sort | uniq unset IFS } terminal() { wmiir setsid urxvt "$@" } clickmenu() { if res=$(wmii9menu -- "$@"); then eval "$res"; fi } # Configure wmii wmiir write /ctl < sel+web /gimp:Gimp:*/ -> image+~ /MATLAB:*:*/ -> matlab /sun-awt-X11-XFramePeer:com-mathworks-util-PostVMInit:*/ -> sel+matlab+~ /sun-awt-X11-XDialogPeer:com-mathworks-util-PostVMInit:*/ -> sel+matlab+~ /Qt-subapplication:VirtualBox:*/ -> vbox /VBoxSDL:VBoxSDL:*/ -> vbox /xchat:Xchat:*/ -> chat /Pidgin:Pidgin:*/ -> chat /*:MPlayer:*/ -> video+~ /urxvt:URxvt:*/ -> sel+term /gvim:Gvim:*/ -> sel+vim ! # Create the notice bar echo $normcolors | wmiir create /rbar/!notice # Right bar widgets # Clock echo '#000000 #ffffff #000000' clock | wmiir create /rbar/zclock # Create the widget clock() { echo $(date '+%a %d, %b; %X') } while clock | wmiir write /rbar/zclock; do sleep 1 done & # MPD echo $normcolors mpd | wmiir create /rbar/mpd mpd() { if [ `mpc status | grep playing | wc -l` -eq 1 ]; then echo '>' `mpc status | head -n 1` else if [ `mpc status | grep paused | wc -l` -eq 1 ]; then echo '||' `mpc status | head -n 1` else echo mpd fi fi } while mpd | wmiir write /rbar/mpd; do sleep 4 done & # Volume echo $normcolors vol | wmiir create /rbar/vol vol() { echo vol $(aumix -q | grep vol | sed 's/vol [0-9]*, //' | sed 's/, P//') % } vol | wmiir write /rbar/vol # Mail echo $normcolors mail | wmiir create /rbar/mail mail() { unread=`curl -n --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" | wc -l` if [ $unread -eq 0 ]; then echo -n $normcolors mail $unread else echo -n $focuscolors mail $unread fi } while mail | wmiir write /rbar/mail; do sleep 60 done & # Bind keys { cat <<! $modkey-$left $modkey-$right $modkey-$up $modkey-$down $modkey-space $modkey-Shift-$left $modkey-Shift-$right $modkey-Shift-$up $modkey-Shift-$down $modkey-Shift-space $modkey-d $modkey-s $modkey-m $modkey-Shift-c $modkey-f $modkey-Return $modkey-p $modkey-a $modkey-t $modkey-Shift-t ! for i in 1 2 3 4 5 6 7 8 9 0; do echo $modkey-$i echo $modkey-Shift-$i done } | wmiir write /keys # Broadcast a custom event wmiir xwrite /event Start wmiirc # Open /event for reading wmiir read /event | # Read the events line by line while read line; do set -- $line event=$1; shift line="$(echo $line | sed 's/^[^ ]* //' | tr -d '\n')" # echo --------------------------------- # echo event: $event # echo param1: $1 # echo param2: $2 # echo --------------------------------- # Process the event case $event in Start) # Quit when a new instance starts [ $1 = wmiirc ] && exit;; CreateTag) # CreateTag <Tag Name> echo $normcolors $1 | wmiir create /lbar/$1;; DestroyTag) # DestroyTag <Tag Name> wmiir rm /lbar/$1;; FocusTag) # FocusTag <Tag Name> wmiir xwrite /lbar/$1 $focuscolors $1;; UnfocusTag) # UnfocusTag <Tag Name> wmiir xwrite /lbar/$1 $normcolors $1;; Notice) echo $focuscolors $line | wmiir write /rbar/!notice #kill $xpid 2>/dev/null { sleep 5; echo $normcolors ' ' | wmiir write /rbar/!notice; } &;; #xpid = $!;; UrgentTag) # UrgentTag <'Client' or 'Manager'> <Tag Name> wmiir xwrite /lbar/$2 "*$2";; NotUrgentTag) # NotUrgentTag <'Client' or 'Manager'> <TagName> wmiir xwrite /lbar/$2 $2;; # Key Events Key) # Key <Key Name> case $1 in # Motion keys $modkey-$left) wmiir xwrite /tag/sel/ctl select left;; $modkey-$right) wmiir xwrite /tag/sel/ctl select right;; $modkey-$up) wmiir xwrite /tag/sel/ctl select up;; $modkey-$down) wmiir xwrite /tag/sel/ctl select down;; $modkey-space) wmiir xwrite /tag/sel/ctl select toggle;; # Client movement $modkey-Shift-$left) wmiir xwrite /tag/sel/ctl send sel left;; $modkey-Shift-$right) wmiir xwrite /tag/sel/ctl send sel right;; $modkey-Shift-$up) wmiir xwrite /tag/sel/ctl send sel up;; $modkey-Shift-$down) wmiir xwrite /tag/sel/ctl send sel down;; $modkey-Shift-space) wmiir xwrite /tag/sel/ctl send sel toggle;; # Column Mode $modkey-d) wmiir xwrite /tag/sel/ctl colmode sel default-max;; $modkey-s) wmiir xwrite /tag/sel/ctl colmode sel stack-max;; $modkey-m) wmiir xwrite /tag/sel/ctl colmode sel stack+max;; # Client Commands $modkey-Shift-c) wmiir xwrite /client/sel/ctl kill;; $modkey-f) wmiir xwrite /client/sel/ctl Fullscreen toggle;; # Run program $modkey-Return) terminal &;; $modkey-p) eval exec wmiir setsid "$(proglist $PATH | wimenu -s 0)" &;; $modkey-a) { set -- $(proglist $actiondir | wimenu -s 0) echo $actiondir/$@ eval exec $actiondir/$@ } &;; # Select view $modkey-t) # Prompt the user for a tag tag=$(wmiir ls /tag | sed 's,/,,; /^sel$/d' | wimenu -s 0) # Write it to the filesystem. wmiir xwrite /ctl view $tag;; $modkey-[0-9]) # wmiir xwrite /ctl view ${1##*-};; tag=$(wmiir ls /tag | grep -v sel/ | tail -n +${1##*-} | head -n 1 | sed 's/\///') wmiir xwrite /ctl view $tag;; # Tag client $modkey-Shift-t) # Prompt the user for new tags tag=$(wmiir ls /tag | sed 's,/,,; /^sel$/d' | wimenu -s 0) # Write them to the client wmiir xwrite /client/sel/tags $tag;; $modkey-Shift-[0-9]) # wmiir xwrite /client/sel/tags ${1##*-};; tag=$(wmiir ls /tag | grep -v sel/ | tail -n +${1##*-} | head -n 1 | sed 's/\///') wmiir xwrite /client/sel/tags $tag;; esac;; # Client menu ClientMouseDown) # ClientMouseDown <Client ID> <Button> case $2 in 3) clickmenu \ "Delete:wmiir xwrite /client/$1/ctl kill" \ "Remove:wmiir xwrite /client/$1/tags -$(wmiir read /tag/sel/ctl | head -n 1)" \ "Kill:wmiir xwrite /client/$1/ctl slay";; 4) wmiir xwrite /tag/sel/ctl select up;; 5) wmiir xwrite /tag/sel/ctl select down;; esac;; # Tag events LeftBarMouseDown) # LeftBarMouseDown <Button> <Bar Name> wmiir xwrite /ctl view $2;; # Widget events RightBarMouseDown) # RightBarMouseDown <Button> <Bar Name> case $2 in # Which widget mpd) case $1 in 1) mpc -q toggle mpd | wmiir write /rbar/mpd;; 3) terminal -e ncmpcpp &;; 4) mpc -q prev mpd | wmiir write /rbar/mpd;; 5) mpc -q next mpd | wmiir write /rbar/mpd;; esac;; vol) case $1 in # Which mouse button 1) # Left button amixer sset Master toggle vol | wmiir write /rbar/vol;; 4) # Scroll up amixer sset Master playback 2dB+ vol | wmiir write /rbar/vol;; 5) # Scroll down amixer sset Master playback 2dB- vol | wmiir write /rbar/vol;; esac;; mail) wmiir setsid firefox mail.google.com &;; zclock) terminal -hold -e cal -3 &;; esac;; esac done