Compare commits

...

12 Commits

Author SHA1 Message Date
Tarasov Aleksandr 9f50809a99 fix(ci): add SDK extensions installation step (#79) 2026-04-25 16:57:01 +03:00
Tarasov Aleksandr 7dda4bc2b1 fix(ci): update Flatter container image to version 25.08 (#77) 2026-04-25 16:46:56 +03:00
Tarasov Aleksandr 1569955e12 chore(ci): Add flatter to host Flatpak repo on GitHub Pages (#76)
* chore(ci): Add flatter to host Flatpak repo on GitHub Pages

- Update release.yml to not upload .flatpak file to releases
- Create flatter.yml to automate building and hosting of Flatpak via GitHub pages using andyholmes/flatter
- Add nightly branch for main pushes and stable branch for releases
- Update README.md with the new Flatpak installation instructions

Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com>

* Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-25 16:38:34 +03:00
Tarasov Aleksandr 9adc6cfbda update dependencies and change version to 1.7.4 (#75)
* deps: cargo update

cc v1.2.60 -> v1.2.61
libc v0.2.185 -> v0.2.186
winnow v1.0.1 -> v1.0.2

* deps: update cargo-sources.json for flatpak

* change version to 1.7.4
2026-04-25 15:58:49 +03:00
Tarasov Aleksandr 76b1d4f345 fix(gui): footer and hotkeys table are no longer clipped because of long filenames (#74)
* fix: truncate file button text in draw function so footer is no clipped

* fix(gui): fix hotkeys table clipping with egui_extras::TableBuilder

fully reworked hotkeys page

* deps: update flatpak cargo-sources.json
2026-04-25 15:44:50 +03:00
Tarasov Aleksandr 10f9937dc3 tests: parse_command set_volume edge cases (#73)
Add unit tests for parse_command in src/utils/commands.rs to ensure
robust handling of set_volume edge cases including missing or
invalid volume and id arguments.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-25 14:37:55 +03:00
Tarasov Aleksandr 498c09eb50 fix(gui): remove unwrap() calls in input handling to prevent potential panics (#72)
Replaced `.chars().next().unwrap()` with `.chars().next().is_some_and(...)` in `chord_from_event` and `parse_chord` functions in `src/gui/input.rs`. This ensures that even if the string is empty, the application will not panic, adhering to the project's safety guidelines and resolving a potential security vulnerability.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-25 14:36:46 +03:00
Tarasov Aleksandr 78e0a133b6 Bump version to 1.7.3 and update dependencies (#70)
* change version to 1.7.3

* deps: cargo update

orbclient -> v0.3.53
wasip2 -> v1.0.3+wasi-0.2.9
wit-bindgen + v0.57.1

* deps: update cargo-sources.json for flatpak
2026-04-21 19:41:19 +03:00
Tarasov Aleksandr 7f8b7194b6 refactor: move PipeWire initialization into a reusable helper function (#69)
Extract duplicated `pipewire::init()`, `MainLoopRc::new()`, and `ContextRc::new()` setup code from `pw_get_global_objects_thread`, `create_virtual_mic`, and `create_link` into a shared `setup_pipewire_context` helper in `src/utils/pipewire.rs`. Also ran codebase-wide linters to improve code quality.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-20 19:22:50 +03:00
Tarasov Aleksandr 302f153b91 refactor: break down handle_input into smaller methods in src/gui/input.rs (#67)
Extract sections from the long `handle_input` function into smaller,
context-specific helper methods such as `handle_hotkey_assignment`,
`handle_toggles`, `handle_playback_and_focus`, `handle_file_playback`,
`handle_navigation`, and `handle_hotkey_triggers`. This significantly
improves the maintainability and readability of `src/gui/input.rs`
while preserving original functionality.

In addition, ran `cargo clippy --fix` on the project to resolve a few
other minor health issues, like collapsing nested `if` statements and
reducing unnecessary allocations.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-20 19:21:59 +03:00
Tarasov Aleksandr f87dcb1564 refactor: remove unnecessary string cloning when finding hotkey conflicts (#68)
Changed `HotkeyConfig::find_conflicts` to return a `Vec<(&str, &str)>` rather than allocating owned `Strings`. In `src/gui/draw.rs`, the code now builds a `HashSet<&str>` directly from the borrowed strings using array-based flat-mapping, avoiding intermediate `Vec` allocations and redundant clones.

Benchmarked to be approximately 3.5x faster in scenarios involving many configured slots.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-20 19:20:54 +03:00
Tarasov Aleksandr d4d16f6ce7 Prepare Application for Flathub Submission (#64)
* chore(flatpak): prepare application for Flathub submission

- Change Flatpak filesystem permissions from `host` to `home` to comply with Flathub sandbox rules
- Remove `--share=network` build argument and implement offline Rust building using `flatpak-cargo-generator.py`
- Add generated `cargo-sources.json` to the Flatpak manifest to download dependencies
- Update `CARGO_HOME` environment variable to ensure vendored dependencies are found by `cargo build --offline`
- Update `.desktop` categories to meet Flathub specs (`AudioVideo` requirement)
- Add required `<releases>`, `bugtracker`, `vcs-browser` URLs, and valid `<developer>` tags to `metainfo.xml`

Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com>

* chore(flatpak): prepare application for Flathub submission

- Change Flatpak filesystem permissions from `host` to `home` to comply with Flathub sandbox rules
- Remove `--share=network` build argument and implement offline Rust building using `flatpak-cargo-generator.py`
- Add generated `cargo-sources.json` to the Flatpak manifest to download dependencies
- Explicitly set `CARGO_HOME=$PWD/cargo` in build-commands to ensure vendored dependencies are found by `cargo build --offline`
- Update `.desktop` categories to meet Flathub specs (`AudioVideo` requirement)
- Add required `<releases>`, `bugtracker`, `vcs-browser` URLs, and valid `<developer>` tags to `metainfo.xml`

Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com>

* chore(flatpak): add script to generate cargo sources

- Added `packages/flatpak/generate-sources.sh` to automate the generation of `cargo-sources.json`
- Script downloads the `flatpak-cargo-generator.py` tool from upstream, generates the offline sources map based on `Cargo.lock`, and cleans up after itself

Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-17 19:35:36 +03:00
25 changed files with 7436 additions and 296 deletions
+70
View File
@@ -0,0 +1,70 @@
name: Flatter
on:
push:
branches: [ main, master ]
release:
types: [ published ]
workflow_dispatch:
jobs:
flatter:
name: Flatter
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: ghcr.io/andyholmes/flatter/freedesktop:25.08
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup GPG
id: gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set Default Branch
id: set_branch
run: |
if [ "${{ github.event_name }}" == "release" ]; then
echo "branch=stable" >> $GITHUB_OUTPUT
else
echo "branch=nightly" >> $GITHUB_OUTPUT
fi
- name: Modify Manifest
run: |
echo "default-branch: ${{ steps.set_branch.outputs.branch }}" >> packages/flatpak/ru.arabianq.pwsp.yaml
- name: Install SDK Extensions
run: flatpak install -y flathub org.freedesktop.Sdk.Extension.rust-stable//25.08
org.freedesktop.Sdk.Extension.llvm20//25.08
- name: Build Flatpak
uses: andyholmes/flatter@main
with:
files: packages/flatpak/ru.arabianq.pwsp.yaml
gpg-sign: ${{ steps.gpg.outputs.fingerprint }}
upload-bundles: false
upload-pages-artifact: true
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: flatter
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
-7
View File
@@ -174,10 +174,3 @@ jobs:
cache: true cache: true
branch: master branch: master
build-bundle: true build-bundle: true
- name: Upload Flatpak to release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.prepare.outputs.tag }}
files: ru.arabianq.pwsp.flatpak
Generated
+146 -16
View File
@@ -486,9 +486,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.60" version = "1.2.61"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"jobserver", "jobserver",
@@ -1022,6 +1022,20 @@ dependencies = [
"web-time", "web-time",
] ]
[[package]]
name = "egui_extras"
version = "0.34.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bfc6870c68d3f254e33aca8200095d422e09edacb0f365f79fe23a5ba10963"
dependencies = [
"ahash",
"egui",
"enum-map",
"log",
"mime_guess2",
"profiling",
]
[[package]] [[package]]
name = "egui_glow" name = "egui_glow"
version = "0.34.1" version = "0.34.1"
@@ -1079,6 +1093,26 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"
[[package]]
name = "enum-map"
version = "2.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9"
dependencies = [
"enum-map-derive",
]
[[package]]
name = "enum-map-derive"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "enumflags2" name = "enumflags2"
version = "0.7.12" version = "0.7.12"
@@ -1898,9 +1932,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.185" version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]] [[package]]
name = "libflate" name = "libflate"
@@ -2060,6 +2094,24 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "mime"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess2"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1706dc14a2e140dec0a7a07109d9a3d5890b81e85bd6c60b906b249a77adf0ca"
dependencies = [
"mime",
"phf",
"phf_shared",
"unicase",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
@@ -2655,9 +2707,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]] [[package]]
name = "orbclient" name = "orbclient"
version = "0.3.51" version = "0.3.53"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59aed3b33578edcfa1bc96a321d590d31832b6ad55a26f0313362ce687e9abd6" checksum = "12c6933ddbbd16539a7672e697bb8d41ac3a4e99ac43eeb40c07236bd7fcb2dd"
dependencies = [ dependencies = [
"libc", "libc",
"libredox", "libredox",
@@ -2721,6 +2773,50 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "phf"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
dependencies = [
"phf_macros",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_macros"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
"quote",
"syn",
"unicase",
]
[[package]]
name = "phf_shared"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
dependencies = [
"siphasher",
"unicase",
]
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.1.11" version = "1.1.11"
@@ -2913,7 +3009,7 @@ checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
[[package]] [[package]]
name = "pwsp" name = "pwsp"
version = "1.7.2" version = "1.7.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"clap", "clap",
@@ -2921,6 +3017,7 @@ dependencies = [
"eframe", "eframe",
"egui", "egui",
"egui_dnd", "egui_dnd",
"egui_extras",
"egui_material_icons", "egui_material_icons",
"evdev", "evdev",
"itertools 0.14.0", "itertools 0.14.0",
@@ -2981,6 +3078,21 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]]
name = "rand"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]] [[package]]
name = "raw-window-handle" name = "raw-window-handle"
version = "0.6.2" version = "0.6.2"
@@ -3326,6 +3438,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c82d449ab1bccfeec125893c6875008206f038d4eb8a09e1e10caf86f44d574e" checksum = "c82d449ab1bccfeec125893c6875008206f038d4eb8a09e1e10caf86f44d574e"
[[package]]
name = "siphasher"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e"
[[package]] [[package]]
name = "skrifa" name = "skrifa"
version = "0.40.0" version = "0.40.0"
@@ -3816,7 +3934,7 @@ dependencies = [
"toml_datetime", "toml_datetime",
"toml_parser", "toml_parser",
"toml_writer", "toml_writer",
"winnow 1.0.1", "winnow 1.0.2",
] ]
[[package]] [[package]]
@@ -3837,7 +3955,7 @@ dependencies = [
"indexmap", "indexmap",
"toml_datetime", "toml_datetime",
"toml_parser", "toml_parser",
"winnow 1.0.1", "winnow 1.0.2",
] ]
[[package]] [[package]]
@@ -3846,7 +3964,7 @@ version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
dependencies = [ dependencies = [
"winnow 1.0.1", "winnow 1.0.2",
] ]
[[package]] [[package]]
@@ -3907,6 +4025,12 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "unicase"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.24" version = "1.0.24"
@@ -4017,11 +4141,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wasip2" name = "wasip2"
version = "1.0.2+wasi-0.2.9" version = "1.0.3+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
dependencies = [ dependencies = [
"wit-bindgen", "wit-bindgen 0.57.1",
] ]
[[package]] [[package]]
@@ -4030,7 +4154,7 @@ version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
dependencies = [ dependencies = [
"wit-bindgen", "wit-bindgen 0.51.0",
] ]
[[package]] [[package]]
@@ -4824,9 +4948,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5" checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -4840,6 +4964,12 @@ dependencies = [
"wit-bindgen-rust-macro", "wit-bindgen-rust-macro",
] ]
[[package]]
name = "wit-bindgen"
version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
[[package]] [[package]]
name = "wit-bindgen-core" name = "wit-bindgen-core"
version = "0.51.0" version = "0.51.0"
+2 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "pwsp" name = "pwsp"
version = "1.7.2" version = "1.7.4"
edition = "2024" edition = "2024"
authors = ["arabian"] authors = ["arabian"]
description = "PWSP lets you play audio files through your microphone. Has both CLI and GUI clients." description = "PWSP lets you play audio files through your microphone. Has both CLI and GUI clients."
@@ -50,6 +50,7 @@ eframe = { version = "0.34.1", default-features = false, features = [
"x11", "x11",
"wayland", "wayland",
] } ] }
egui_extras = "0.34.1"
egui_material_icons = "0.6.0" egui_material_icons = "0.6.0"
egui_dnd = "0.15.0" egui_dnd = "0.15.0"
+22
View File
@@ -52,6 +52,28 @@ three main components:
You can download pre-built binaries and .deb packages from You can download pre-built binaries and .deb packages from
the [releases page](https://github.com/arabianq/pipewire-soundpad/releases). the [releases page](https://github.com/arabianq/pipewire-soundpad/releases).
## **Flatpak**
You can install PWSP via Flatpak from our custom repository hosted on GitHub Pages.
Add the repository:
```bash
flatpak remote-add --user --if-not-exists arabianq-repo https://arabianq.github.io/pipewire-soundpad/index.flatpakrepo
```
Install the stable version:
```bash
flatpak install --user arabianq-repo ru.arabianq.pwsp//stable
```
Or install the nightly version (latest commit to `main`):
```bash
flatpak install --user arabianq-repo ru.arabianq.pwsp//nightly
```
## **Fedora Linux (and derivatives)** ## **Fedora Linux (and derivatives)**
If you're using Fedora, you can install PWSP from a dedicated repository using DNF. If you're using Fedora, you can install PWSP from a dedicated repository using DNF.
+3 -3
View File
@@ -1,6 +1,6 @@
pkgbase = pwsp-bin pkgbase = pwsp-bin
pkgdesc = Lets you play audio files through your microphone (Pre-built binaries) pkgdesc = Lets you play audio files through your microphone (Pre-built binaries)
pkgver = 1.7.2 pkgver = 1.7.4
pkgrel = 2 pkgrel = 2
url = https://github.com/arabianq/pipewire-soundpad url = https://github.com/arabianq/pipewire-soundpad
arch = x86_64 arch = x86_64
@@ -9,8 +9,8 @@ depends = pipewire
depends = alsa-lib depends = alsa-lib
provides = pwsp provides = pwsp
conflicts = pwsp conflicts = pwsp
source = pwsp-bin-1.7.2.zip :: https://github.com/arabianq/pipewire-soundpad/releases/download/v1.7.2/pwsp-v1.7.2-linux-x64.zip source = pwsp-bin-1.7.4.zip :: https://github.com/arabianq/pipewire-soundpad/releases/download/v1.7.4/pwsp-v1.7.4-linux-x64.zip
source = pipewire-soundpad-1.7.2.tar.gz :: https://github.com/arabianq/pipewire-soundpad/archive/refs/tags/v1.7.2.tar.gz source = pipewire-soundpad-1.7.4.tar.gz :: https://github.com/arabianq/pipewire-soundpad/archive/refs/tags/v1.7.4.tar.gz
sha256sums = SKIP sha256sums = SKIP
sha256sums = SKIP sha256sums = SKIP
+1 -1
View File
@@ -1,7 +1,7 @@
# Maintainer: Alexander Tarasov <a.tevg@ya.ru> # Maintainer: Alexander Tarasov <a.tevg@ya.ru>
pkgname=pwsp-bin pkgname=pwsp-bin
_pkgname=pipewire-soundpad _pkgname=pipewire-soundpad
pkgver=1.7.2 pkgver=1.7.4
pkgrel=2 pkgrel=2
pkgdesc="Lets you play audio files through your microphone (Pre-built binaries)" pkgdesc="Lets you play audio files through your microphone (Pre-built binaries)"
arch=('x86_64') arch=('x86_64')
+2 -2
View File
@@ -1,6 +1,6 @@
pkgbase = pwsp pkgbase = pwsp
pkgdesc = Lets you play audio files through your microphone pkgdesc = Lets you play audio files through your microphone
pkgver = 1.7.2 pkgver = 1.7.4
pkgrel = 1 pkgrel = 1
url = https://github.com/arabianq/pipewire-soundpad url = https://github.com/arabianq/pipewire-soundpad
arch = any arch = any
@@ -10,7 +10,7 @@ pkgbase = pwsp
makedepends = cargo makedepends = cargo
makedepends = pipewire makedepends = pipewire
makedepends = alsa-lib makedepends = alsa-lib
source = https://github.com/arabianq/pipewire-soundpad/archive/refs/tags/v1.7.2.tar.gz source = https://github.com/arabianq/pipewire-soundpad/archive/refs/tags/v1.7.4.tar.gz
sha256sums = SKIP sha256sums = SKIP
pkgname = pwsp pkgname = pwsp
+1 -1
View File
@@ -1,7 +1,7 @@
# Maintainer: Alexander Tarasov <a.tevg@ya.ru> # Maintainer: Alexander Tarasov <a.tevg@ya.ru>
pkgsubn=pwsp pkgsubn=pwsp
pkgname=pwsp pkgname=pwsp
pkgver=1.7.2 pkgver=1.7.4
pkgrel=1 pkgrel=1
pkgdesc="Lets you play audio files through your microphone" pkgdesc="Lets you play audio files through your microphone"
arch=('any') arch=('any')
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
set -e
if [ ! -f "Cargo.lock" ]; then
echo "Error: Cargo.lock not found. Please run this script from the project root."
return 1
fi
echo "Downloading flatpak-cargo-generator.py..."
curl -sLO https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/cargo/flatpak-cargo-generator.py
chmod +x flatpak-cargo-generator.py
echo "Generating cargo-sources.json..."
python3 flatpak-cargo-generator.py Cargo.lock -o packages/flatpak/cargo-sources.json
echo "Cleaning up..."
rm flatpak-cargo-generator.py
echo "Successfully generated packages/flatpak/cargo-sources.json"
+1 -1
View File
@@ -5,5 +5,5 @@ Exec=pwsp-wrapper.py %u
Icon=ru.arabianq.pwsp Icon=ru.arabianq.pwsp
Terminal=false Terminal=false
Type=Application Type=Application
Categories=Audio;Utility; Categories=AudioVideo;Audio;
Keywords=soundpad;pipewire;audio; Keywords=soundpad;pipewire;audio;
@@ -15,11 +15,17 @@
<launchable type="desktop-id">ru.arabianq.pwsp.desktop</launchable> <launchable type="desktop-id">ru.arabianq.pwsp.desktop</launchable>
<screenshots> <screenshots>
<screenshot type="default"> <screenshot type="default">
<image> <image>https://raw.githubusercontent.com/arabianq/pipewire-soundpad/master/assets/screenshot.png</image>
https://raw.githubusercontent.com/arabianq/pipewire-soundpad/master/assets/screenshot.png</image>
</screenshot> </screenshot>
</screenshots> </screenshots>
<url type="homepage">https://pwsp.arabianq.ru</url> <url type="homepage">https://pwsp.arabianq.ru</url>
<developer_name>arabian</developer_name> <url type="bugtracker">https://github.com/arabianq/pipewire-soundpad/issues</url>
<url type="vcs-browser">https://github.com/arabianq/pipewire-soundpad</url>
<developer id="ru.arabianq">
<name>arabian</name>
</developer>
<releases>
<release version="1.7.4" date="2026-04-25" />
</releases>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
</component> </component>
+3 -6
View File
@@ -14,10 +14,9 @@ finish-args:
- --filesystem=xdg-run/pipewire-0 - --filesystem=xdg-run/pipewire-0
- --filesystem=xdg-run/pwsp:create - --filesystem=xdg-run/pwsp:create
- --filesystem=xdg-run/app/ru.arabianq.pwsp:create - --filesystem=xdg-run/app/ru.arabianq.pwsp:create
- --filesystem=host - --filesystem=home
- --device=all - --device=all
- --device=dri - --device=dri
- --share=network
- --talk-name=org.freedesktop.portal.Desktop - --talk-name=org.freedesktop.portal.Desktop
- --talk-name=org.freedesktop.portal.Documents - --talk-name=org.freedesktop.portal.Documents
@@ -30,11 +29,8 @@ build-options:
modules: modules:
- name: pwsp - name: pwsp
buildsystem: simple buildsystem: simple
build-options:
build-args:
- --share=network
build-commands: build-commands:
- cargo build --release - export CARGO_HOME=$PWD/cargo && cargo build --release --offline
- install -Dm755 target/release/pwsp-daemon /app/bin/pwsp-daemon - install -Dm755 target/release/pwsp-daemon /app/bin/pwsp-daemon
- install -Dm755 target/release/pwsp-cli /app/bin/pwsp-cli - install -Dm755 target/release/pwsp-cli /app/bin/pwsp-cli
- install -Dm755 target/release/pwsp-gui /app/bin/pwsp-gui - install -Dm755 target/release/pwsp-gui /app/bin/pwsp-gui
@@ -45,3 +41,4 @@ modules:
sources: sources:
- type: dir - type: dir
path: ../../ path: ../../
- cargo-sources.json
+1 -1
View File
@@ -4,7 +4,7 @@
%global cargo_install_lib 0 %global cargo_install_lib 0
Name: pwsp Name: pwsp
Version: 1.7.2 Version: 1.7.4
Release: %autorelease Release: %autorelease
Summary: Lets you play audio files through your microphone Summary: Lets you play audio files through your microphone
+4 -4
View File
@@ -42,10 +42,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
lock_file.lock()?; lock_file.lock()?;
let socket_path = runtime_dir.join("daemon.sock"); let socket_path = runtime_dir.join("daemon.sock");
if let Err(e) = fs::remove_file(&socket_path) { if let Err(e) = fs::remove_file(&socket_path)
if e.kind() != std::io::ErrorKind::NotFound { && e.kind() != std::io::ErrorKind::NotFound
return Err(e.into()); {
} return Err(e.into());
} }
let listener = UnixListener::bind(&socket_path)?; let listener = UnixListener::bind(&socket_path)?;
+188 -173
View File
@@ -1,9 +1,10 @@
use crate::gui::SoundpadGui; use crate::gui::SoundpadGui;
use egui::{ use egui::{
Align, AtomExt, Button, CollapsingHeader, Color32, ComboBox, CursorIcon, FontFamily, Grid, Align, AtomExt, Button, CollapsingHeader, Color32, ComboBox, CursorIcon, FontFamily, Label,
Label, Layout, RichText, ScrollArea, Sense, Slider, TextEdit, Ui, Vec2, Layout, RichText, ScrollArea, Sense, Slider, TextEdit, Ui, Vec2,
}; };
use egui_dnd::dnd; use egui_dnd::dnd;
use egui_extras::{Column, TableBuilder};
use egui_material_icons::icons::*; use egui_material_icons::icons::*;
use pwsp::types::socket::Request; use pwsp::types::socket::Request;
use pwsp::types::{audio_player::TrackInfo, gui::AppState}; use pwsp::types::{audio_player::TrackInfo, gui::AppState};
@@ -133,26 +134,24 @@ impl SoundpadGui {
} }
pub fn draw_hotkeys(&mut self, ui: &mut Ui) { pub fn draw_hotkeys(&mut self, ui: &mut Ui) {
let area_size = ui.available_size();
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_min_width(area_size.x);
ui.set_min_height(area_size.y);
ui.spacing_mut().item_spacing.y = 5.0; ui.spacing_mut().item_spacing.y = 5.0;
// Header // --- Header ---
ui.horizontal_top(|ui| { ui.horizontal(|ui| {
let back_button = Button::new(ICON_ARROW_BACK).frame(false); let back_button = Button::new(ICON_ARROW_BACK).frame(false);
if ui.add(back_button).clicked() { if ui.add(back_button).clicked() {
self.app_state.show_hotkeys = false; self.app_state.show_hotkeys = false;
} }
ui.add_space(ui.available_width() / 2.0 - 40.0); ui.vertical_centered(|ui| {
ui.label(RichText::new("Hotkeys").color(Color32::WHITE).monospace()); ui.label(RichText::new("Hotkeys").color(Color32::WHITE).monospace());
});
}); });
ui.separator(); ui.separator();
// Search and Add Command // --- Search and Add Command ---
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.menu_button(format!("{} Add Command", ICON_ADD.codepoint), |ui| { ui.menu_button(format!("{} Add Command", ICON_ADD.codepoint), |ui| {
let mut selected_cmd = None; let mut selected_cmd = None;
@@ -185,10 +184,10 @@ impl SoundpadGui {
ui.add_space(10.0); ui.add_space(10.0);
ui.add_sized( ui.add(
[ui.available_width(), 22.0],
TextEdit::singleline(&mut self.app_state.hotkey_search_query) TextEdit::singleline(&mut self.app_state.hotkey_search_query)
.hint_text("Search hotkeys..."), .hint_text("Search hotkeys...")
.desired_width(f32::INFINITY),
); );
}); });
@@ -196,171 +195,190 @@ impl SoundpadGui {
ui.add_space(5.0); ui.add_space(5.0);
let conflicts = self.app_state.hotkey_config.find_conflicts(); let conflicts = self.app_state.hotkey_config.find_conflicts();
let conflict_slots: std::collections::HashSet<String> = conflicts let conflict_slots: std::collections::HashSet<&str> =
.iter() conflicts.into_iter().flat_map(|(a, b)| [a, b]).collect();
.flat_map(|(a, b)| vec![a.clone(), b.clone()])
.collect();
let search = self.app_state.hotkey_search_query.to_lowercase(); let search = self.app_state.hotkey_search_query.to_lowercase();
// Slots table
let mut action: Option<HotkeyAction> = None; let mut action: Option<HotkeyAction> = None;
let area_size = ui.available_size();
ScrollArea::vertical().show(ui, |ui| { let slots: Vec<_> = self
ui.set_min_width(area_size.x); .app_state
Grid::new("hotkeys_grid") .hotkey_config
.striped(true) .slots
.num_columns(4) .iter()
.max_col_width(area_size.x) .filter(|s| {
.min_col_width(area_size.x / 4.0) if search.is_empty() {
.spacing([40.0, 10.0]) return true;
.show(ui, |ui| { }
// Table header s.slot.to_lowercase().contains(&search)
|| format!("{:?}", s.action).to_lowercase().contains(&search)
|| s.key_chord
.as_deref()
.unwrap_or("")
.to_lowercase()
.contains(&search)
})
.cloned()
.collect();
let available_width = ui.available_width();
let col_width = (available_width / 4.0).max(80.0);
TableBuilder::new(ui)
.striped(true)
.column(Column::exact(col_width).clip(true)) // Slot
.column(Column::exact(col_width).clip(true)) // Sound / Action name
.column(Column::exact(col_width).clip(true)) // Key Chord
.column(Column::exact(col_width).clip(true)) // Actions
.header(30.0, |mut header| {
header.col(|ui| {
ui.label( ui.label(
RichText::new("Slot") RichText::new("Slot")
.strong() .strong()
.monospace() .monospace()
.color(Color32::LIGHT_GRAY), .color(Color32::LIGHT_GRAY),
); );
});
header.col(|ui| {
ui.label( ui.label(
RichText::new("Sound") RichText::new("Sound")
.strong() .strong()
.monospace() .monospace()
.color(Color32::LIGHT_GRAY), .color(Color32::LIGHT_GRAY),
); );
});
header.col(|ui| {
ui.label( ui.label(
RichText::new("Key Chord") RichText::new("Key Chord")
.strong() .strong()
.monospace() .monospace()
.color(Color32::LIGHT_GRAY), .color(Color32::LIGHT_GRAY),
); );
});
header.col(|ui| {
ui.label( ui.label(
RichText::new("Actions") RichText::new("Actions")
.strong() .strong()
.monospace() .monospace()
.color(Color32::LIGHT_GRAY), .color(Color32::LIGHT_GRAY),
); );
ui.end_row();
let slots: Vec<_> = self
.app_state
.hotkey_config
.slots
.iter()
.filter(|s| {
if search.is_empty() {
return true;
}
s.slot.to_lowercase().contains(&search)
|| format!("{:?}", s.action).to_lowercase().contains(&search)
|| s.key_chord
.as_deref()
.unwrap_or("")
.to_lowercase()
.contains(&search)
})
.cloned()
.collect();
for slot in &slots {
ui.horizontal(|ui| {
// Conflict badge
if conflict_slots.contains(&slot.slot) {
ui.label(
RichText::new(ICON_WARNING.codepoint)
.color(Color32::from_rgb(255, 165, 0)),
)
.on_hover_text("Key chord conflict");
}
// Slot name
let slot_text = RichText::new(&slot.slot).monospace();
ui.label(slot_text);
});
// Action description
let action_name = match slot.action.name.as_str() {
"play" => {
if let Some(file_path_str) = slot.action.args.get("file_path") {
Path::new(file_path_str)
.file_name()
.unwrap_or_default()
.to_string_lossy()
.to_string()
} else {
"Play".to_string()
}
}
"toggle_pause" => "Toggle Pause".to_string(),
"pause" => "Pause Playback".to_string(),
"resume" => "Resume Playback".to_string(),
"stop" => "Stop Playback".to_string(),
"toggle_loop" => "Toggle Loop".to_string(),
other => other.to_string(),
};
ui.add(Label::new(RichText::new(action_name).monospace()).truncate());
// Key chord
let chord_text = slot.key_chord.as_deref().unwrap_or("(none)");
ui.label(RichText::new(chord_text).monospace().color(
if slot.key_chord.is_some() {
Color32::from_rgb(100, 200, 100)
} else {
Color32::GRAY
},
));
ui.horizontal(|ui| {
// Delete button
if ui
.add(Button::new(ICON_DELETE).frame(false))
.on_hover_text("Remove slot")
.clicked()
{
action = Some(HotkeyAction::Remove(slot.slot.clone()));
}
// Set key chord button
if ui
.add(Button::new(ICON_KEYBOARD).frame(false))
.on_hover_text("Set key chord")
.clicked()
{
action = Some(HotkeyAction::Capture(slot.slot.clone()));
}
// Clear key chord
if slot.key_chord.is_some()
&& ui
.add(Button::new(ICON_BACKSPACE).frame(false))
.on_hover_text("Clear key chord")
.clicked()
{
action = Some(HotkeyAction::ClearChord(slot.slot.clone()));
}
// Play button
if ui
.add(Button::new(ICON_PLAY_ARROW).frame(false))
.on_hover_text("Play")
.clicked()
{
action = Some(HotkeyAction::Play(slot.slot.clone()));
}
});
ui.end_row();
}
if slots.is_empty() {
ui.label("No hotkey slots configured.");
ui.label("");
ui.label("");
ui.label("");
ui.end_row();
}
}); });
}); })
.body(|mut body| {
if slots.is_empty() {
body.row(30.0, |mut row| {
row.col(|_| {});
row.col(|ui| {
ui.label(
RichText::new("No hotkey slots configured.")
.color(Color32::GRAY),
);
});
row.col(|_| {});
row.col(|_| {});
});
return;
}
for slot in &slots {
body.row(30.0, |mut row| {
// Column 1: Slot
row.col(|ui| {
ui.horizontal(|ui| {
if conflict_slots.contains(slot.slot.as_str()) {
ui.label(
RichText::new(ICON_WARNING.codepoint)
.color(Color32::from_rgb(255, 165, 0)),
)
.on_hover_text("Key chord conflict");
}
ui.add(
Label::new(RichText::new(&slot.slot).monospace())
.truncate(),
);
});
});
// Column 2: Sound / Action name
row.col(|ui| {
let action_name = match slot.action.name.as_str() {
"play" => {
if let Some(file_path_str) =
slot.action.args.get("file_path")
{
Path::new(file_path_str)
.file_name()
.unwrap_or_default()
.to_string_lossy()
.to_string()
} else {
"Play".to_string()
}
}
"toggle_pause" => "Toggle Pause".to_string(),
"pause" => "Pause Playback".to_string(),
"resume" => "Resume Playback".to_string(),
"stop" => "Stop Playback".to_string(),
"toggle_loop" => "Toggle Loop".to_string(),
other => other.to_string(),
};
ui.add(
Label::new(RichText::new(action_name).monospace()).truncate(),
);
});
// Column 3: Key Chord
row.col(|ui| {
let chord_text = slot.key_chord.as_deref().unwrap_or("(none)");
ui.add(
Label::new(RichText::new(chord_text).monospace().color(
if slot.key_chord.is_some() {
Color32::from_rgb(100, 200, 100)
} else {
Color32::GRAY
},
))
.truncate(),
);
});
// Column 4: Actions
row.col(|ui| {
ui.horizontal(|ui| {
if ui
.add(Button::new(ICON_DELETE).frame(false))
.on_hover_text("Remove slot")
.clicked()
{
action = Some(HotkeyAction::Remove(slot.slot.clone()));
}
if ui
.add(Button::new(ICON_KEYBOARD).frame(false))
.on_hover_text("Set key chord")
.clicked()
{
action = Some(HotkeyAction::Capture(slot.slot.clone()));
}
if slot.key_chord.is_some()
&& ui
.add(Button::new(ICON_BACKSPACE).frame(false))
.on_hover_text("Clear key chord")
.clicked()
{
action = Some(HotkeyAction::ClearChord(slot.slot.clone()));
}
if ui
.add(Button::new(ICON_PLAY_ARROW).frame(false))
.on_hover_text("Play")
.clicked()
{
action = Some(HotkeyAction::Play(slot.slot.clone()));
}
});
});
});
}
});
if let Some(action) = action { if let Some(action) = action {
match action { match action {
@@ -609,10 +627,10 @@ impl SoundpadGui {
.unwrap_or_else(|| path.to_string_lossy().to_string()); .unwrap_or_else(|| path.to_string_lossy().to_string());
let mut dir_button_text = RichText::new(name.clone()); let mut dir_button_text = RichText::new(name.clone());
if let Some(current_dir) = &self.app_state.current_dir { if let Some(current_dir) = &self.app_state.current_dir
if current_dir.eq(&path) { && current_dir.eq(&path)
dir_button_text = dir_button_text.color(Color32::WHITE); {
} dir_button_text = dir_button_text.color(Color32::WHITE);
} }
let dir_button = let dir_button =
@@ -645,10 +663,9 @@ impl SoundpadGui {
ICON_OPEN_IN_BROWSER.codepoint, "Open in File Manager" ICON_OPEN_IN_BROWSER.codepoint, "Open in File Manager"
)) ))
.clicked() .clicked()
&& let Err(e) = opener::open(&path)
{ {
if let Err(e) = opener::open(&path) { eprintln!("Failed to open file manager: {}", e);
eprintln!("Failed to open file manager: {}", e);
}
} }
ui.separator(); ui.separator();
@@ -728,13 +745,13 @@ impl SoundpadGui {
} }
let mut file_button_text = RichText::new(&file_name); let mut file_button_text = RichText::new(&file_name);
if let Some(current_file) = &self.app_state.selected_file { if let Some(current_file) = &self.app_state.selected_file
if current_file.eq(&entry_path) { && current_file.eq(&entry_path)
file_button_text = file_button_text.color(Color32::WHITE); {
} file_button_text = file_button_text.color(Color32::WHITE);
} }
let file_button = Button::new(file_button_text).frame(false); let file_button = Button::new(file_button_text).frame(false).truncate();
let file_button_response = ui.add(file_button); let file_button_response = ui.add(file_button);
if file_button_response.clicked() { if file_button_response.clicked() {
ui.input(|i| { ui.input(|i| {
@@ -792,10 +809,9 @@ impl SoundpadGui {
ICON_OPEN_IN_BROWSER.codepoint, "Show in File Manager" ICON_OPEN_IN_BROWSER.codepoint, "Show in File Manager"
)) ))
.clicked() .clicked()
&& let Err(e) = opener::reveal(&entry_path)
{ {
if let Err(e) = opener::reveal(&entry_path) { eprintln!("Failed to open file manager: {}", e);
eprintln!("Failed to open file manager: {}", e);
}
} }
ui.separator(); ui.separator();
@@ -822,15 +838,14 @@ impl SoundpadGui {
fn get_hotkey_badge(&self, path: &PathBuf) -> Option<String> { fn get_hotkey_badge(&self, path: &PathBuf) -> Option<String> {
for slot in &self.app_state.hotkey_config.slots { for slot in &self.app_state.hotkey_config.slots {
if slot.action.name == "play" { if slot.action.name == "play"
if let Some(file_path_str) = slot.action.args.get("file_path") { && let Some(file_path_str) = slot.action.args.get("file_path")
if Path::new(file_path_str) == path.as_path() { && Path::new(file_path_str) == path.as_path()
if let Some(chord) = &slot.key_chord { {
return Some(format!("[{}]", chord)); if let Some(chord) = &slot.key_chord {
} else { return Some(format!("[{}]", chord));
return Some(format!("[{}]", slot.slot)); } else {
} return Some(format!("[{}]", slot.slot));
}
} }
} }
} }
+15 -15
View File
@@ -9,7 +9,7 @@ use std::path::PathBuf;
fn chord_from_event(modifiers: &Modifiers, key: &Key) -> Option<String> { fn chord_from_event(modifiers: &Modifiers, key: &Key) -> Option<String> {
let key_name = key.name(); let key_name = key.name();
let is_valid = (key_name.len() == 1 let is_valid = (key_name.len() == 1
&& key_name.chars().next().unwrap().is_ascii_alphanumeric()) && key_name.chars().next().is_some_and(|c| c.is_ascii_alphanumeric()))
|| (key_name.starts_with('F') || (key_name.starts_with('F')
&& key_name.len() > 1 && key_name.len() > 1
&& key_name[1..].chars().all(|c| c.is_ascii_digit())); && key_name[1..].chars().all(|c| c.is_ascii_digit()));
@@ -60,7 +60,7 @@ pub fn parse_chord(chord: &str) -> Option<(Modifiers, Key)> {
let key_name = parts[parts.len() - 1]; let key_name = parts[parts.len() - 1];
let is_valid = (key_name.len() == 1 let is_valid = (key_name.len() == 1
&& key_name.chars().next().unwrap().is_ascii_alphanumeric()) && key_name.chars().next().is_some_and(|c| c.is_ascii_alphanumeric()))
|| (key_name.starts_with('F') || (key_name.starts_with('F')
&& key_name.len() > 1 && key_name.len() > 1
&& key_name[1..].chars().all(|c| c.is_ascii_digit())); && key_name[1..].chars().all(|c| c.is_ascii_digit()));
@@ -192,18 +192,18 @@ impl SoundpadGui {
} }
// Play selected file on Enter // Play selected file on Enter
if self.key_pressed(ctx, Key::Enter) { if self.key_pressed(ctx, Key::Enter)
if let Some(path) = self.app_state.selected_file.clone() { && let Some(path) = self.app_state.selected_file.clone()
if modifiers.ctrl { {
self.play_file(&path, true); if modifiers.ctrl {
} else if modifiers.shift self.play_file(&path, true);
&& let Some(last_track) = self.audio_player_state.tracks.last() } else if modifiers.shift
{ && let Some(last_track) = self.audio_player_state.tracks.last()
self.stop(Some(last_track.id)); {
self.play_file(&path, true); self.stop(Some(last_track.id));
} else { self.play_file(&path, true);
self.play_file(&path, false); } else {
} self.play_file(&path, false);
} }
} }
@@ -212,7 +212,7 @@ impl SoundpadGui {
let arrow_down_pressed = self.key_pressed(ctx, Key::ArrowDown); let arrow_down_pressed = self.key_pressed(ctx, Key::ArrowDown);
if modifiers.ctrl && (arrow_up_pressed || arrow_down_pressed) { if modifiers.ctrl && (arrow_up_pressed || arrow_down_pressed) {
if modifiers.shift && !self.app_state.dirs.is_empty() { if modifiers.shift && !self.app_state.dirs.is_empty() {
let mut dirs: Vec<PathBuf> = self.app_state.dirs.iter().cloned().collect(); let mut dirs: Vec<PathBuf> = self.app_state.dirs.to_vec();
dirs.sort(); dirs.sort();
let current_dir_index = self let current_dir_index = self
+15 -16
View File
@@ -106,7 +106,7 @@ impl AudioPlayer {
fn abort_link_thread(&mut self) { fn abort_link_thread(&mut self) {
if let Some(sender) = &self.input_link_sender { if let Some(sender) = &self.input_link_sender {
if let Ok(_) = sender.send(Terminate {}) { if sender.send(Terminate {}).is_ok() {
println!("Sent terminate signal to input link thread"); println!("Sent terminate signal to input link thread");
self.input_link_sender = None; self.input_link_sender = None;
} else { } else {
@@ -117,7 +117,7 @@ impl AudioPlayer {
fn abort_player_link_thread(&mut self) { fn abort_player_link_thread(&mut self) {
if let Some(sender) = &self.player_link_sender { if let Some(sender) = &self.player_link_sender {
if let Ok(_) = sender.send(Terminate {}) { if sender.send(Terminate {}).is_ok() {
println!("Sent terminate signal to player link thread"); println!("Sent terminate signal to player link thread");
self.player_link_sender = None; self.player_link_sender = None;
} else { } else {
@@ -254,12 +254,12 @@ impl AudioPlayer {
pub fn get_volume(&mut self, id: Option<u32>) -> Option<f32> { pub fn get_volume(&mut self, id: Option<u32>) -> Option<f32> {
if let Some(id) = id { if let Some(id) = id {
if let Some(sound) = self.tracks.get_mut(&id) { if let Some(sound) = self.tracks.get_mut(&id) {
return Some(sound.sink.volume()); Some(sound.sink.volume())
} else { } else {
return None; None
} }
} else { } else {
return Some(self.volume); Some(self.volume)
} }
} }
@@ -443,10 +443,10 @@ impl AudioPlayer {
if let Some(sound) = self.tracks.get(&id) { if let Some(sound) = self.tracks.get(&id) {
let path = sound.path.clone(); let path = sound.path.clone();
let handle = tokio::task::spawn_blocking(move || { let handle = tokio::task::spawn_blocking(move || {
if let Ok(file) = fs::File::open(&path) { if let Ok(file) = fs::File::open(&path)
if let Ok(source) = Decoder::try_from(file) { && let Ok(source) = Decoder::try_from(file)
return Some((id, source)); {
} return Some((id, source));
} }
None None
}); });
@@ -455,13 +455,12 @@ impl AudioPlayer {
} }
for handle in restart_futures { for handle in restart_futures {
if let Ok(res) = handle.await { if let Ok(res) = handle.await
if let Some((id, source)) = res { && let Some((id, source)) = res
if let Some(sound) = self.tracks.get_mut(&id) { && let Some(sound) = self.tracks.get_mut(&id)
sound.sink.append(source); {
sound.sink.play(); sound.sink.append(source);
} sound.sink.play();
}
} }
} }
+1 -1
View File
@@ -673,7 +673,7 @@ impl Executable for PlayHotkeyCommand {
if let Some(cmd) = parse_command(&action) { if let Some(cmd) = parse_command(&action) {
cmd.execute().await cmd.execute().await
} else { } else {
Response::new(false, "Unknown command in hotkey slot".to_string()) Response::new(false, "Unknown command in hotkey slot")
} }
} }
} }
+10 -10
View File
@@ -13,10 +13,10 @@ impl DaemonConfig {
pub fn save_to_file(&self) -> Result<(), Box<dyn Error>> { pub fn save_to_file(&self) -> Result<(), Box<dyn Error>> {
let config_path = get_config_path()?.join("daemon.json"); let config_path = get_config_path()?.join("daemon.json");
if let Some(config_dir) = config_path.parent() { if let Some(config_dir) = config_path.parent()
if !config_path.exists() { && !config_path.exists()
fs::create_dir_all(config_dir)?; {
} fs::create_dir_all(config_dir)?;
} }
let config_json = serde_json::to_string_pretty(self)?; let config_json = serde_json::to_string_pretty(self)?;
@@ -68,10 +68,10 @@ impl GuiConfig {
pub fn save_to_file(&mut self) -> Result<(), Box<dyn Error>> { pub fn save_to_file(&mut self) -> Result<(), Box<dyn Error>> {
let config_path = get_config_path()?.join("gui.json"); let config_path = get_config_path()?.join("gui.json");
if let Some(config_dir) = config_path.parent() { if let Some(config_dir) = config_path.parent()
if !config_path.exists() { && !config_path.exists()
fs::create_dir_all(config_dir)?; {
} fs::create_dir_all(config_dir)?;
} }
// Do not save scale factor if user does not want to // Do not save scale factor if user does not want to
@@ -172,7 +172,7 @@ impl HotkeyConfig {
} }
/// Returns pairs of slot names that share the same key chord. /// Returns pairs of slot names that share the same key chord.
pub fn find_conflicts(&self) -> Vec<(String, String)> { pub fn find_conflicts(&self) -> Vec<(&str, &str)> {
let mut conflicts = vec![]; let mut conflicts = vec![];
let mut chord_map: HashMap<&str, Vec<&str>> = HashMap::new(); let mut chord_map: HashMap<&str, Vec<&str>> = HashMap::new();
@@ -186,7 +186,7 @@ impl HotkeyConfig {
if slots.len() > 1 { if slots.len() > 1 {
for i in 0..slots.len() { for i in 0..slots.len() {
for j in (i + 1)..slots.len() { for j in (i + 1)..slots.len() {
conflicts.push((slots[i].to_string(), slots[j].to_string())); conflicts.push((slots[i], slots[j]));
} }
} }
} }
+85
View File
@@ -122,3 +122,88 @@ pub fn parse_command(request: &Request) -> Option<Box<dyn Executable + Send>> {
_ => None, _ => None,
} }
} }
#[cfg(test)]
mod tests {
use super::*;
use crate::types::socket::Request;
use std::collections::HashMap;
#[test]
fn test_parse_set_volume_valid() {
let mut args = HashMap::new();
args.insert("volume".to_string(), "0.5".to_string());
args.insert("id".to_string(), "1".to_string());
let request = Request {
name: "set_volume".to_string(),
args,
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
#[test]
fn test_parse_set_volume_missing_volume() {
let mut args = HashMap::new();
args.insert("id".to_string(), "1".to_string());
let request = Request {
name: "set_volume".to_string(),
args,
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
#[test]
fn test_parse_set_volume_invalid_volume() {
let mut args = HashMap::new();
args.insert("volume".to_string(), "not-a-float".to_string());
let request = Request {
name: "set_volume".to_string(),
args,
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
#[test]
fn test_parse_set_volume_missing_id() {
let mut args = HashMap::new();
args.insert("volume".to_string(), "0.5".to_string());
let request = Request {
name: "set_volume".to_string(),
args,
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
#[test]
fn test_parse_set_volume_invalid_id() {
let mut args = HashMap::new();
args.insert("id".to_string(), "not-an-int".to_string());
args.insert("volume".to_string(), "0.5".to_string());
let request = Request {
name: "set_volume".to_string(),
args,
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
#[test]
fn test_parse_set_volume_empty_args() {
let request = Request {
name: "set_volume".to_string(),
args: HashMap::new(),
};
let cmd = parse_command(&request);
assert!(cmd.is_some());
}
}
+4 -6
View File
@@ -1,9 +1,7 @@
use crate::{ use crate::types::{
types::{ audio_player::AudioPlayer,
audio_player::AudioPlayer, config::DaemonConfig,
config::DaemonConfig, socket::{MAX_MESSAGE_SIZE, Request, Response},
socket::{MAX_MESSAGE_SIZE, Request, Response},
},
}; };
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
+7 -7
View File
@@ -112,13 +112,13 @@ pub fn start_app_state_thread(audio_player_state_shared: Arc<Mutex<AudioPlayerSt
let hotkey_res = make_request(Request::get_hotkeys()) let hotkey_res = make_request(Request::get_hotkeys())
.await .await
.unwrap_or_default(); .unwrap_or_default();
if hotkey_res.status { if hotkey_res.status
if let Ok(config) = serde_json::from_str::<HotkeyConfig>(&hotkey_res.message) { && let Ok(config) = serde_json::from_str::<HotkeyConfig>(&hotkey_res.message)
let mut guard = audio_player_state_shared {
.lock() let mut guard = audio_player_state_shared
.unwrap_or_else(|e| e.into_inner()); .lock()
guard.hotkey_config = Some(config); .unwrap_or_else(|e| e.into_inner());
} guard.hotkey_config = Some(config);
} }
last_hotkey_poll = Instant::now(); last_hotkey_poll = Instant::now();
} }
+20 -22
View File
@@ -9,6 +9,13 @@ use tokio::{
time::{Duration, timeout}, time::{Duration, timeout},
}; };
pub fn setup_pipewire_context() -> (MainLoopRc, ContextRc) {
pipewire::init();
let main_loop = MainLoopRc::new(None).expect("Failed to initialize pipewire main loop");
let context = ContextRc::new(&main_loop, None).expect("Failed to create pipewire context");
(main_loop, context)
}
fn parse_global_object( fn parse_global_object(
global_object: &GlobalObject<&DictRef>, global_object: &GlobalObject<&DictRef>,
) -> (Option<AudioDevice>, Option<Port>) { ) -> (Option<AudioDevice>, Option<Port>) {
@@ -56,20 +63,20 @@ fn parse_global_object(
(None, None) (None, None)
}; };
// Check if the object is a port // Check if the object is a port
} else if props.get("port.direction").is_some() { } else if props.get("port.direction").is_some()
if let (Some(node_id), Some(port_id), Some(port_name)) = ( && let (Some(node_id), Some(port_id), Some(port_name)) = (
props.get("node.id").and_then(|id| id.parse::<u32>().ok()), props.get("node.id").and_then(|id| id.parse::<u32>().ok()),
props.get("port.id").and_then(|id| id.parse::<u32>().ok()), props.get("port.id").and_then(|id| id.parse::<u32>().ok()),
props.get("port.name"), props.get("port.name"),
) { )
let port = Port { {
node_id, let port = Port {
port_id, node_id,
name: port_name.to_string(), port_id,
}; name: port_name.to_string(),
};
return (None, Some(port)); return (None, Some(port));
}
} }
} }
(None, None) (None, None)
@@ -79,9 +86,7 @@ async fn pw_get_global_objects_thread(
main_sender: mpsc::Sender<(Option<AudioDevice>, Option<Port>)>, main_sender: mpsc::Sender<(Option<AudioDevice>, Option<Port>)>,
pw_receiver: pipewire::channel::Receiver<Terminate>, pw_receiver: pipewire::channel::Receiver<Terminate>,
) { ) {
pipewire::init(); let (main_loop, context) = setup_pipewire_context();
let main_loop = MainLoopRc::new(None).expect("Failed to initialize pipewire main loop");
// Stop main loop on Terminate message // Stop main loop on Terminate message
let _receiver = pw_receiver.attach(main_loop.loop_(), { let _receiver = pw_receiver.attach(main_loop.loop_(), {
@@ -89,7 +94,6 @@ async fn pw_get_global_objects_thread(
move |_| _main_loop.quit() move |_| _main_loop.quit()
}); });
let context = ContextRc::new(&main_loop, None).expect("Failed to create pipewire context");
let core = context let core = context
.connect(None) .connect(None)
.expect("Failed to connect to pipewire context"); .expect("Failed to connect to pipewire context");
@@ -224,10 +228,7 @@ pub fn create_virtual_mic() -> Result<pipewire::channel::Sender<Terminate>, Box<
let (pw_sender, pw_receiver) = pipewire::channel::channel::<Terminate>(); let (pw_sender, pw_receiver) = pipewire::channel::channel::<Terminate>();
let _pw_thread = thread::spawn(move || { let _pw_thread = thread::spawn(move || {
pipewire::init(); let (main_loop, context) = setup_pipewire_context();
let main_loop = MainLoopRc::new(None).expect("Failed to initialize pipewire main loop");
let context = ContextRc::new(&main_loop, None).expect("Failed to create pipewire context");
let core = context let core = context
.connect(None) .connect(None)
.expect("Failed to connect to pipewire context"); .expect("Failed to connect to pipewire context");
@@ -305,10 +306,7 @@ pub fn create_link(
let (pw_sender, pw_receiver) = pipewire::channel::channel::<Terminate>(); let (pw_sender, pw_receiver) = pipewire::channel::channel::<Terminate>();
let _pw_thread = thread::spawn(move || { let _pw_thread = thread::spawn(move || {
pipewire::init(); let (main_loop, context) = setup_pipewire_context();
let main_loop = MainLoopRc::new(None).expect("Failed to initialize pipewire main loop");
let context = ContextRc::new(&main_loop, None).expect("Failed to create pipewire context");
let core = context let core = context
.connect(None) .connect(None)
.expect("Failed to connect to pipewire context"); .expect("Failed to connect to pipewire context");