[dev] wmii - key events are not read unless they are repeated

From: Ben Smith <bensmith87_AT_gmail.com>
Date: Sun, 8 May 2011 15:54:33 +1000

Hi,

I'm starting to get into scripting wmii and am having a little trouble
reading key events, e.g. the programs list does not appear until its pressed
a few times, or another action if called.

This is also my first adventure into scripting.

I'm on arch linux with the wmii installed from community which is version
3.9.2-1 and I'm following the customizing section of the users guide.

Below is my wmiirc script that I'm using by calling "exec wmii -r ~/wmiirc"
in my .xinitrc file, any advice would be greatly appreciated.

I'm not sure if it's best practice to post large scripts here, so please let
me know for the future.
#!/bin/sh

up=k
down=j
left=h
right=l

focuscolors='#000000 #cd6d37 #000000'
normcolors='#000000 #848484 #000000'

font="xft:Sans-9"

wallpaper="/home/ben/pictures/wallpaper.png"
feh --bg-tile $wallpaper &

proglist() {
    IFS=: set -- $1
    find -L $@ -maxdepth 1 -perm /111 | sed '1d; s,.*/,,' | sort | uniq
    unset IFS
}

wmiir write /ctl <<!
    font $font
    focuscolors $focuscolors
    normcolors $normcolors
    grabmod Mod4
    border 1
    view 1
    bar on top
!

{
cat <<!
Mod4-p
Mod4-h
!
for i in 1 2 3 4 5 6 7 8 9 0; do
    echo Mod4-$i
done
} | wmiir write /keys

wmiir xwrite /event Start wmiirc
wmiir xwrite /event CreateTag 1

# Turn off globbing
set -f

# Open /event for reading
wmiir read /event |
# Read the events line by line
while read line; do

    # Split the line into words, store in $@
    set -- $line
    event=$1; shift
    line = "$(echo $line | sed 's/^[^ ]* //' | tr -d '\n')"

    # 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 $normalcolors $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
        Mod4-h) wmiir xwrite /tag/sel/ctl select left
            ;;

        # Run program
        Mod4-p)
            eval exec wmiir setsid "$(proglist $PATH | wimenu -s 0)" &
            ;;

        Mod4-[0-9])
            wmiir xwrite /ctl view ${1##*-}
            ;;
        esac
        ;;

    # Tag menu events
    LeftBarMouseDown) # LeftBarMouseDown <Button> <Bar Name>
        [ $1 = 3 ] && clickmenu \
        "Delete:delete_view $2"
    esac
done

-- 
Regards,
Ben Smith
Received on Sun May 08 2011 - 07:54:33 CEST

This archive was generated by hypermail 2.2.0 : Sun May 08 2011 - 08:00:05 CEST