You are not logged in.

#1 2009-07-23 23:53:52

richardmurri
Member
Registered: 2008-10-29
Posts: 39

Yet another dmenu launcher

Give this script a try.  It should be pretty easy to understand. wink

It requires wmctrl and dmenu-vertical.

#!/bin/bash

append_path=1
path_delimiter='  '

hostname=`hostname`

# find active windows
wins=`wmctrl -l`

# filter out sticky windows
filteredwins=`echo "$wins" | grep -v '0x[0-9a-f]* *-1'`

# perform sustitutions
filteredwins=`echo "$filteredwins" | sed 's/- File Manager/- Thunar/'`

# filter out other window information
wintitles=`echo "$filteredwins" | sed "s/.*\(${hostname}\|N\/A\) \(.*\)/\2/"`

# add path executables if applicable
if [ "$append_path" == "1" ]; then
    commands=`echo "$wintitles"; dmenu_path | sed "s/^/$path_delimiter/"`
else
    commands=$wintitles
fi

# show dmenu
selectedwin=`echo "$commands" | dmenu -l 25 -w 400 -x 400 -y 480 -rs -c -ni -i -xs`

if [ "$?" == "0" ]; then

    # strip path delimiter
    if [ "$append_path" == "1" ]; then
        selectedwin=${selectedwin#$path_delimiter}
    fi

    # undo substitutions
    selectedwin=`echo "$selectedwin" | sed 's/- Thunar/- File Manager/'`

    # activate selected window
    wmctrl -F -a "$selectedwin"

    # if no window matches, launch the program selected
    if [ "$?" == "1" -a "$append_path" == "1" ]; then
        exec $selectedwin
    fi
fi

Offline

Board footer

Powered by FluxBB