#!/bin/sh cmd=$(dmenu_path | ~/bin/dmenu "$@") if [ -n "$cmd" ]; then # NOTE: only tested with zsh and sh, and has issues with expansion; zsh # SH_WORD_SPLIT is unset by default, `=' flag is required to expand it. # XXX: probably has issues with single quotes # XXX: does not perform any(!) shell expansion echo "alias sudo='sudo -Ak' cmd='$(echo "$cmd" | sed "s/'/'\\\\''/g")'" ' if [ -n "$ZSH_VERSION" ]; then out="$(${=cmd} 2>&1)" else out="$($cmd 2>&1)" fi code=$? out="$(echo "$out" | tail -n 3)" notify-send -t 10000 -u $([ $code != 0 ] && echo normal || echo low) -a ' "'$(basename $0)'" ' "${cmd}$([ $code != 0 ] && echo \: $code)" "$out"' | SUDO_ASKPASS=~/bin/dpass ${SHELL:-"/bin/sh"} fi