Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[howto] custom menu in dwm
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
cyclon3
n00b
n00b


Joined: 09 Nov 2003
Posts: 9
Location: Aachen

PostPosted: Wed Dec 05, 2007 4:34 am    Post subject: [howto] custom menu in dwm Reply with quote

why?
some months ago, i fell in love with dwm. i customized my config and added shortcuts for my most used programs.
but sometimes i forgot a command don't use that often. i wished a menu like the fluxbox-menu in such moments.
so i decided to write a script which uses dmenu (comes with dwm) and it ended up very very simple.

what you need!
create a dir e.g. $HOME/.menu.

think of categories for your programs you want to have:
e.g.:
- Mail
- Video
- Audio

..an the order of them.

create your category with the programs!
e.g. "Mail" should be the first category, then create a file in your dir called "01_Mail".

the file consists of the program's names and its commands:

Description,command

e.g.:
~/.menu/01_Mail:
Code:
Mozilla Thunderbird,thunderbird
Mutt,mrxvt -e mutt
get my mails!,mrxvt -e getmail

...

the script!
menu.sh
Code:
#!/bin/bash

menudir=$HOME/".menu"

subname=$(ls $menudir | cut -d "_" -f 2 | dmenu)
sub=$(ls $menudir | grep $subname)

exename=$(cat $menudir/$sub | cut -d "," -f 1 | dmenu)
exe=$(cat $menudir/$sub | grep $exename | cut -d "," -f 2)

exec $exe


screenshot, showing the config and the dir

and that's it! now you can execute the script and make a shortcut for it :)

ps: sorry for my bad english!
Back to top
View user's profile Send private message
sleipner
n00b
n00b


Joined: 13 Aug 2005
Posts: 48

PostPosted: Sat Dec 08, 2007 6:11 am    Post subject: Reply with quote

this is great.. thanks for sharing!
i didn't like categories though so i fixed your script to more my likings :)

Code:

#!/bin/bash

exename=$(cat "$@" | cut -d "," -f 1 | dmenu)
if [ $? -eq 0 ]; then
   exe=$(cat "$@" | grep "$exename" | cut -d "," -f 2)
   exec $exe
fi


there was few problems tho..
if you close dmenu with escape it launches first application from list. to fix either check return value of dmenu or that exename isn't empty.
and if exename contains spaces, grep wont work without quotes on exename.
Back to top
View user's profile Send private message
nenemsis5
n00b
n00b


Joined: 23 Oct 2007
Posts: 72

PostPosted: Sat Dec 08, 2007 11:30 pm    Post subject: Reply with quote

greate
thx
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum