I run programs using keybindings, which themselves could call dmenu and do things in the background. I would love to pipe stderr
to notify-send
and get a notification if something failed.
These programs are not called from a terminal emulator, mostly sxhkd
coupled with an xdg-open
alternative jaro
.
Take this example, for instance:
$ ls /root
"/root": Permission denied (os error 13)
$ ls /root 2> /dev/null
$
If I had an sxhkd entry
super + Return
ls /root
How can I have it output stderr to a notification?
Create a script notify-pipe
:
#!/usr/bin/env sh
read notification
notify-send "Command Failed" "$notification" "$@"
And pipe stderr
to stdout
:
$ ls /root 2>&1| notify-pipe
Possible enhancement: bash get command that was used before pipe symbol to get the command in the notification summary.
Thanks for the help, Ron.