Page 2 of 2

Re: post your custom dmenu

Posted: Thu Apr 30, 2015 5:37 am
by machinebacon
^ In this case, "stop" can actually be dropped :D

Re: post your custom dmenu

Posted: Thu Apr 30, 2015 9:42 am
by rhowaldt
^ ja, but i wanted to have at least an option to stop the music completely. this is just to soothe my mind; when i pause, i still feel it "hanging", whereas when i stop, it is stopped and done. /ENOGHU!

Re: post your custom dmenu

Posted: Thu Apr 30, 2015 10:20 am
by machinebacon
^ Your mind is paranoid. ;) I need facts! :D

Re: post your custom dmenu

Posted: Thu Apr 30, 2015 10:31 am
by rhowaldt
no such thing as facts! nothing is true. ;_;

Re: post your custom dmenu

Posted: Sat May 09, 2015 8:53 am
by elixir
This is all so neat. I honestly had no idea that dmenu hacking/customizing was a thing.

Re: post your custom dmenu

Posted: Sat May 09, 2015 3:34 pm
by rhowaldt
since i wanted to use xft fonts in dmenu i switched to dmenu2 instead, which works really well :)

Re: post your custom dmenu

Posted: Sat May 09, 2015 4:18 pm
by rhowaldt
adjusted version to deal with MOC server not running:

Code: Select all

#!/bin/bash
 
#       Custom dmenu-moc.sh
#
#       Copyright 2009, Gatti Paolo (lordkrandel at gmail dot com)
#       Distributed as public domain.
#		Modified to use with MOC by rhowaldt 290415

bgcol=$(xrdb -query | sed -n "/*background:/s/*background://p" $xcolors | tr -d [:blank:])
fgcol=$(xrdb -query | sed -n "/*foreground:/s/*foreground://p" $xcolors | tr -d [:blank:])
sbgcol=$(xrdb -query | sed -n "/*color4:/s/*color4://p" $xcolors | tr -d [:blank:])
#font='-misc-fixed-*-r-*-*-12-*-*-*-*-*-*-*'

title="MOC "
moc_running=$(pidof "mocp" > /dev/null && echo 1 || echo 0)
if [ $moc_running -eq 1 ]; then
menu=( \
#               labels            commands
#           Main =========================================
                next               "mocp --next"
                playpause          "mocp --toggle-pause"
                stop               "mocp --stop"
                quit               "mocp --exit"
    )

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 $bgcol -nf $fgcol -sb $sbgcol -sf $fgcol`
 
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
else
echo "--server not running--" | dmenu -p $title -nb $bgcol -nf $fgcol -sb $sbgcol -sf $fgcol
fi

Re: post your custom dmenu

Posted: Fri May 15, 2015 12:05 pm
by stark
Updated dmenu2 script with colr and icons from siji.
menu.png
menu.png (4.96 KiB) Viewed 5273 times

Code: Select all

#!/usr/bin/env bash
 
# Preferred terminal
terminal='urxvtc'
 
# Preferred editor
editor='vim'
 
# Drawing the line ( hexcode will vary if not using lime )
auto_line ()
{
	# You may change the limit ( i.e the number 11 ) to suit your needs
	for i in {1..11}
	do
		printf "\u00c4"
	done
}
 
# Fonts
font1='-artwiz-lime-medium-r-normal--10-110-75-75-m-50-iso8859-1'
font2='-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1'
 
# Dmenu Preferences
 
# Width
W=64
# Horizontal Position
X=612
# Vertical Position
Y=304
 
 
menu_list="  Run\n  File\n  Edit\n  View\n  Term\n  Web\n  Rngr\n  Wifi\n  Music\n`auto_line`\n  Info\n  Find\n  Sett\n\n    "
 
# Get colr: http://ow.ly/MYBjg or manually enter the color codes
Dmenu="/usr/bin/dmenu -i -fn '$font1','$font2' -x $X -y $Y -w $W -l 20 -nb '#`colr bg`' -sb '#`colr cynf`' -nf '#`colr fg`' -sf '#`colr bg`'"
 
 
# Putting it all together
cmd=$(echo -e "$menu_list" | eval $Dmenu)
 
case $cmd in
 
	*Run)
		$HOME/bin/dmenu.scripts/run-recent ;;
 
	*File)
		thunar > /dev/null 2>&1 ;;
 
	*Edit)
		$terminal -e $editor
 
	*View)
		sxiv -qbfr $HOME/images/ ;;
 
	*Term)
		$terminal -g 120x40 -e bash -c "tmux -q has-session && exec tmux attach-session -dt main || exec tmux new-session -nmain -smain" ;;
 
	*Web)
		firefox --private > /dev/null 2>&1 ;;
 
	*Music)
		$HOME/bin/mpd-launch ;;
 
	*Rngr)
		$terminal -e ranger ;;
 
	*Wifi)
		gksudo $HOME/bin/dmenu.scripts/.connman_dmenu > /dev/null 2>&1 ;;
 
	*Info | ";"i | i";")
		$HOME/bin/dmenu.scripts/stat ;;
 
	*Find)
		$HOME/bin/dmenu.scripts/finder ;;
 
	*Sett | ";"s | s";")
		$HOME/bin/dmenu.scripts/settings ;;
 
	quit | * | ";"q | q |q";")
		$HOME/bin/dmenu.scripts/exit-menu ;;
 
	h | ";"h | h";")
		$terminal -g 68x6 -e htop ;;
 
	";"a | a";")
		$HOME/bin/dmenu.scripts/.dscript ;;
 
	";"t | t";")
		$HOME/bin/dmenu.scripts/todo ;;
 
	";"e | e";")
		$terminal -e $editor $HOME/bin/dmenu.scripts/.menu ;;
 
	"/")
		$terminal -e $editor $HOME/bin/dmenu.scripts/ ;;
 
	k | ";"k | k";")
		$HOME/bin/dmenu.scripts/pkill-menu ;;
esac
 
exit 0

Re: post your custom dmenu

Posted: Fri May 15, 2015 1:17 pm
by rhowaldt
that looks cool :)

(this is essentially just like the Openbox menu in dmenu, no?)

Re: post your custom dmenu

Posted: Fri May 15, 2015 1:44 pm
by stark
Thanks :)

I didn't mess with openbox that much so I don't know and remember much about the xml stuff. But essentially yeah just a predefined menu. You can make the positioning dynamic so it launches under the cursor by using xdotool. I can add the xdotool version if you want :)

Re: post your custom dmenu

Posted: Fri May 15, 2015 4:40 pm
by rhowaldt
thanks stark, i wont be using it myself as it doesnt fit my workflow, so worries about the xdotool :)