Skip to content

Linux + iPhone Continuity / iMessage / SMS

packaging

Zack Barteld4ad81f23cfa
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50771de..c69b13c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.19)
-project(tether CXX C)
+project(tether VERSION 0.1.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET wayland-client)
pkg_check_modules(AVAHI REQUIRED IMPORTED_TARGET avahi-client)
@@ -48,7 +49,6 @@ if(NOT TARGET uninstall)
endif()
# Browser Extension Host manifest generation
-include(GNUInstallDirs)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/extension/host/com.tether.extension.chrome.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.chrome.json"
@@ -60,22 +60,88 @@ configure_file(
@ONLY
)
-install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/extension/host/tether-native-host"
+# Wrapper script for native host
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/extension/host/tether-native-host.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/tether-native-host"
+ @ONLY
+)
+
+install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/tether-native-host"
DESTINATION ${CMAKE_INSTALL_BINDIR})
# native messaging manifests
+set(CHROME_MESSAGING_DIR "/etc/chromium/native-messaging-hosts" CACHE PATH "Chrome native messaging hosts directory")
+set(GOOGLE_CHROME_MESSAGING_DIR "/etc/opt/chrome/native-messaging-hosts" CACHE PATH "Google Chrome native messaging hosts directory")
+set(MOZILLA_MESSAGING_DIR "${CMAKE_INSTALL_LIBDIR}/mozilla/native-messaging-hosts" CACHE PATH "Mozilla native messaging hosts directory")
+set(THUNDERBIRD_MESSAGING_DIR "${CMAKE_INSTALL_LIBDIR}/thunderbird/native-messaging-hosts" CACHE PATH "Thunderbird native messaging hosts directory")
+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.chrome.json"
- DESTINATION "/etc/chromium/native-messaging-hosts"
+ DESTINATION "${CHROME_MESSAGING_DIR}"
RENAME "com.tether.extension.json")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.chrome.json"
- DESTINATION "/etc/opt/chrome/native-messaging-hosts"
+ DESTINATION "${GOOGLE_CHROME_MESSAGING_DIR}"
RENAME "com.tether.extension.json")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.mozilla.json"
- DESTINATION "/usr/lib/mozilla/native-messaging-hosts"
+ DESTINATION "${MOZILLA_MESSAGING_DIR}"
RENAME "com.tether.extension.json")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.mozilla.json"
- DESTINATION "/usr/lib/thunderbird/native-messaging-hosts"
+ DESTINATION "${THUNDERBIRD_MESSAGING_DIR}"
RENAME "com.tether.extension.json")
+
+# install man pages
+install(FILES docs/man/man1/tether.1 docs/man/man1/tether-gtk.1
+ DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(FILES docs/man/man8/tetherd.8
+ DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)
+
+# Extension Building only if npm is available
+option(TETHER_BUILD_EXTENSIONS "Build browser and mail extensions automatically" ON)
+find_program(NPM_EXECUTABLE npm)
+
+if(TETHER_BUILD_EXTENSIONS AND NPM_EXECUTABLE)
+ set(EXTENSION_BUILD_DIR "${CMAKE_BINARY_DIR}/extension_bundles")
+
+ add_custom_target(extensions ALL
+ COMMAND ${CMAKE_COMMAND} -E env BUILD_DIR=${EXTENSION_BUILD_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/extension/build.sh
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Building browser and mail extensions"
+ VERBATIM
+ )
+
+ # Install extensions into the package
+ install(DIRECTORY "${EXTENSION_BUILD_DIR}/"
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/tether/extensions"
+ OPTIONAL
+ FILES_MATCHING PATTERN "*.zip" PATTERN "*.xpi")
+endif()
+
+# CPack Configuration
+set(CPACK_SET_DESTDIR ON)
+set(CPACK_PACKAGE_NAME "tether")
+set(CPACK_PACKAGE_VENDOR "zackb")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Wayland-native local file transfer and clipboard sync tool over mDNS")
+set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
+set(CPACK_PACKAGE_CONTACT "[email protected]")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "tether")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
+
+# DEB
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk-3-0, libnotify4, openssl, libwayland-client0, libavahi-client3")
+set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
+set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/zackb/tether")
+
+# RPM
+set(CPACK_RPM_PACKAGE_REQUIRES "gtk3, libnotify, openssl, wayland-client, avahi-client")
+set(CPACK_RPM_PACKAGE_LICENSE "MIT")
+set(CPACK_RPM_PACKAGE_RELOCATABLE OFF)
+
+# Generators
+set(CPACK_GENERATOR "TGZ;DEB;RPM")
+
+include(CPack)
diff --git a/Makefile b/Makefile
index 7dc9fc1..66a6958 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,12 @@ test: debug
install: release
cmake --install build/release
+package: release
+ cd build/release && cpack
+
+arch-package:
+ makepkg -sf
+
uninstall:
cmake --build build/release --target uninstall
diff --git a/docs/man/man1/tether-gtk.1 b/docs/man/man1/tether-gtk.1
new file mode 100644
index 0000000..a4c8a11
--- /dev/null
+++ b/docs/man/man1/tether-gtk.1
@@ -0,0 +1,23 @@
+.TH TETHER-GTK 1 "May 2026" "Tether 0.1.0" "User Commands"
+.SH NAME
+tether-gtk \- Graphical interface for Tether
+.SH SYNOPSIS
+.B tether-gtk
+.SH DESCRIPTION
+.B tether-gtk
+is a GTK-based graphical application for managing Tether connections and devices.
+It provides a user-friendly interface to:
+.IP \(bu 2
+Monitor the status of the connection to the Tether daemon.
+.IP \(bu 2
+Manage paired devices and accept new pairing requests.
+.IP \(bu 2
+Send and receive files.
+.IP \(bu 2
+View clipboard sync history and status.
+.PP
+If the \fBtetherd\fR(8) daemon is not running, \fBtether-gtk\fR will attempt to
+start it automatically.
+.SH SEE ALSO
+.BR tether (1),
+.BR tetherd (8)
diff --git a/docs/man/man1/tether.1 b/docs/man/man1/tether.1
new file mode 100644
index 0000000..219680d
--- /dev/null
+++ b/docs/man/man1/tether.1
@@ -0,0 +1,67 @@
+.TH TETHER 1 "May 2026" "Tether 0.1.0" "User Commands"
+.SH NAME
+tether \- Wayland companion CLI for iPhone integration
+.SH SYNOPSIS
+.B tether
+[\fIOPTIONS\fR]
+.SH DESCRIPTION
+.B tether
+is a command-line interface for communicating with the Tether daemon (\fBtetherd\fR).
+It allows for clipboard synchronization, file transfers, and device management between
+a Linux Wayland desktop and an iOS device.
+.SH OPTIONS
+.TP
+\fB\-h, \-\-help\fR
+Show help message and exit.
+.TP
+\fB\-g, \-\-get-clipboard\fR
+Retrieve the current Wayland clipboard text from the daemon.
+.TP
+\fB\-s, \-\-set-clipboard\fR [\fISTRING\fR]
+Copy the provided string (or stdin if omitted) to the local Wayland clipboard.
+.TP
+\fB\-f, \-\-send-file\fR \fIFILE\fR
+Send a file to the currently connected device.
+.TP
+\fB\-n, \-\-native-host\fR
+Start the browser Native Messaging Host proxy loop (used by browser extensions).
+.TP
+\fB\-d, \-\-discover\fR
+Scan the local network for tetherd instances via mDNS.
+.TP
+\fB\-\-host\fR \fIIP\fR
+Connect over TCP to the daemon at the specified IP address instead of using the local UNIX socket.
+.TP
+\fB\-\-port\fR \fINUM\fR
+Connect over TCP port (default: 5134).
+.TP
+\fB\-\-timeout\fR \fIMS\fR
+Discovery scan duration in milliseconds (default: 3000).
+.TP
+\fB\-\-list-devices\fR
+List all paired connection devices and their fingerprints.
+.TP
+\fB\-\-accept\fR \fIFINGERPRINT\fR
+Accept a pending pairing request locally for the specified device fingerprint.
+.TP
+\fB\-\-pair\fR
+Send a pairing request over TCP to the daemon.
+.SH EXAMPLES
+Retrieve clipboard:
+.IP
+tether \-g
+.PP
+Copy text to clipboard:
+.IP
+echo "Hello from Linux" | tether \-s
+.PP
+Discover other Tether instances:
+.IP
+tether \-\-discover
+.PP
+Send a file:
+.IP
+tether \-f document.pdf
+.SH SEE ALSO
+.BR tetherd (8),
+.BR tether-gtk (1)
diff --git a/docs/man/man8/tetherd.8 b/docs/man/man8/tetherd.8
new file mode 100644
index 0000000..ba6fe99
--- /dev/null
+++ b/docs/man/man8/tetherd.8
@@ -0,0 +1,28 @@
+.TH TETHERD 8 "May 2026" "Tether 0.1.0" "System Administration"
+.SH NAME
+tetherd \- Tether background daemon for iOS/Wayland integration
+.SH SYNOPSIS
+.B tetherd
+.SH DESCRIPTION
+.B tetherd
+ is a background daemon that manages the connection between a Linux Wayland
+compositor and an iOS device running the Tether app. It handles clipboard
+synchronization, file transfers, and secure device pairing using mTLS.
+
+The daemon advertises its presence on the local network using mDNS (Bonjour)
+and listens for incoming connections on TCP port 5134 by default. It also
+provides a UNIX domain socket at \fB$XDG_RUNTIME_DIR/tether/tetherd.sock\fR
+for local communication with the \fBtether\fR(1) CLI and \fBtether-gtk\fR(1) GUI.
+.SH FILES
+.TP
+\fB$XDG_RUNTIME_DIR/tether/tetherd.sock\fR
+The UNIX domain socket used for local communication.
+.TP
+\fB$XDG_RUNTIME_DIR/tether/tetherd.lock\fR
+Advisory lock file to ensure only one instance of the daemon is running.
+.TP
+\fB$XDG_CONFIG_HOME/tether/certs/\fR
+Directory containing the mTLS certificates and keys.
+.SH SEE ALSO
+.BR tether (1),
+.BR tether-gtk (1)
diff --git a/extension/build.sh b/extension/build.sh
index 4b98ccd..6117df2 100755
--- a/extension/build.sh
+++ b/extension/build.sh
@@ -3,7 +3,8 @@
set -e
echo "Building Tether Extensions..."
-BUILD_DIR="build/extension"
+# Allow overriding build directory from environment
+BUILD_DIR="${BUILD_DIR:-build/extension}"
BROWSER_DIR="$BUILD_DIR/browser"
MAIL_DIR="$BUILD_DIR/mail"
CHROME_DIR="$BUILD_DIR/chromium"
diff --git a/extension/host/tether-native-host.in b/extension/host/tether-native-host.in
new file mode 100644
index 0000000..622dffd
--- /dev/null
+++ b/extension/host/tether-native-host.in
@@ -0,0 +1,5 @@
+#!/bin/bash
+# Wrapper script to run tether in native messaging proxy mode
+# The browser will execute this script via the com.tether.extension.json manifest.
+
+exec "@CMAKE_INSTALL_FULL_BINDIR@/tether" --native-host 2>> /tmp/tether-native.log