You are not logged in.

#1 2008-12-15 21:11:21

andr3as
Member
Registered: 2008-10-06
Posts: 53

controlling mpd via dmenu

Hi,

i already posted the script in the "Post your handy self made command line utilities" thread, but probably hardly anybody will look at the programming forum when searching for something like this.
I hope it is ok to post it again here, if not feel free to delete this topic (if you are a mod) wink

This script lets you select any track of your current mpd playlist via dmenu and makes mpd play it immediately.
I think it is pretty useful when bound to a keyboard shortcut in any tiling wm.
Yes, it took only a few minutes to do this, but maybe you'll find it useful nontheless.

#!/bin/bash
mpc play `mpc playlist | sed -e "s/^>/ /" | dmenu -i | grep -P -o "^ \d+" `

Offline

#2 2008-12-16 03:08:09

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: controlling mpd via dmenu

Nice . I found it pretty useful.
Thanks


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#3 2008-12-16 14:14:41

Windowlicker
Member
Registered: 2008-07-20
Posts: 15

Re: controlling mpd via dmenu

Here's one for selecting which folder to play:

#!/bin/sh

cmd=$(mpc ls | dmenu)

if [ -d ~/music/"$cmd" ]; then
  mpc clear & mpc add "$cmd"
  mpc play
fi

Last edited by Windowlicker (2008-12-16 14:16:36)

Offline

#4 2009-06-29 21:53:24

bjesus
Member
Registered: 2007-04-06
Posts: 49

Re: controlling mpd via dmenu

hey, here is my version. it basically just makes sure mpd wouldn't add all of your music in case you close dmenu without selecting.

#!/bin/sh

cmd=$(mpc ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)
if [$cmd == ""]; then
  echo "bye"
else
if [ -d ~/music/albums/"$cmd" ]; then
  mpc add "$cmd"
  mpc play
fi
fi

Offline

#5 2009-06-29 21:58:03

lifeafter2am
Member
From: 127.0.0.1
Registered: 2009-06-10
Posts: 1,332

Re: controlling mpd via dmenu

Ah, nice everyone!  Adding now!


#binarii @ irc.binarii.net
Matrix Server: https://matrix.binarii.net
-------------
Allan -> ArchBang is not supported because it is stupid.

Offline

#6 2009-06-29 22:00:32

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: controlling mpd via dmenu

i think we need a dmenu hacks thread, hehe.  anyway here's my version of the same thing (did someone say bikeshed?)

mine accepts search parameters or 'all' to put up the whole playlist.  that way i can search from CLI or bind the 'msearch all' to a key as mentioned.

example:
  msearch a love supreme
  msearch led zeppelin
  msearch all

#!/bin/bash

if [ -f $HOME/.dmenurc ]; then
  . $HOME/.dmenurc
else
  DMENU='dmenu -i'
fi

if [ $# -eq 1 -a "$1" = "all" ]; then
  mpc --no-status play $(mpc playlist --format '%title% by %artist%' | cut -c 2- | sed 's/)/ -/g' | $DMENU | awk '{print $1}')
else
  mpc --no-status play $(mpc playlist --format '%title% by %artist% #| %album%' | cut -c 2- | sed 's/)/ -/g' | grep -i "$*" | cut -d '|' -f 1 | $DMENU | awk '{print $1}')
fi

i also keep a file at $HOME/.dmenurc that contains the DMENU variable so my 4 different dmenu scripts can all source it and keep consistent font/colors which i can change easily from one file.

Offline

#7 2009-08-07 09:58:57

SpeedVin
Member
From: Poland
Registered: 2009-04-29
Posts: 955

Re: controlling mpd via dmenu

Hello I want to control mpd via dmenu/script I am using bjesus script but I have space I the name of song.
I will give you an example:
SpeedVin - Rock's wink
And I can't play it becouse for sh it's another command neutral
I'm using mpd+ncmpcpp and is there any option to change spaces to _ in their config files(mpd,ncmpcpp) without change name of files ?
Ok solved now I'm using andr3as script wink
Thanks for help smile

Last edited by SpeedVin (2009-08-07 11:31:54)


Shell Scripter | C/C++/Python/Java Coder | ZSH

Offline

#8 2009-08-07 11:37:30

SpeedVin
Member
From: Poland
Registered: 2009-04-29
Posts: 955

Re: controlling mpd via dmenu

I modied bjesus and andr3as script's and now this script can play files with space in name and change colors wink

#!/bin/bash
mpc play `mpc playlist | sed -e "s/^>/ /" | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf  "#afff2f" -i | grep -    P -o "^ \d+" `

Shell Scripter | C/C++/Python/Java Coder | ZSH

Offline

#9 2011-03-21 01:32:56

xj9578cd
Member
Registered: 2011-03-21
Posts: 3

Re: controlling mpd via dmenu

I had an idea to search the internet from DMENU like surfraw.

surfraw ixquick -browser=firefox

But incorporating the search terms into the command line is difficult. It would be nice to make some alias like "x" then one could type "x my_term" in the DMENU and open firefox with the term searched already. I use Xmonad and vimperator, and this edition to DMENu would be neat.

Offline

#10 2011-03-21 11:52:05

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: controlling mpd via dmenu

You really shouldn't resurrect 2 year old threads. Just create a new one.

Offline

Board footer

Powered by FluxBB