You are not logged in.

#326 2018-11-08 17:12:47

From: Netherlands
Registered: 2012-06-20
Posts: 773

Re: Dmenu Hacking Thread

Unstack wrote:

dmenu hack for querying Google. [GIF Preview (>1mb)]

Tell me what you think.

Hey Unstack, I like your tool, especially the 'back & cancel' button.
I'm a nitwit in python but I'm going to try to use that part for other dmenu script, like osx-finder or git-jumper.

As for what your tool actually does, I miss the address together with the search, so you get something like: search enter back enter back enter back etc...
If the URL was visible in the search it would be a winner , for me;)

A little tool I made, alarm based on 'sleep':

set -xe
if [ -f "$XDG_CONFIG_HOME"/dmenu/dmenurc ]; then
  . "$XDG_CONFIG_HOME"/dmenu/dmenurc

alarm_clock() {
  reason=$(echo '' | $demcmd -p "ReasonForAlarm?" -w '375')
  if [ -z "$reason" ]; then  reason=Alarm; fi
  timer=$(echo '' | $demcmd -p "TimeToAlarm:" -w '375')
  (sleep "$timer" | $dmalarm -p "$reason" -w '540' -x '675' -y '500')

exit 0

+ teh config lines:

demcmd='dmenu -i -fn Monospace-14:normal -nb #222222 -nf #ff7f50 -sb #222222 -sf #f5deb3'
dmalarm='dmenu -fn Monospace-40:normal -sb #222222 -sf #dd0000'

edit: add e to dmcmd, which is also in my list...
edit2: dmenu can run multiple instances of the same script
I added  a reason for alarm(default=Alarm), like movie start or taxi, etc
Right now it shows 16 characters increase last width to change that.

Last edited by qinohe (2018-11-20 16:11:30)


#327 2018-11-13 11:59:46

Registered: 2017-04-21
Posts: 5

Re: Dmenu Hacking Thread

I often open a new terminal window and want to quickly jump to the working directory that I have in another window. Here is a fragment of my .bashrc for doing that:

choose_from_cwds() {
	for PROCID in $(pgrep '^bash$'); do
		readlink -e /proc/$PROCID/cwd
	done \
	| sort -u \
	| dmenu -l 5
alias chd='cd $(choose_from_cwds)'


#328 2018-11-16 16:13:46

Registered: 2017-04-21
Posts: 5

Re: Dmenu Hacking Thread

Here's another one for browsing git commits and selecting their hash values. I use it for example to select points for a diff.

choose_git_commit() {
    git log --date='format:%Y-%m-%d %H:%M' \
        | paste -sd'\t' \
        | sed 's/commit /\n/g; s/\(Author\|Date\)://g; s/<[^>]*>//g;
               s/ \+/ /g; s/\t\+/  /g' \
        | cut -c -150 \
        | dmenu -i -l 10 \
        | cut -d' ' -f 1
alias Gdd='git diff $(choose_git_commit) $(choose_git_commit)'

There is one problem with this script: it is very slow on my elderly laptop (ThinkPad X200). However, on a newer desktop PC, it works smoothly. Apparently, dmenu is not very well suited for long strings. Does anyone know how to improve it?

Solved the performance issue. The problem was not long strings, but tab characters. I changed the script accordingly, now it runs smoothly.

Last edited by msum (2018-11-16 16:23:11)


Board footer

Powered by FluxBB