You are not logged in.
If anybody is interested, I made a fork of dmenu.
Its in AUR https://aur.archlinux.org/packages/dmenu2/
It contains i guess all possible paches (x,y, width,height, xft, etc.) and have some extended finctionality.
Now you can:
- select screen on which dmenu appears while in the multi-screen configuration
- change dmenu opacity
- change dmenu window class and name
- dim screen by selected opacity and color while running dmenu
Last edited by melek (2013-02-26 13:32:22)
Offline
There's already been a few window switching scripts posted, but my version feels a bit more clean to me, although it'd very likely have to be modified for every DE that isn't xfce so for it to be portable it would have to either be made messier or modified to read a config file. xD
Here goes (It depends on wmctrl):
#!/bin/sh
if [ "${@:-1}" == "1" ]
then
win=`wmctrl -l | colrm 1 19 | sed '/xfce4-panel/d' | dmenu -i`
else
win=`wmctrl -l | colrm 1 19 | sed '/xfce4-panel/d' | dmenu ${@:-1}`
fi
if [ "$win" == "" ]
then
exit
elif [ "$win" == "Desktop" ]
then
wmctrl -k on
else
wmctrl -a $win
fi
Basically what it does is: First it checks if it has been run with any arguments, and if it has, dmenu will be run with those, if it hasn't, dmenu will just run with -i (case-insensitive matching). Then it removes xfce4-panel from the list of windows returned by `wmctrl` (D'oh). The `colrm`'s removes everything but the window names from the list.
It then checks if nothing was selected and if so exits (Otherwise you get an error from dmenu if ran from the commandline (Another D'oh)), if you selected Desktop it runs `wmctrl -k on` which turns on the window managers 'show the desktop' feauture, and otherwise just raises and gives focus to the selected window.
I apologize for any rambling, unclarity and uncorrectness of my use of the English language. It's 06:00 and I haven't been able to get any sleep, but I hope that atleast parts of my script might be usefull to someone somehow.
Offline
Here's an updated version of my edit script:
#!/bin/sh # # dedit: Use dmenu to open and edit a file from a given list. # Global variables: FILES=${1:-"$HOME/.config/dmenu/edit-list"} if [ -f $XDG_CONFIG_HOME/dmenu/dmenurc ]; then . $XDG_CONFIG_HOME/dmenu/dmenurc else DMENU='dmenu -i -l 8' fi # Show list of options choice=$(awk '{print $1}' $FILES | $DMENU -p "File to edit:") if [[ $choice ]]; then # use eval as get vim error is use awk's system eval $(awk '/'$choice'/ && NF == 2 {printf("'$EDITOR' %s",$2); exit} /'$choice'/ && NF == 3 {printf("%s %s",$3,$2); exit}' $FILES) fi
It will assume standard editor for two entry items, and if there is a third entry it will assume that that is a different editor to use. There may be better ways to do that, but after trying a few out, this works best with how I will use it. The label file being consistently the first two items on the line. That way if I want to add other parameters, I won't need to insert them to existing entries.
Sudo is used by using sudoedit as the editor name, see example below.
Here's a couple of example files:
$ cat ~/.config/dmenu/edit-list bashrc ~/.bashrc bash_profile ~/.bash_profile functions ~/.config/bash/bash_functions xinitrc ~/.xinitrc Xdefaults ~/.Xdefaults vimrc ~/.config/vim/vimrc rc.conf /etc/rc.conf sudoedit editlist $XDG_CONFIG_HOME/dmenu/edit-list acclist $XDG_CONFIG_HOME/dmenu/edit-list-acc $ $cat ~/.config/dmenu/edit-list-acc Forecast ~/data/Accounting/Forecast11-12.xls gnumeric Ledgers ~/data/Accounting/Ledgers.xls gnumeric PPAC ~/data/Accounting/AC20112012.xls gnumeric
Using the second file I wrapped dedit in a function:
acedit () { dedit "$XDG_CONFIG_HOME/dmenu/edit-list-acc" & }
It should be fairly trivial to convert it to a generic command launcher. I haven't done that yet as I'm not sure how much I'll use it.
I'll keep it in mind though.Nothing overly sophisticated, but does a job.
Anyone else tried this as it's not working for me so i tried running it in terminal to see any error messages and got
17: /home/boo/bin/dedit: [[: not found
so line 17 is the problem for me
You can like linux without becoming a fanatic!
Offline
[[ is a bash built-in, what shell are you using.
I *think* in this case you should just be able to swap in [ instead.
Sorry, I should have flagged it wasn't portable (few of my scripts are, so I tend to forget it's worth mentioning).
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
[[ is a bash built-in, what shell are you using.
I *think* in this case you should just be able to swap in [ instead.
Sorry, I should have flagged it wasn't portable (few of my scripts are, so I tend to forget it's worth mentioning).
hmm now I am getting
1: eval: /home/boo/.bashrc: Permission denied
You can like linux without becoming a fanatic!
Offline
Looks like your EDITOR env variable is not set.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
@skanky yes your right, thank a lot - its working now and nice to have
You can like linux without becoming a fanatic!
Offline
@skanky yes your right, thank a lot - its working now and nice to have
Cool, thanks.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
For what it's worth, I'm moving my edit and umount scirpts (above) to use slmenu. The main change is that I'm no longer referencing an rc file and just dropped "slmenu -i -l 5 -p 'prompt here'" in place of $DMENU. What's nice is that the menu appears at the cursor (can be configured to be top or bottom) which for these scripts is, I think, more friendly. There are situations where dmenu makes more sense though, so it's horses for courses.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
Dmenu can be configured to run at the bottom ....
dmenu_run -fn -misc-fixed-*-*-*-*-20-200-*-*-*-*-*-* -l '5' -i -b -nf 'yellow' -sb 'blue' -nb 'black'
Last edited by jv2112 (2013-03-07 10:23:24)
Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -
Offline
Yes, I know, thanks.
slmenu is a console app that defaults to where the cursor is, but can be configured to run at top or bottom. Thus the script can be run under X or in the console (though I've not yet tested the latter, so caveats applied). I just think that if everything's happening in a particular terminal, then having the menu also in that terminal is "nice".
As an additionaly bit of info. the list isn't cleared by slmenu if you escape out (which is a non-zero exit), so you may need to add a "clear" command on error.
Last edited by skanky (2013-03-07 10:37:40)
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
A quick hack to present power options (suspend, poweroff, etc). I'm sure this can be done in a prettier way. I suck at shell scripting.
#!/bin/sh
FONT="DejaVu Sans Mono:pixelsize=11:antialias=true:rgba=rgb"
BGCOL="#3f3f3f"
FGCOL="#dcdccc"
SELBGCOL="#5f7f5f"
SELFGCOL="#dcdccc"
COMMANDS="
suspend\n
poweroff\n
reboot\n
hibernate\n
hybrid-sleep\n
halt\n
lock\n
"
command=$(echo -e $COMMANDS | \
dmenu -p "Power:" -fn "$FONT" -nb $BGCOL -nf $FGCOL -sb $SELBGCOL -sf $SELFGCOL)
[ "$command" = "" ] && exit 1
systemctl $command && exit 0
Offline
Not my creation, but I found this one liner somewhere within the depths of the internet and played around with it for a while. It's a window switcher for dmenu;
wmctrl -l | cut -d' ' -f 1,5- | dmenu -f -i -b -p "Switch to" -nb black -nf white -sf white -fn Ubuntu-8 | cut -d' ' -f 1 | xargs wmctrl -iR
If you're using awesome window manager, you might want to add ...
client.add_signal("focus", function(c) c:raise() end)
... under the awful.util.spawn function for your shortcut or it doesn't work for some reason, still using awesome 3.4, I think in 3.5 it's connect_signal instead of add_signal.
Offline
On the suckless mailing list this problem was solved in a VERY nice way!
This script depends on lsw, which is also a suckless project and available in the AUR.
Thanks for that. Here's a link back to the original source. Also note, it doesn't depend on lsw (although an alternative mentioned earlier in the thread did).
I simplified it a little and added it to dmenu-tools as dmenu_raise, although later re-wrote it using wmctrl and added an Xmonad RunOrRaise equivalent: (more accurately named) raise_or_run.
Offline
Army wrote:Slowly but surely it's getting hard to find a not already used shortcut for all those fine dmenu tools!
You may have to make a dmenu tool to list and select which dmenu tool you wish to use.
I do the very same in dmenu_menu
Offline
Here's a python script I wrote to generate an alternate menu on i3, based on dmenu. I was looking for a small project to keep me busy and missed having a categorized application menu on i3 (I use the default dmenu launcher which just lists every executable in my PATH).
So the script generates a sqlite3 database at ~/.pymenu.db which contains all programs with a *.desktop file in /usr/share/applications and keeps track of their name, category(ies) and path. The script then handles the generation of the main menu and submenus and launches dmenu with the appropriate input/options.
I still haven't tested it extensively but I'm quite happy with it. Also it uses dmenu2 for the 'width' option.
Here's how it looks (nothing fancy, and this is a brand new install on virtualbox):
Here's the script: http://pastebin.com/XxkeSs0e
Hope you like it (I do)!
Last edited by miek (2013-03-21 01:29:19)
Offline
Bug fixed (v1.2).
[Edit] Now v1.4, I've corrected 1~2 bugs which prevented some applications from being categorized correctly and added an option which by defaut limits the applications to the main applications defined by the menu entry specification (for *.desktop files). Much cleaner once you start installing a few applications (as mentioned I've done this script on a new VM on virtualbox). I don't want to spam the forum so please tell me or PM me if anyone's interested in the latest version of the script (it's not on Github).
Last edited by miek (2013-03-21 19:30:41)
Offline
dmenu-when
I quickly hacked a script for the cli calendar application when, because I wanted a replacement for gcalcli.
The code isn't the nicest, a lot of repetitions etc, but it works.
#!/bin/bash
if [ -f $HOME/.dmenurc ]
then
source $HOME/.dmenurc
else
DMENU='dmenu -i'
fi
TERMINAL=st
if [ -e ~/.when/preferences ]
then
calendar="$(head -n 1 ~/.when/preferences | awk '{print $3}' )"
else
$TERMINAL -e when
exit
fi
options="--noheader --wrap=0 --noampm" # the first two are important, please don't remove them
choice=$(echo -e "show\nadd\nspecial\nedit" | $DMENU -p 'choose an action:')
case $choice in
show)
wmy=$(echo -e "week\nmonth\nyear" | $DMENU -p 'show events of coming')
case $wmy in
week)
when $options w | $DMENU -p 'events of coming week:'
;;
month)
when $options m | $DMENU -p 'events of coming month:'
;;
year)
when $options y | $DMENU -p 'events of coming year'
;;
esac
;;
add)
year=$(date +%Y | $DMENU -p 'year:')
if [ ! "$year" ];then exit;fi
month=$(echo -e "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec" | $DMENU -p 'month:')
if [ ! "$month" ];then exit;fi
case $month in
Jan|Mar|May|Jul|Aug|Oct|Dec)
day=$(echo {01..31} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
Feb)
if [ $[$year % 400] -eq "0" ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
elif [ $[$year % 4] -eq 0 ]
then
if [ $[$year % 100] -ne 0 ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
else
day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
else day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
;;
Apr|Jun|Sep|Nov)
day=$(echo {01..30} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
esac
if [ ! "$day" ];then exit;fi
time=$(date +%H:%M | $DMENU -p 'time (can be left blank):')
event=$(xsel -o | $DMENU -p 'event:')
if [ ! "$event" ];then exit;fi
echo "$year $month $day , $time $event" >> $calendar
;;
special)
specialcase=$(echo -e "birthday\nyearly\nmonthly\nweekly\ncustom" | $DMENU -p 'choose a special case:')
case $specialcase in
birthday)
who="$(xsel -o | $DMENU -p 'who is the birthday kid?')"
if [ ! "$who" ];then exit;fi
year=$(xsel -o | $DMENU -p "what year was $who born?")
if [ ! "$year" ];then exit;fi
month=$(echo -e "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec" | $DMENU -p "what month was $who born?")
if [ ! "$month" ];then exit;fi
case $month in
Jan|Mar|May|Jul|Aug|Oct|Dec)
day=$(echo {01..31} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
Feb)
if [ $[$year % 400] -eq "0" ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
elif [ $[$year % 4] -eq 0 ]
then
if [ $[$year % 100] -ne 0 ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
else
day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
else day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
;;
Apr|Jun|Sep|Nov)
day=$(echo {01..30} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
esac
echo "${year}* $month $day , BIRTHDAY: ${who}s \a. birthday (\y)" >> $calendar
;;
yearly)
month=$(echo -e "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec" | $DMENU -p 'month:')
if [ ! "$month" ];then exit;fi
case $month in
Jan|Mar|May|Jul|Aug|Oct|Dec)
day=$(echo {01..31} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
Feb)
if [ $[$year % 400] -eq "0" ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
elif [ $[$year % 4] -eq 0 ]
then
if [ $[$year % 100] -ne 0 ]
then
day=$(echo {01..29} | sed 's/\ /\n/g' | $DMENU -p 'month:')
else
day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
else day=$(echo {01..28} | sed 's/\ /\n/g' | $DMENU -p 'month:')
fi
;;
Apr|Jun|Sep|Nov)
day=$(echo {01..30} | sed 's/\ /\n/g' | $DMENU -p 'month:')
;;
esac
if [ ! "$day" ];then exit;fi
time=$(date +%H:%M | $DMENU -p 'time (can be left blank):')
event=$(xsel -o | $DMENU -p 'event:')
if [ ! "$event" ];then exit;fi
echo "m=$month & d=$day , $time $event" >> $calendar
;;
monthly)
day=$(echo {01..31} | sed 's/\ /\n/g' | $DMENU -p 'day of the month:')
if [ ! "$day" ];then exit;fi
time=$(date +%H:%M | $DMENU -p 'time (can be left blank):')
event=$(xsel -o | $DMENU -p 'event:')
if [ ! "$event" ];then exit;fi
echo "d=$day , $time $event" >> $calendar
;;
weekly)
day=$(echo -e "Mon\nTue\nWed\nThu\nFri\nSat\nSun" | $DMENU -p 'weekday:')
if [ ! "$day" ];then exit;fi
time=$(date +%H:%M | $DMENU -p 'time (can be left blank):')
event=$(xsel -o | $DMENU -p 'event:')
if [ ! "$event" ];then exit;fi
echo "w=$day , $time $event" >> $calendar
;;
custom)
fancycustominput="$(xsel -o | $DMENU -p 'fancy custom input:')"
if [ ! "$fancycustominput" ];then exit;fi
echo "$fancycustominput" >> $calendar
esac
;;
edit)
$TERMINAL -e when e
esac
or http://codepad.org/2FPAoKRr
(edited, fixed a little mistake)
Please at least adjust the TERMINAL variable. I use st, so that's my default.
I also show the events in conky, a simple
${scroll 15 5 ${execi 300 when --noheader --wrap=0 --noampm w}}
is enough (I use a one-liner conky, so I need to scroll such content).
And I show them on every boot, so when I turn on the computer in the moring, I know what's gonna happen in the coming week. Just put
notify-send "$(when --noheader --wrap=0 --noampm w)"
in your ~/.xinitrc to get this.
Last edited by Army (2013-03-29 14:26:08)
Offline
youtube_dmenu
I wrote this script for myself to watch youtube channels but maybe somebody can use it.
more info in code.
#!/bin/bash
if [ -f $HOME/.dmenurc ]; then
. $HOME/.dmenurc
else
DMENU='dmenu -i'
fi
# number of entries to display
MAX=5
# simple www get from perl libwww can be replaced by curl wget or whatever
GETBIN=GET
# html parser I use query for nodejs - 'npm install query'
# can be replaced with rquery - 'gem install ruby-query' - but this gives some trouble with new lines
# or script uses pyquery
QUERYBIN=query
# command to deal with youtube video url
VIDEOBIN="ytcmd -e @mplayer"
# can be run with channel name
CHANNEL=$1
# and number of entries to retrive
NUM=${2:-$MAX}
# or channel is taken from dmenu feed with file
if [[ -z $CHANNEL ]]
then
# DATAFILE can hold Your entries
# added automatically, delete it manually
# number added after channel name is used as number of entries
DATADIR="${XDG_CONFIG_HOME:-${HOME}/.config}/dmenu"
DATAFILE="${DATADIR}/youtube_channels_list"
if [[ ! -e "$DATADIR" ]]
then
mkdir -p "$DATADIR"
fi
X=($(cat $DATAFILE | $DMENU -l 5))
if [ $? -ne 0 ]; then
exit
fi
if ! grep -qx "$X" "${DATAFILE}"
then
echo "$X" >> "${DATAFILE}"
fi
CHANNEL=${X[0]}
NUM=${X[1]:-$MAX}
fi
rss=`$GETBIN "http://gdata.youtube.com/feeds/base/videos?max-results=$NUM&orderby=published&author=$CHANNEL"`
IFS=$'\n'
entries=($(echo $rss | $QUERYBIN entry))
unset IFS
menu=""
declare -A tab
for v in "${entries[@]}"
do
title=$(echo $v | $QUERYBIN title text)
menu="${menu}${title}\n"
tab[$title]=$(echo $v | $QUERYBIN link attr href )
done
choice=$(echo -e $menu | $DMENU -l $NUM)
if [ $? -ne 0 ]; then
exit
fi
$VIDEOBIN ${tab[$choice]}
Enjoy or blame!
Marcin Babnis
EDIT. Changed location of channels file and short early exit code (removed ifs)
Last edited by mbab (2013-04-13 11:43:34)
Offline
#!/bin/sh
find ${1} -iname *.desktop | xargs egrep -h "^Exec=" $i \
| sed 's/^Exec=//' | sed 's/\s%[fFuU]//' \
| dmenu -i | sh -
invoked as 'deskmenu.sh /path/to/desktop/files'.
It's a little ugly but it works. Took a few tries to get one that ran fast enough; this one should be instant, but if anyone can think of a good way to eliminate the extra sh invocation, that'd be cool.
Offline
Merging with the dmenu hacking thread...
Offline
It's a little ugly but it works. Took a few tries to get one that ran fast enough; this one should be instant, but if anyone can think of a good way to eliminate the extra sh invocation, that'd be cool.
Thank you, I like that and it's pretty fast too.
Offline
#!/bin/sh find ${1} -iname *.desktop | xargs egrep -h "^Exec=" $i \ | sed 's/^Exec=//' | sed 's/\s%[fFuU]//' \ | dmenu -i | sh -
invoked as 'deskmenu.sh /path/to/desktop/files'.
It's a little ugly but it works. Took a few tries to get one that ran fast enough; this one should be instant, but if anyone can think of a good way to eliminate the extra sh invocation, that'd be cool.
Don't know about the sh, but you can remove one sed call as you can have multiple commands in a script. You can have new lines inside the quotes, or use a semi colon on one line.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
And (e)grep + sed = awk. So one awk could take the place of the egrep and the two seds.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I was wondering how it would be possible to show some information as soon as opening dmenu, without entering any text. Like battery state, date, cpu, mem etc. I think that would be nice.
Offline