You are not logged in.
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.
update:
Okay, I modified Red Dwarf's script for google uk and it works with surfraw. Still working on it. I was having trouble because I just installed on a new laptop and forgot to export my surfraw path in .bashrc (export PATH="/usr/lib/surfraw:$PATH")! It wouldnt work until I did that.
#!/bin/bash
if [ -f $HOME/.dmenurc ]; then
. $HOME/.dmenurc
else
DMENU='dmenu -nb #fffab2 -nf #2d73b9 -sf green -fn '-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*' -i'
fi
SS=`cat ~/.sshist | $DMENU $*`
if grep -q "$SS" "$HOME/.sshist" ; then
echo already exists in history
else
echo $SS >> ~/.sshist
fi
surfraw ixquick -browser=firefox -new=yes "$SS"
Still working on it, to run a variable with different search engines from dmenu. For now you have to edit the script to change search engine.
Last edited by xj9578cd (2011-03-22 05:01:57)
Offline
Got another script to control MPD. Whipped this up prettly quickly last night, somebody wanted something like this.
First it let's you pick an artist, and after selecting one, another instance of dmenu opens wich let's you pick an album to play, or decide to play all by that artist (given your music is stored like /musicdir/artist/album).
#!/bin/bash
if [[ -f $HOME/.config/dmenurc ]]; then
. $HOME/.config/dmenurc
else
DMENU="dmenu -i"
fi
ARTIST=$( mpc ls | $DMENU )
if [[ $ARTIST == "" ]]; then
exit 1
else
ALBUM=$( echo -e "Play All\n$( mpc ls "$ARTIST" )" | $DMENU )
if [[ $ALBUM == "" ]]; then
exit 1
else
mpc clear
if [[ $ALBUM == "Play All" ]]; then
mpc add "$ARTIST"
else
mpc add "$ALBUM"
fi
mpc play
fi
fi
exit 0
Offline
Actually, I've been sitting on a similar script to what k3ttc4r just posted for about a year. This SHOULD work based on any directory structure because it uses mpc find to get all files with the inputted tags. As such, it's probably quite a bit slower on very large collections. (And it's not as pretty)
I also don't use a dmenurc, but instead export the values for dmenu's configuration from my .zprofile. It's not as compact in the script, but I think it works well enough for me.
#!/bin/sh
artist=$(mpc list artist| sort -n | dmenu -fn "$DMENU_FONT" -nb "$DMENU_NORMBG" -nf "$DMENU_NORMFG" -sb "$DMENU_SELBG" -sf "$DMENU_SELFG" -i -p "ARTIST:" -l 10)
if [[ $artist = '' ]]; then
exit
else
if [[ $(mpc list album artist "$artist" | wc -l) > 1 ]]; then
album=$(mpc list album artist "$artist"| sort -n | dmenu -fn "$DMENU_FONT" -nb "$DMENU_NORMBG" -nf "$DMENU_NORMFG" -sb "$DMENU_SELBG" -sf "$DMENU_SELFG" -i -p "ALBUM:" -l 3)
fi
mpc clear >> /dev/null
if [[ $album = '' ]]; then
echo "Playlist cleared, Adding all songs available from $artist to the playlist"
mpc find artist "$artist" | mpc add
else
echo "Playlist cleared, Adding $artist - $album to the playlist"
mpc find artist "$artist" album "$album" | mpc add
fi
mpc play >> /dev/null
fi
exit 0
"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)
Offline
So here is my contribution. I was really missing an option to print pdfs with mupdf, it does not support this afaik. It uses lpstat to get the list of printers and the list of options for the one you choose, you can set as many options as you like. It finally prints the pdf with lpr.
Enjoy, please comment if you have suggestions!
#!/bin/bash
# printpdf - script
# usage:
# printpdf file.pdf
# printpdf file1.pdf file2.pdf
# printpdf *.pdf
# by i_magnific0
COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
then
DMENU="dmenu -i -xs -rs -l 10" # vertical patch
else
DMENU="dmenu -i" # horizontal, oh well!
fi
printer=`lpstat -p | awk '{print $2}' | $DMENU -p 'Printer:' $COLORS | perl -p -e 's/^.*?: ?//'`
set_options=`echo -e 'No\nYes' | $DMENU -p 'Set options?' $COLORS | perl -p -e 's/^.*?: ?//'`
options=""
# standard options to lpr, not in the printer lpstat -l
standard_options="page-ranges\nlandscape"
while [ $set_options == "Yes" ]; do
custom_options=`lpoptions -d $printer -l | grep -v NotInstalled | awk '{ print $1 }' | sed 's/:\+//g'`
option_to_set=`echo -e "$standard_options\n$custom_options" | $DMENU -p 'Option:' $COLORS | perl -p -e 's/^.*?: ?//'`
option_value=`lpoptions -d $printer -l | grep $option_to_set | awk 'BEGIN { FS = ": " } ; { print $2 }' | sed 's/ \+/\n/g' | sed 's/*\+//g' | $DMENU -p 'Setting:' $COLORS | perl -p -e 's/^.*?: ?//'`
option_to_set_1d=`echo $option_to_set | awk 'BEGIN { FS = "/" } ; { print $1 }'`
if [ -z $option_value ]; then
options=$options"-o $option_to_set_1d "
else
options=$options"-o $option_to_set_1d=$option_value "
fi
set_options=`echo -e 'No\nYes' | $DMENU -p 'Set more options?' $COLORS | perl -p -e 's/^.*?: ?//'`
done
lpr $options -P $printer $@
Offline
I've been using this one for many months now and I can't live without it anymore (on the computer). It was written by Dieter Plaetinck and posted somewhere here in the forums. I had to make it depend on dmenu-path-c because of changes in dmenu. Maybe someone capable can make it use stest like dmenu_run does? I'll try it myself again, maybe this time I'll succeed.
Anyways, here's this little perl
It's a drop-in replacement for dmenu_run and adds the ability to either run the application in the background (e.g. web browsers, libreoffice, etc.) or in the terminal (mutt, ranger, ncmpcpp, etc.). You'll have to tell it the first time you launch an application, if it's supposed to be run in the background or in a terminal. After that it won't ask again.
Last edited by Army (2012-01-23 22:30:17)
Offline
Does anyone know of a patch that adds a --height option to dmenu? Google has left me hanging so far. Guess I'll try writing my own.
Offline
Does anyone know of a patch that adds a --height option to dmenu?
https://bbs.archlinux.org/viewtopic.php?id=124915
Maybe this? I haven't tried it, but was thinking of playing with it too.
Offline
Runiq wrote:Does anyone know of a patch that adds a --height option to dmenu?
https://bbs.archlinux.org/viewtopic.php?id=124915
Maybe this? I haven't tried it, but was thinking of playing with it too.
Nope, that patch is for offsets and width only, unfortunately. I'm currently working on the height patch, though, and it's almost finished. Just a few minor issues to work out.
Offline
Okay, it's finished and working. See here.
I'll get it to work with the Xft patch, shouldn't take more than an hour (I still don't speak C and am pretty new to coding in general).
Edit: I finished the Xft version; URL is the same as above. I love gist.
Last edited by Runiq (2012-02-06 23:17:52)
Offline
Okay, it's finished and working. See here.
I'll get it to work with the Xft patch, shouldn't take more than an hour (I still don't speak C and am pretty new to coding in general).
Edit: I finished the Xft version; URL is the same as above. I love gist.
Thanks, oh my gosh, this is a great addition to the 'dmenu family'. Now, if only the y offset patch I crudely hacked (dmenu-xft package) could be incorporated, I'd be on Cloud 9!
--- dmenu-4.5/dmenu.c 2012-02-03 23:00:09.485789612 +0000
+++ dmenu-4.5/dmenu-yoffset.c 2012-02-03 23:06:55.052650108 +0000
@@ -44,6 +44,7 @@ static void usage(void);
static char text[BUFSIZ] = "";
static int bh, mw, mh;
static int inputw, promptw;
+static int yoffset = 0;
static size_t cursor = 0;
static const char *font = NULL;
static const char *prompt = NULL;
@@ -92,6 +93,8 @@ main(int argc, char *argv[]) {
/* these options take one argument */
else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]);
+ else if(!strcmp(argv[i], "-y"))
+ yoffset = atoi(argv[++i]);
else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i];
else if(!strcmp(argv[i], "-fn")) /* font or font set */
@@ -578,7 +581,7 @@ setup(void) {
break;
x = info[i].x_org;
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+ y = info[i].y_org + (topbar ? yoffset : info[i].height - mh - yoffset);
mw = info[i].width;
XFree(info);
}
@@ -586,7 +589,7 @@ setup(void) {
#endif
{
x = 0;
- y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh;
+ y = topbar ? yoffset : DisplayHeight(dc->dpy, screen) - mh - yoffset;
mw = DisplayWidth(dc->dpy, screen);
}
promptw = prompt ? textw(dc, prompt) : 0;
@@ -614,7 +617,7 @@ setup(void) {
void
usage(void) {
- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n"
+ fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-y offset] [-p prompt] [-fn font]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
exit(EXIT_FAILURE);
}
Offline
Thanks Runiq! The height patch works great.
Offline
Thanks, oh my gosh, this is a great addition to the 'dmenu family'. Now, if only the y offset patch I crudely hacked (dmenu-xft package) could be incorporated, I'd be on Cloud 9!
You might be interested in the patch stlarch posted earlier. It adds x and y offsets, a -w option to specify dmenu's width, and a -q option to hide items on empty input. I just added the missing puzzle piece, basically.
I just noticed I forgot adding the -h option to the manpage, I'll do that and then try to incorporate my patch into the qxyw one. And then pull all that into the Xft patch, if possible.
I guess it's about time I started checking out mercurial patch queues or something…
Edit: Manpages updated.
Last edited by Runiq (2012-02-07 11:26:43)
Offline
Okay, it's finished and working. See here.
I'll get it to work with the Xft patch, shouldn't take more than an hour (I still don't speak C and am pretty new to coding in general).
Edit: I finished the Xft version; URL is the same as above. I love gist.
Just a suggestion, I think it's better to use
+ bh = (line_height > dc->font.height) ? line_height : dc->font.height;
rather than
+ bh = (line_height > dc->font.height + 2) ? line_height : dc->font.height + 2;
because only this way you can really determine the real height. Me for example, I don't want those extra 2 pixels.
Offline
Me for example, I don't want those extra 2 pixels.
Yeah, I read about your predicament in the other thread.
I haven't yet suggested this to the mailing list. After I wrote the patch, I found a few alternatives which added a height switch and/or similar things (the qxyw patch above, for example), and they weren't even mentioned on the "official" dmenu patch list. So I don't think I'll post this one either because it's pretty trivial.
Offline
I've never used these tools before and have to ask - I downloaded and extracted dmenu-xft from AUR, moved into the new directory, downloaded the patch file but am completely clueless as to what I should do now? I've got both dmenu-4.5-xft.diff and dmenu-4.5-xft-height.diff but how do I combine them?
Offline
I don't think you need to combine them. You can apply them one after the other using the patch command. If there are any conflicts, you may need to weed through the rej files and hand patch in any failed chunks.
Offline
Here goes:
» wget http://dl.suckless.org/tools/dmenu-4.5.tar.gz
» tar -zxvf dmenu-4.5.tar.gz
» cp dmenu-4.5-xft.diff dmenu-4.5/
» cp dmenu-4.5-xft-height.diff dmenu-4.5/
» cd dmenu-4.5
» patch < dmenu-4.5-xft.diff
patching file config.mk
patching file dmenu.1
patching file dmenu.c
patching file draw.c
patching file draw.h
» patch < dmenu-4.5-xft-height.diff
patching file dmenu.1
patching file dmenu.c
patching file draw.c
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 39 with fuzz 1
I used the dmenu-4.5-xft.diff from the AUR package and the dmenu-4.5-xft-height from Runiq's gist. I don't understand what is wrong. I'm reading the man page for patch and am trying to find a tutorial on these kind of things as well as building from source... but it's rather abstract to me. Advice appreciated.
Offline
totte: It is the missing eol in the file dmenu-4.5-height.diff, patch then complains about this.
Hint: If you inspect that file with vim you can see the "noeol" notification in the statusbar. Saving it will add the eol to the last line (if you have set eol which is the default). Try patching it with the saved file and the message will disappear.
Offline
totte: It is the missing eol in the file dmenu-4.5-height.diff, patch then complains about this.
Hint: If you inspect that file with vim you can see the "noeol" notification in the statusbar. Saving it will add the eol to the last line (if you have set eol which is the default). Try patching it with the saved file and the message will disappear.
Ahh, thank you! I followed your instructions and then ran make and make install, everything works as it should now.
Offline
Cross posted from this thread which inspired the idea.
Launch terminal apps from dmenu with a trivial edit to the dmenu_run script
#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run
else
cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
fi
APP=$(
IFS=:
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u | tee "$cache" | dmenu "$@"
else
dmenu "$@" < "$cache"
fi
)
grep -q -w "$APP" ~/.dmenu_term && urxvtc -e $APP || echo $APP | ${SHELL:-"/bin/sh"} &
I suddenly love dmenu even more.
edit: I should mention some 'instructions'. Change the urxvtc to your terminal of choice, and create a file called .dmenu_term in your home directory with a list of programs that should start in the terminal.
edit2: Improvements added thanks to other members: beloglazov suggested -w switch to avoid substring matching, and steve__ suggested streamlining the conditional statements.
Last edited by Trilby (2012-04-16 14:16:49)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
You can test the exit status of grep.
grep -q "$APP" ~/.dmenu_term && urxvtc -e $APP &
grep -q "$APP" ~/.dmenu_term && echo $APP | ${SHELL:-"/bin/sh"} &
Offline
For all who do not use wallpaper,and for those who use.
I created simple, stupid script to set background color whit Dmenu & Xsetroot. (more than 100 colors)
That script can be made a hundredfold smaller.
ᶘ ᵒᴥᵒᶅ
Offline
A wrapper for deluge-console, to control torrents from dmenu:
EDIT: Whoops, forgot to source '.dmenurc'. Also, this assumes the vertical patch (it would probably look terrible without it).
#!/bin/bash
if [[ -f $HOME/.dmenurc ]]; then
. $HOME/.dmenurc
else
DMENU="dmenu -i"
fi
IFS=$'\n'
torArr=( $(deluge-console info | grep -E 'Name:|State:') )
IFS=$' '
for (( x = 0; x < ${#torArr}; x++ )); do
if [ $(( $x % 2 )) -eq 0 ]; then
# Operations on "Name: "
xp1=`expr $x + 1`
torArr[$xp1]=`echo -e ${torArr[$xp1]} | sed 's/State: //'`
torArr[$xp1]=`echo -e ${torArr[$xp1]} | sed 's/Downloading /D: /'`
torArr[$xp1]=`echo -e ${torArr[$xp1]} | sed 's/Seeding /S: /'`
name_len=${#torArr[$xp1]}
# Operations on "Status: "
num_spaces=1
if [ "$name_len" -lt "$BUF_SPACE" ]; then
num_spaces=`expr $BUF_SPACE - $name_len`
fi
spaces=" "
for (( s_index = 0; s_index < $num_spaces; s_index++ )); do
spaces="$spaces "
done
torArr[$x]=`echo -e ${torArr[$x]} | sed "s/Name: /$spaces/"`
torArr[$x]="${torArr[$xp1]}${torArr[$x]}"
if [ $x -eq 0 ]; then
fmtTorLst=${torArr[0]}
elif [ -n "${torArr[$x]}" ]; then
fmtTorLst="$fmtTorLst\n${torArr[$x]}"
fi
else
true
fi
done
fmtTorLst=`echo -e "$fmtTorLst" | sort`
fmtTorLst="$fmtTorLst\n \nReload\nExit"
selTor=`echo -e "$fmtTorLst" | $DMENU -p "Select Torrent" -l ${#torArr}`
selTor=`echo -e $selTor | sed 's/Paused//'`
selTor=`echo -e $selTor | sed 's/Queued//'`
selTor=`echo -e $selTor | sed 's/D: Down Speed: [0-9]*\.[0-9]* .iB\/s//'`
selTor=`echo -e $selTor | sed 's/\(S: \)\?Up Speed: [0-9]*\.[0-9]* .iB\/s//'`
selTor=`echo -e $selTor | sed 's/ETA: \([0-9]*[dhms] \)*//'`
selTor=`echo -e $selTor | sed 's/^ *//'`
case $selTor in
""|"Exit") # press esc to quit
exit
;;
Reload)
$0
;;
*)
option_list="info\nvinfo\nhalt\nresume\npause\n \nrm\ndel\n \nReturn\nExit"
opt=`echo -e "$option_list" | $DMENU -p "$selTor" -l 10`
case $opt in
info)
torInfo="`deluge-console $opt $selTor | grep -v "Do Not Download"`"
torInfo="$torInfo\n \nReturn\nExit"
fin_option=`echo -e ${torInfo:2:${#torInfo}} | $DMENU -l 30`
case $fin_option in
""|Exit)
exit
;;
*)
$0
;;
esac
;;
vinfo)
torInfo="`deluge-console "info -v" $selTor | grep -v "Do Not Download"`"
torInfo="$torInfo\n \nReturn\nExit"
fin_option=`echo -e ${torInfo:2:${#torInfo}} | $DMENU -l 30`
case $fin_option in
""|Exit)
exit
;;
*)
$0
;;
esac
;;
halt|resume|pause)
deluge-console $opt $selTor
$0
;;
rm|del)
#This should confirm for command, but I don't know how...
deluge-console $opt $selTor
$0
;;
""|Exit)
exit
;;
*)
$0
;;
esac
;;
esac
Last edited by djp (2012-05-15 14:08:00)
Offline