Skip to content

Instantly share code, notes, and snippets.

@yrps
Created June 6, 2017 10:17
Show Gist options
  • Save yrps/9f745c4d8893f9554e34c3eaf4310ec5 to your computer and use it in GitHub Desktop.
Save yrps/9f745c4d8893f9554e34c3eaf4310ec5 to your computer and use it in GitHub Desktop.
Direct dmenu command output to notify-send
#!/bin/sh
cmd="$(dmenu_path |
dmenu -p '$' -l 10 -fn 'Liberation Sans-20:Bold' -nb '#eee' -nf '#008')" ||
exit
if output="$(${SHELL:-"/bin/sh"} -c "$cmd" 2>&1)" ; then
urgency=normal
icon=emblem-default
else
urgency=critical
icon=emblem-important
fi
if [ -z "$output" ]; then
notify-send --icon="$icon" --urgency="$urgency" "$cmd"
else
notify-send --icon="$icon" --urgency="$urgency" "$cmd" "$output"
fi
ret=$?
[ $ret -eq 0 ] || {
echo "Failed to direct '$cmd' output through notify-send."
[ -z "$output" ] || echo "$output"
} >&2
exit $ret
@yrps
Copy link
Author

yrps commented Jun 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment