jnoortheen / xontrib-cmd-durations

Show long running commands durations in prompt with option to send notification when terminal is not focused.
MIT License
16 stars 4 forks source link

Add custom tool to send notification #9

Open anki-code opened 2 years ago

anki-code commented 2 years ago

Hi! Thanks for this xontrib!

It will be cool to have an ability to send notification using external tool.

For example run wsl-notify-send as

sp.check_output(['/tmp/wsl-notify-send.exe', '--appId', 'Title!', '-c', 'Subtitle!', 'Message!']).decode().strip()

instead of this:

https://github.com/jnoortheen/xontrib-cmd-durations/blob/383b6ad31944b285bba909e9d8e2c492e43f627d/xontrib/cmd_done.py#L128-L133

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

jnoortheen commented 2 years ago

is there any advantage using that? using this library is convenient , that we don't have haggle on each OS

anki-code commented 2 years ago

I mean something like this:

CUSTOM_NOTIFIER = xsh.env.get("XONTRIB_CD_CUSTOM_NOTIFIER", None)

if CUSTOM_NOTIFIER:
    sp.check_output(CUSTOM_NOTIFIER).decode().strip()
else:
    from notifypy import Notify 
    # ...  

and:

$XONTRIB_CD_CUSTOM_NOTIFIER = ['/tmp/wsl-notify-send.exe', '--appId', '{title}', '-c', '{subtitle}', '{message}']
xontrib load cmd_done
jnoortheen commented 2 years ago

could you answer why this is needed?

anki-code commented 2 years ago

To have a way to support WSL until notifypy hasn't this feature (https://github.com/ms7m/notify-py/issues/45).

jnoortheen commented 2 years ago

Thanks now I understand. PRs welcome to add such functionality.