SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-09-28 22:22:15

lordkrandel
New Member
Registered: 2009-09-28
Posts: 8

Custom dmenu-bind.sh

Updates

#       09.29.2009 -- Submenu support added

This is my personal dmenu-bind.sh, pretty easy to understand and modify. There is also a fast command to edit itself with gedit.

Is there any hope to see it being default? And what about having me write a little script with obxml to convert the default obmenu to commands for dmenu?

Discuss,
lordkrandel


#!/bin/bash

#       Custom dmenu-bind.sh
#
#       Copyright 2009, Gatti Paolo (lordkrandel at gmail dot com)
#       Distributed as public domain.

#       09.28.2009 -- First release
#       09.29.2009 -- Submenu support added

if [ "$1" == "" ]; then
    title="MainMenu"
    menu=( \
#               labels            commands
#           Main =========================================
                web               "$0 web"
                system            "$0 system"
                tools             "$0 tools"
                settings          "$0 settings"
    )
else
    case $1 in
    web)
        title="web"
        menu=( \
#           Web ==========================================
                firefox           "firefox" \
                lostirc           "lostirc" \
         )
    ;;
    tools)
        title="tools"
        menu=( \
#           Tools ========================================
                gedit             "gedit" \
                geditsudo         "gksudo gedit" \
         )
    ;;
    system)
        title="system"
        menu=( \
#           System =======================================
                home              "pcmanfm" \
                tilda             "tilda" \
                synaptic          "gksudo synaptic" \
         )
    ;;
    settings)
        title="settings"
        menu=( \
#           Settings =====================================
                volume            "$0 volume" \
                dmenu             "gedit $0" \
                obconf            "obconf" \
         )
    ;;
    volume)
        title="Volume"
        menu=( \
#           Volume controls ==============================
                0%                "amixer sset Master 0" \
                50%               "amixer sset Master 50" \
                70%               "amixer sset Master 70" \
                100%              "amixer sset Master 100" \
         )
    ;;
    
    esac
fi

for (( count = 0 ; count < ${#menu[*]}; count++ )); do

#   build two arrays, one for labels, the other for commands
    temp=${menu[$count]}
    if (( $count < ${#menu[*]}-2 )); then
        temp+="\n"
    fi
    if (( "$count" % 2 == "0" )); then
        menu_labels+=$temp
    else
        menu_commands+=$temp
    fi

done

select=`echo -e $menu_labels | dmenu -p $title -nb black -nf white -sb darkblue -sf white`

if [ "$select" != "" ]; then

#   fetch and clean the index of the selected label
    index=`echo -e "${menu_labels[*]}" | grep -xnm1 $select | sed 's/:.*//'`
    
#   get the command which has the same index
    part=`echo -e ${menu_commands[*]} | head -$index`
    exe=`echo -e "$part" | tail -1`

#   execute
    $exe &
fi

Last edited by lordkrandel (2009-09-29 12:58:30)

Offline

Help fund CrunchBang, donate to the project!

#2 2009-09-28 23:30:38

hailukahh
#! Member
From: Texas
Registered: 2009-07-27
Posts: 87

Re: Custom dmenu-bind.sh

Great script.  I'd been wanting something like that, but been too lazy.  Thanks


<'(((><  I am not ashamed of the gospel, because it is the  ><)))'>
<'(((><  power of God, the salvation of everyone who believes.  ><)))'>

EeePC 900a : #! 9.04 : Atom 1.60 GHz : 1 GB RAM : 4 GB SSD

Offline

#3 2009-09-29 01:07:05

corenominal
root
From: Lincoln, UK
Registered: 2008-11-20
Posts: 4,887
Website

Re: Custom dmenu-bind.sh

hailukahh wrote:

Great script.  I'd been wanting something like that, but been too lazy.  Thanks

+1, thank you for sharing! smile

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo