Skip to content

Commit ebef137

Browse files
committed
feat: Add Linux support documentation
This commit introduces two new files: - LINUX_AUDIO.md: Documents the current state of audio support on Linux. - LINUX_SUPPORT.md: Provides a comprehensive overview of missing features for full Linux support.
1 parent cc9174b commit ebef137

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

LINUX_AUDIO.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Linux Audio Implementation Status
2+
3+
This document outlines the current status of the audio implementation for Linux in this project.
4+
5+
## Current Implementation
6+
7+
The current implementation in `crates/audio/src/speaker/linux.rs` is a **mock implementation**. It does not capture any actual audio from the system. Instead, it generates a stream of silence.
8+
9+
## Microphone Usage Detection
10+
11+
The application uses the `pactl` command-line tool to detect if a microphone is currently in use by any application. This is implemented in `crates/detect/src/mic/linux.rs`.
12+
13+
This indicates that there is some level of interaction with the PulseAudio sound server, but it is limited to monitoring and does not include audio capture.
14+
15+
## Audio Processing Pipeline
16+
17+
The application has a sophisticated audio processing pipeline that is managed by a state machine in `plugins/listener/src/fsm.rs`. The pipeline is as follows:
18+
19+
1. **Audio Input:**
20+
* Microphone audio is captured using the `cpal` crate, which provides a cross-platform API for audio I/O.
21+
* Speaker audio is captured using a platform-specific implementation. **On Linux, this is currently a mock implementation that generates silence.**
22+
23+
2. **Processing:**
24+
* Both the microphone and speaker audio streams are resampled to 16kHz.
25+
* Acoustic Echo Cancellation (AEC) is performed using the `hypr_aec` crate. The speaker audio is used as the reference signal to remove echo from the microphone audio.
26+
* The AEC-processed microphone audio and the speaker audio are mixed together.
27+
* Audio levels (amplitude) are calculated and sent to the frontend for visualization.
28+
29+
3. **Output:**
30+
* The mixed audio is sent to the `owhisper` service for speech-to-text transcription.
31+
* In debug mode, the raw microphone, raw speaker, and mixed audio streams are saved to `.wav` files for debugging purposes.
32+
33+
## Missing Features
34+
35+
The following features are missing for a complete Linux audio implementation:
36+
37+
* **Actual audio capture:** The primary missing feature is the ability to capture system audio. The current implementation only provides a silent stream.
38+
* **PipeWire support:** There is no integration with the PipeWire audio server. A full implementation would require using the PipeWire API to capture audio.
39+
* **PulseAudio support:** There is no integration with the PulseAudio audio server. A full implementation would require using the PulseAudio API to capture audio.
40+
* **ALSA support:** While ALSA is mentioned in the code comments, there is no actual implementation that uses ALSA to capture audio.
41+
42+
## Next Steps
43+
44+
To have a functional audio implementation on Linux, the following steps need to be taken:
45+
46+
1. Decide on the primary audio backend to support. PipeWire is the modern choice, but PulseAudio and ALSA are still relevant for compatibility.
47+
2. Implement audio capture using the chosen audio backend's API.
48+
3. Provide a mechanism to select the audio backend at runtime or compile time.

LINUX_SUPPORT.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Linux Support Status
2+
3+
This document outlines the current status of Linux support in the Hyprnote application, highlighting areas that are missing or incomplete.
4+
5+
## 1. Speaker Audio Capture
6+
7+
**This is the most critical missing feature for full Linux support.**
8+
9+
The current implementation for speaker audio capture on Linux is a mock that only generates silence. The file `crates/audio/src/speaker/linux.rs` needs to be implemented to capture system audio using a native Linux audio backend.
10+
11+
**Recommended solutions:**
12+
13+
* **PipeWire:** The modern and preferred audio server on Linux.
14+
* **PulseAudio:** A widely used and still relevant audio server.
15+
* **ALSA:** The underlying audio API, which can be used for broader compatibility.
16+
17+
## 2. Notifications
18+
19+
The `hypr_notification2` crate, which is responsible for handling desktop notifications, has incomplete support for Linux.
20+
21+
* **Basic Notifications:** Basic notifications may work if the underlying `wezterm` crate has Linux support.
22+
* **Missing Features:**
23+
* **Permission Handling:** The ability to request notification permissions from the user is not implemented for Linux.
24+
* **Settings Integration:** The functionality to open the system's notification settings is not implemented for Linux.
25+
26+
## 3. Desktop Integration
27+
28+
### 3.1. Application Menu
29+
30+
The main application menu is customized for macOS to provide a more native look and feel. This includes adding "About Hyprnote" and "New Note" items to the application menu. This level of integration is missing for Linux.
31+
32+
### 3.2. Window Decorations
33+
34+
The `plugins/windows` crate contains platform-specific code for window decorations on macOS and Windows.
35+
36+
* **macOS:** Uses a title bar with an overlay style and a hidden title.
37+
* **Windows:** Uses borderless windows.
38+
* **Linux:** Lacks specific window decoration configurations, which may result in an inconsistent and less polished user experience. The application will use the default window decorations provided by the user's window manager.
39+
40+
## 4. Build and Packaging
41+
42+
While not explicitly investigated, it's important to ensure that the application can be easily built and packaged for various Linux distributions. This includes:
43+
44+
* **Dependencies:** Ensuring that all required dependencies are available on common Linux distributions.
45+
* **Packaging Formats:** Providing packages in common formats like `.deb` (for Debian/Ubuntu), `.rpm` (for Fedora/CentOS), and `AppImage` (for distribution-agnostic use).
46+
47+
## 5. macOS-Specific Features and Implementations
48+
49+
Several features and implementations in the Hyprnote application are specific to macOS. These features will not work on Linux, and in some cases, the application may not behave as expected.
50+
51+
### 5.1. Apple Calendar Integration
52+
53+
The `tauri-plugin-apple-calendar` is **macOS-specific** and cannot be used on Linux. This is because it relies on macOS-specific technologies to interact with the Calendar and Contacts applications.
54+
55+
The reasons for this include:
56+
57+
* **`osascript`:** The plugin uses `osascript` to execute AppleScript for interacting with the Calendar application.
58+
* **`open x-apple.systempreferences`:** The plugin uses macOS-specific URL schemes to open the System Preferences to the correct privacy settings.
59+
* **`hypr_calendar_apple` crate:** The plugin uses the `hypr_calendar_apple` crate, which is a wrapper around Apple's native frameworks for accessing calendar and contact data.
60+
* **`tccutil`:** The plugin uses the `tccutil` command-line tool to manage calendar and contacts permissions, which is specific to macOS.
61+
62+
### 5.2. AI/ML Acceleration
63+
64+
The application uses Apple's **Metal** and **Core ML** frameworks for hardware-accelerated AI/ML tasks on macOS. This is enabled through the `llm-metal`, `stt-metal`, and `stt-coreml` features. While the application may fall back to CPU-based processing on Linux, it will not have the same level of performance as on Apple hardware.
65+
66+
### 5.3. Autostart
67+
68+
The autostart feature is implemented using `launchd` on macOS. For the application to autostart on Linux, a different implementation is required, such as creating a `.desktop` file in the `~/.config/autostart/` directory.
69+
70+
### 5.4. Microphone and System Audio Permissions
71+
72+
The permission handling for microphone and system audio access is heavily reliant on macOS-specific APIs and command-line tools.
73+
74+
* **`check_microphone_access`:** On Linux, this function is a workaround that tries to open the microphone to see if it's available, which is not a reliable permission check.
75+
* **`request_microphone_access`:** On Linux, this function also tries to open the microphone, which may or may not trigger a system-level permission prompt.
76+
* **`open_microphone_access_settings` and `open_system_audio_access_settings`:** These functions will not work on Linux as they use macOS-specific URLs.
77+
* **`check_system_audio_access`:** This function relies on the `hypr_tcc` crate, which is entirely macOS-specific and always returns `true` on Linux.
78+
79+
### 5.5. TCC (Transparency, Consent, and Control)
80+
81+
The `hypr_tcc` crate, which is used for managing permissions, is entirely macOS-specific and has no functionality on Linux.
82+
83+
### 5.6. Email Integration
84+
85+
The application uses the native macOS email client to send emails. This is implemented in the `crates/email` crate, which uses the `NSSharingService` class. This functionality will be missing on Linux. To provide a similar feature on Linux, a different approach would be needed, such as opening a `mailto:` URL or using a library that can communicate with common Linux email clients.
86+
87+
### 5.7. Application and Browser Detection
88+
89+
The application uses macOS-specific APIs to detect running applications and the frontmost browser window. This is used for features like automatically detecting meetings.
90+
91+
* **`crates/detect/src/app/macos.rs`:** Uses `ns::RunningApp` and `ns::Workspace` to detect running applications.
92+
* **`crates/detect/src/browser/macos.rs`:** Uses `objc2_foundation::NSURL` and `objc2_app_kit::NSWorkspace` to get the URL of the frontmost browser window.
93+
94+
A Linux-specific implementation would be needed to provide similar functionality. This could involve using the `/proc` filesystem or a library like `libprocps`.
95+
96+
## 6. Conclusion
97+
98+
To achieve full Linux support, the following tasks need to be prioritized:
99+
100+
1. **Implement speaker audio capture** in `crates/audio/src/speaker/linux.rs`.
101+
2. **Add full notification support** for Linux in the `hypr_notification2` crate, including permission handling and settings integration.
102+
3. **Improve desktop integration** by customizing the application menu and window decorations for a more native Linux experience.
103+
4. **Ensure robust build and packaging** for various Linux distributions.

0 commit comments

Comments
 (0)