1

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?

simohamed
  • 61
  • 1
  • 4

2 Answers2

1

notify-send will not work with piping

However, you can try: sudo pip install notify-pipe

Which accepts piping

See here: https://github.com/ron7/notify-pipe

And you can pipe stderr to stdout and send it to notify-pipe

command 2>&1|notify-pipe
Ron
  • 5,900
  • 2
  • 20
  • 30
0

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.

simohamed
  • 61
  • 1
  • 4