The Great Dmenu thread

I saw a similar thread at the Arch BBS. I think we need our own. Share your Dmenu hacks, scripts and black magic here.

2 Likes

Dmenu Screenshot:

#!/bin/bash
#changelog
#v0.3
#added 1. Notifications 2.unique names for each type (for quick launch) 3.better photo editor (pinta) 4.dmenu title
#v0.4
#1.Added variable for notification timeouts. 2. Show link in notification


IMG_PATH=/home/dobbie/Screenshots/
UL=fb
EDIT=pinta
TIME=3 #Seconds notification should remain visible


prog="
---Local screenshots (saved at IMG_PATH)---
1.quick_fullscreen
2.delayed_fullscreen
3.section
4.edit_fullscreen
---Upload to remote service (images will be deleted)---
a.upload_fullscreen
u.upload_delayed_fullscreen
e.edit_upload_fullscreen
s.upload_section
p.edit_upload_section
"

cmd=$(dmenu  -l 20  -nf '#f0f0f0' -nb '#353535' -sf '#f0f0f0' -sb '#4184F3' -p 'Choose Screenshot Type'   <<< "$prog")

cd $IMG_PATH
case ${cmd%% *} in

	1.quick_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png'  && notify-send -u low -t $TIME 'Scrot' 'Fullscreen taken and saved'  ;;
	2.delayed_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png'  && notify-send -u low -t $TIME 'Scrot' 'Fullscreen Screenshot saved'    ;;
	3.section)	scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' && notify-send -u low -t $TIME 'Scrot' 'Screenshot of section saved'    ;;
	4.edit_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f"  && notify-send -u low -t $TIME 'Scrot' 'Screenshot edited and saved' ;;

a.upload_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f" && (xclip -o;echo) | xclip -selection clipboard  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o;echo)"  ;;
    u.upload_delayed_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f"  && (xclip -o;echo) | xclip -selection clipboard  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)"  ;;
	e.edit_upload_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f"  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)"  ;;
s.upload_section)	scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f"  && (xclip -o;echo) | xclip -selection clipboard   &&  notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb - $(xclip -o)";;
    p.edit_upload_section)  scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f"  && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by FB) - $(xclip -o)"  ;;


  	*)		exec "'${cmd}'"  ;;
esac

Found this one at the Arch BBS and adapted it to suit…

3 Likes

Nice, & good idea.

No magic inside, but in case someone needed dmenu on Wayland, this one works very well.

2 Likes

This one is for guys who like or want to edit configurations files in a quicker way. I use geany as the editor so edit it as your choice.

#!/usr/bin/env bash

confDir='/home/archangel/.config/'

dirOptions=$(cd ${confDir} && ls -d */ | cut -d " " -f 1)
dirChoice=$(echo -e "${dirOptions[@]}\nquit" | dmenu -i -p 'Config directories: ')

if [ "$dirChoice" == "quit" ]; then
  echo "dmenu closed."
elif [ "$dirChoice" == ${dirChoice} ]; then
  fileOptions=$(cd ${confDir}${dirChoice} && ls -Ap | cut -d " " -f 1 | grep -v / )
  fileChoice=$(echo -e "${fileOptions[@]}" | dmenu -i -l 20 -p 'Edit this file: ')
  exec geany ${confDir}${dirChoice}${fileChoice}
fi

Same kind of but from a given list of files, and have this format: autostart ~/bin/autostart. This one use vim as editor.

#!/bin/sh
#
# scriptor: Use dmenu to open and edit a file from a given list.

FILES=${1:-"$HOME/.config/dmenu/scripts-list"}

if [ -f $XDG_CONFIG_HOME/dmenu/dmenurc ]; then
  . $XDG_CONFIG_HOME/dmenu/dmenurc
else
  DMENU='dmenu -i -l 20 '
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
3 Likes

Top again @archus .

Nice! Thanks for sharing.

Yours is great Dobbie, with nice multiple functions :+1:

If only I could claim ownership of that one :smiley: