Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust rewrite #99

Merged
merged 31 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7c41dfb
Implement io operations
jim3692 Feb 28, 2024
e70b3d5
Implement GetVersion
jim3692 Feb 28, 2024
ee593d9
Change indentations to 2
jim3692 Feb 28, 2024
96db58a
Implement GetSessionType
jim3692 Feb 28, 2024
9af4d56
Implement GetNodes
jim3692 Feb 28, 2024
cb7d114
Refactor GetNodes
jim3692 Feb 28, 2024
f7d8dfb
Refactor
jim3692 Feb 28, 2024
03bee11
Unused json
jim3692 Feb 28, 2024
85f1bf8
New fn get_pw_dump
jim3692 Feb 28, 2024
0d9b081
Refactor pipewire.rs
jim3692 Feb 28, 2024
2bf8f0f
Fix indentation
jim3692 Feb 28, 2024
7f259e6
Implement IsPipewireScreenAudioRunning
jim3692 Feb 28, 2024
6fa75a4
Fix node_exists
jim3692 Feb 28, 2024
eb4318f
Cleanup
jim3692 Mar 1, 2024
d0796d6
Prefer borrowed strings + Create nodes
jim3692 Mar 1, 2024
cca9551
Cache pipewire dump
jim3692 Mar 2, 2024
e98bf28
Fix StartPipewireScreenAudio + Implement StopPipewireScreenAudio
jim3692 Mar 2, 2024
1b7dca2
Switch from json to serde_json
jim3692 May 7, 2024
fbc9deb
fixes
jim3692 May 7, 2024
9cf642d
Update cli.sh to use connector-rs
jim3692 May 7, 2024
5ee3317
Rename variables to match bash impl
jim3692 May 7, 2024
a68252f
Fix StartPipewireScreenAudio
jim3692 May 7, 2024
09fa500
Implement SetSharingNode
jim3692 May 7, 2024
e79d086
Enable rust stacktrace on cli.sh
jim3692 May 7, 2024
12f5774
Update firefox.json and install.sh to target connector-rs
jim3692 May 7, 2024
000082e
Fix argument parsing
jim3692 May 7, 2024
5534726
Add Cargo.lock
jim3692 May 8, 2024
63f4cce
Update nix flake for rust rewrite
IceDBorn May 8, 2024
c2f1459
update cli
jim3692 Jul 11, 2024
d5c9c23
update install script
jim3692 Jul 11, 2024
e248226
update readme
jim3692 Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ You can find us on [Matrix](https://matrix.to/#/#pipewire-screenaudio:matrix.org

#### Requirements

- gawk
- hexdump
- jq
- cargo
- pipewire

```bash
Expand Down Expand Up @@ -82,6 +80,10 @@ bash install.sh
```bash
bash native/connector/cli.sh SetSharingNode '{ "micId": 100, "node": 200 }'
```
- **Environment:**
```bash
DEBUG=1 # Set to enable verbose logging
```

## Known Problems

Expand Down
39 changes: 14 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,38 @@

outputs = { self, nixpkgs, }:
let
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = nixpkgs.legacyPackages;
read = builtins.readFile;
systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs systems;
write = builtins.toFile;

mkDate = longDate:
with builtins;
(concatStringsSep "-" [
(substring 0 4 longDate)
(substring 4 2 longDate)
(substring 6 2 longDate)
]);

firefoxJSON = write "firefox.json" (read native/native-messaging-hosts/firefox.json);
connectorPath = "lib/mozilla/native-messaging-hosts/com.icedborn.pipewirescreenaudioconnector.json";
in {
packages = forAllSystems (system: {
default = with pkgsFor.${system};
stdenv.mkDerivation {
rustPlatform.buildRustPackage {
name = "pipewire-screenaudio";
version = mkDate (self.lastModifiedDate or "19700101") + "_"
+ (self.shortRev or "dirty");

src = self;

buildInputs = [ gawk hexdump jq pipewire ];

installPhase = ''
runHook preInstall

# Replace jq with its absolute path
substituteInPlace native/connector/virtmic.sh --replace jq ${pkgs.jq}/bin/jq
substituteInPlace native/connector/pipewire-screen-audio-connector.sh --replace jq ${pkgs.jq}/bin/jq
substituteInPlace native/connector/connect-and-monitor.sh --replace jq ${pkgs.jq}/bin/jq
substituteInPlace native/connector/util.sh --replace jq ${pkgs.jq}/bin/jq

# Install files
mkdir -p $out/lib/out
install -Dm755 native/connector/pipewire-screen-audio-connector.sh $out/lib/connector/pipewire-screen-audio-connector.sh
install -Dm755 native/connector/virtmic.sh $out/lib/connector/virtmic.sh
install -Dm755 native/connector/connect-and-monitor.sh $out/lib/connector/connect-and-monitor.sh
install -Dm755 native/connector/util.sh $out/lib/connector/util.sh
src = ./native/connector-rs;
buildInputs = [ pipewire ];
cargoHash = "sha256-+mLsrKt7WRyO++B0rFoRb/JodBPxhZCdg2qZguKzqUI=";

postInstall = ''
# Firefox manifest
substituteInPlace native/native-messaging-hosts/firefox.json --replace /usr/lib/pipewire-screenaudio $out/lib
install -Dm644 native/native-messaging-hosts/firefox.json $out/lib/mozilla/native-messaging-hosts/com.icedborn.pipewirescreenaudioconnector.json

runHook postInstall
install -Dm644 ${firefoxJSON} "$out/${connectorPath}"
substituteInPlace "$out/${connectorPath}" --replace "/usr/lib/pipewire-screenaudio/connector-rs/target/debug" "$out/bin"
'';
};
});
Expand Down
6 changes: 4 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash

set -e

projectRoot="$( cd -- "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"

mkdir -p ~/.mozilla/native-messaging-hosts
( cd $projectRoot/native/connector-rs ; cargo build )

mkdir -p ~/.mozilla/native-messaging-hosts
sed "s|/usr/lib/pipewire-screenaudio|$projectRoot/native|g" $projectRoot/native/native-messaging-hosts/firefox.json > ~/.mozilla/native-messaging-hosts/com.icedborn.pipewirescreenaudioconnector.json

10 changes: 10 additions & 0 deletions native/connector-rs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
Loading