diff --git a/CMakeLists.txt b/CMakeLists.txt index 669a65b8a..43b695b85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ else() add_compile_definitions(_CRT_SECURE_NO_WARNINGS _GNU_SOURCE) endif() -set(SOURCE_FILES src/utils.c src/pty.c src/protocol.c src/http.c src/server.c) +set(SOURCE_FILES src/utils.c src/pty.c src/protocol.c src/http.c src/server.c src/notify.c) include(FindPackageHandleStandardArgs) @@ -57,8 +57,10 @@ endif() find_package(ZLIB REQUIRED) find_package(Libwebsockets 3.2.0 REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(LIBSYSTEMD IMPORTED_TARGET libsystemd) -set(INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} ${LIBWEBSOCKETS_INCLUDE_DIRS} ${JSON-C_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS}) +set(INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} ${LIBWEBSOCKETS_INCLUDE_DIRS} ${JSON-C_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS} ${LIBSYSTEMD_INCLUDE_DIRS}) if(MSVC) # vcpkg's LIBWEBSOCKETS_LIBRARIES lists both 'websockets' and 'websockets_shared' # but only one target exists per triplet, so resolve the correct one. @@ -68,7 +70,7 @@ if(MSVC) set(LINK_LIBS ${ZLIB_LIBRARIES} websockets ${JSON-C_LIBRARIES} ${LIBUV_LIBRARIES}) endif() else() - set(LINK_LIBS ${ZLIB_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARIES} ${LIBUV_LIBRARIES}) + set(LINK_LIBS ${ZLIB_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARIES} ${LIBUV_LIBRARIES} ${LIBSYSTEMD_LIBRARIES}) endif() set (CMAKE_REQUIRED_INCLUDES ${INCLUDE_DIRS}) diff --git a/README.md b/README.md index d473388c1..cd076b011 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ttyd is a simple command-line tool for sharing terminal over the web. - Run any custom command with options - Basic authentication support and many other custom options - Cross platform: macOS, Linux, FreeBSD/OpenBSD, [OpenWrt](https://openwrt.org), Windows +- Desktop notification bridging on Linux: registers as a D-Bus notification daemon, forwarding desktop notifications to the browser # Installation @@ -75,6 +76,8 @@ OPTIONS: -I, --index Custom index.html path -b, --base-path Expected base path for requests coming from a reverse proxy (eg: /mounted/here, max length: 128) -P, --ping-interval Websocket ping interval(sec) (default: 5) + -f, --srv-buf-size Maximum chunk of file (in bytes) that can be sent at once, a larger value may improve throughput (default: 4096) + -N, --monitor-notifications Monitor desktop notifications via D-Bus and forward to browser -6, --ipv6 Enable IPv6 support -S, --ssl Enable SSL -C, --ssl-cert SSL certificate file path @@ -87,6 +90,20 @@ OPTIONS: Read the example usage on the [wiki](https://github.com/tsl0922/ttyd/wiki/Example-Usage). +## Desktop Notification Bridging + +Pass `-N` (or `--monitor-notifications`) to forward desktop notifications to the browser: + +``` +ttyd -N -W bash +``` + +When enabled, ttyd registers as a D-Bus notification daemon on the session bus (falling back to the system bus on headless servers). Any application that sends notifications via `org.freedesktop.Notifications` will have them forwarded to all connected browser clients as native [Browser Notifications](https://developer.mozilla.org/en-US/docs/Web/API/Notification). + +If a notification daemon is already running (e.g. KDE Plasma, GNOME Shell), ttyd falls back to monitoring with `dbus-monitor`. + +Build requirement: `libsystemd-dev` (for `sd-bus`). + ## Browser Support Modern browsers, See [Browser Support](https://github.com/xtermjs/xterm.js#browser-support). diff --git a/html/src/components/terminal/index.tsx b/html/src/components/terminal/index.tsx index b42bf15df..565912c91 100644 --- a/html/src/components/terminal/index.tsx +++ b/html/src/components/terminal/index.tsx @@ -34,7 +34,12 @@ export class Terminal extends Component { render({ id }: Props, { modal }: State) { return ( -
(this.container = c as HTMLElement)}> +
{ + this.container = c as HTMLElement; + }} + >