Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -f
- up=k
- down=j
- left=h
- right=l
- modkey=Mod4
- focuscolors='#000000 #cd6d37 #000000'
- normcolors='#000000 #848484 #000000'
- font="xft:Sans-9"
- wallpaper="/home/ben/pictures/wallpaper.png"
- feh --bg-tile $wallpaper &
- actiondir="/home/ben/.wmii"
- 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 <<!
- focuscolors $focuscolors
- normcolors $normcolors
- grabmod $modkey
- border 1
- view 1
- bar on top
- font $font
- !
- # Create initial view
- echo $focuscolors 1 | wmiir create /lbar/1
- # Create the notice bar
- echo $normcolors | wmiir create /rbar/!notice
- # Right bar widgets
- # Clock
- echo $normcolors clock | wmiir create /rbar/clock # Create the widget
- clock() {
- echo ◷ $(date '+%a %d, %b; %X')
- }
- while clock | wmiir write /rbar/clock; do
- sleep 1
- done &
- # MPD
- echo $normcolors mpd | wmiir create /rbar/mpd
- mpd() {
- if [ `mpc status | grep playing | wc -l` -eq 1 ]; then
- echo -n ▶ `mpc status | head -n 1`
- else
- if [ `mpc status | grep paused | wc -l` -eq 1 ]; then
- echo -n ▮▮ `mpc status | head -n 1`
- else
- echo -n ▪
- fi
- fi
- }
- while mpd | wmiir write /rbar/mpd; do
- sleep 4
- done &
- # Volume
- echo $normcolors vol | wmiir create /rbar/vol
- vol() {
- echo ♪ $(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 '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" | wc -l`
- if [ $unread -eq 0 ]; then
- echo -n $normcolors ⌧ $unread
- else
- echo -n $focuscolors ⌧ $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
- !
- 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
- # 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
- # Process the event
- case $event in
- 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;;
- 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-[0-9])
- wmiir xwrite /ctl view ${1##*-};;
- # Tag client
- $modkey-Shift-[0-9])
- wmiir xwrite /client/sel/tags ${1##*-};;
- esac;;
- # Client menu
- ClientMouseDown) # ClientMouseDown <Client ID> <Button>
- [ $2 = 3 ] && clickmenu \
- "Delete:wmiir xwrite /client/$1/ctl kill" \
- "Kill:wmiir xwrite /client/$1/ctl slay";;
- # 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 &;;
- clock)
- terminal -hold -e cal -3 &;;
- esac;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement