phuhl / notify-send.py

A python-script like libnotify but with improved functionality
Other
96 stars 13 forks source link

Fix exiting-on-action #16

Closed hollowshiroyuki closed 3 years ago

hollowshiroyuki commented 3 years ago

I don't understand how we are supposed to use the actions. When executing notify-send.py "Hello" "World" --action value:Test the notification successfully show up and "value" appears in the terminal when the button is clicked but notify-send.py does not return ? Is it a bug due to some dbus bad configuration ?

Here's the output when clicking on the button once then hitting Ctrl-C to kill it

➜  scripts notify-send.py "Test" "Henlo" --action value:Test 
value
^CTraceback (most recent call last):
  File "/usr/bin/notify-send.py", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/notify_send_py/notify_send_py.py", line 210, in main
    NotifySendPyCLI()
  File "/usr/lib/python3.9/site-packages/notify_send_py/notify_send_py.py", line 192, in __init__
    n_id = NotifySendPy().notify(
  File "/usr/lib/python3.9/site-packages/notify_send_py/notify_send_py.py", line 145, in notify
    self.loop.run()
  File "/usr/lib/python3.9/site-packages/gi/overrides/GLib.py", line 497, in run
    super(MainLoop, self).run()
  File "/usr/lib/python3.9/contextlib.py", line 124, in __exit__
    next(self.gen)
  File "/usr/lib/python3.9/site-packages/gi/_ossighelper.py", line 237, in register_sigint_fallback
    signal.default_int_handler(signal.SIGINT, None)
KeyboardInterrupt
hollowshiroyuki commented 3 years ago

Is there a reason why this line is commented out ? https://github.com/phuhl/notify-send.py/blob/dbd502db3d261eab5ef0429493b3c4908a50189a/notify_send_py/notify_send_py.py#L29

phuhl commented 3 years ago

The reason for this is, because you can click the button mutiple times. Then, the output would occure multiple times. notify-send.py only returns on the close-message, currently.

The line you mentioned is commented out to support the new scrubber-option in https://github.com/phuhl/linux_notification_center where you would repeatedly recieve the value of the scrubber this way.

The idea, how this should work is that you parse stdout in real time so you can immediatly react to button presses/messages while also receiving all of them. I have to admit though, that I didn't get that to work myself, yet.

Anyways, there should probably be an option to enable the current behavior and make the previous behavior the default.