config/.local/bin/dmenuprompt

22 lines
453 B
Bash
Executable File

#!/bin/bash
# A dmenu binary prompt script.
# Gives a dmenu prompt labelled with $1 to perform command $2.
# To invert the options, simply provide a thrid parameter $3.
# For example:
# `./prompt "Do you want to shutdown?" "shutdown now"`
# Taken shamelessly from Luke Smith
if [[ -n "$3" ]]
then
choice=$(echo -e "Yes\nNo" | dmenu -i -p "$1")
else
choice=$(echo -e "No\nYes" | dmenu -i -p "$1")
fi
if [[ "$choice" = "Yes" ]]
then
$2
fi