mirror of
https://github.com/turtlebasket/env.git
synced 2026-03-07 21:14:27 -08:00
misc
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# ntfy-bell - run a command, forwarding OSC 9 notifications and BEL to ntfy
|
||||
# ntfy-bell - run a command, forwarding OSC 9 notifications to ntfy
|
||||
#
|
||||
# Usage:
|
||||
# ntfy-bell <command> [args...]
|
||||
@@ -102,9 +102,9 @@ def _copy_winsize(src_fd: int, dst_fd: int) -> None:
|
||||
|
||||
|
||||
def main() -> int:
|
||||
topic = os.environ.get("BELL2NTFY_TOPIC")
|
||||
topic = os.environ.get("NTFY_ME_TOPIC")
|
||||
if not topic:
|
||||
print("Error: environment variable BELL2NTFY_TOPIC not set", file=sys.stderr)
|
||||
print("Error: environment variable NTFY_ME_TOPIC not set", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
@@ -155,7 +155,6 @@ def main() -> int:
|
||||
signal.signal(signal.SIGWINCH, _on_winch)
|
||||
|
||||
osc_last_sent = 0.0
|
||||
bel_last_sent = 0.0
|
||||
cooldown_s = 1.5
|
||||
parse_buf = bytearray()
|
||||
stdin_eof_sent = False
|
||||
@@ -224,19 +223,6 @@ def main() -> int:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if bytes([BEL]) in data and parse_buf.find(OSC9_PREFIX) == -1:
|
||||
now = time.time()
|
||||
if now - bel_last_sent >= cooldown_s:
|
||||
bel_last_sent = now
|
||||
try:
|
||||
notify_ntfy(
|
||||
topic=topic,
|
||||
title="Terminal bell",
|
||||
message=f"BEL from: {' '.join(cmd)}",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
finally:
|
||||
if stdin_fd is not None and stdin_is_tty and old_tty_attrs is not None:
|
||||
try:
|
||||
Reference in New Issue
Block a user