Hi, and thanks for CCNotify — the click-to-jump-back-to-VS-Code feature is genuinely nice.
I ran into one portability issue I wanted to flag. In send_notification
(ccnotify.py, line 291) the VS Code CLI path is hardcoded:
if cwd:
cmd.extend(["-execute", f'/usr/local/bin/code "{cwd}"'])
/usr/local/bin is the Intel-Homebrew prefix. On Apple Silicon Macs,
Homebrew lives under /opt/homebrew, so the code shim is at
/opt/homebrew/bin/code. Because the -execute payload only runs when
the notification is clicked (and via terminal-notifier, not the Python
process), the failure is silent: the notification still appears, but
clicking it does nothing and nothing is logged. Since the README lists
click-to-open as a headline feature, it's a confusing experience on
what is now the default Mac hardware.
Proposed fix: resolve the binary on PATH with shutil.which("code") and
degrade gracefully (still notify, just skip the -execute action) when it
isn't found:
if cwd:
code_bin = shutil.which("code")
if code_bin:
cmd.extend(["-execute", f'{code_bin} "{cwd}"'])
else:
logging.warning(
"VS Code CLI ('code') not found on PATH; "
"notification will not be click-to-open."
)
(plus import shutil at the top). This covers Intel, Apple Silicon, and
any custom PATH location, with no change for existing users.
One small adjacent note, take it or leave it: cwd is interpolated into
the -execute string with just double-quote wrapping, so a path containing
a " would break the quoting. In practice cwd is a trusted local path so
this is minor, but shlex.quote(cwd) would harden it if you'd like.
Happy to open a PR with the change (and the shlex.quote hardening if you
want it) — just let me know your preference. Thanks again!
Hi, and thanks for CCNotify — the click-to-jump-back-to-VS-Code feature is genuinely nice.
I ran into one portability issue I wanted to flag. In
send_notification(ccnotify.py, line 291) the VS Code CLI path is hardcoded:
/usr/local/binis the Intel-Homebrew prefix. On Apple Silicon Macs,Homebrew lives under
/opt/homebrew, so thecodeshim is at/opt/homebrew/bin/code. Because the-executepayload only runs whenthe notification is clicked (and via terminal-notifier, not the Python
process), the failure is silent: the notification still appears, but
clicking it does nothing and nothing is logged. Since the README lists
click-to-open as a headline feature, it's a confusing experience on
what is now the default Mac hardware.
Proposed fix: resolve the binary on PATH with shutil.which("code") and
degrade gracefully (still notify, just skip the -execute action) when it
isn't found:
(plus
import shutilat the top). This covers Intel, Apple Silicon, andany custom PATH location, with no change for existing users.
One small adjacent note, take it or leave it:
cwdis interpolated intothe -execute string with just double-quote wrapping, so a path containing
a
"would break the quoting. In practice cwd is a trusted local path sothis is minor, but
shlex.quote(cwd)would harden it if you'd like.Happy to open a PR with the change (and the shlex.quote hardening if you
want it) — just let me know your preference. Thanks again!