[go: nahoru, domu]

Skip to content

Commit

Permalink
Add pipewire support
Browse files Browse the repository at this point in the history
  • Loading branch information
fxttr committed Dec 6, 2023
1 parent 2a446d5 commit 71705d8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 28 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interfaces = "0.0.9"
nix = "0.27.1"
x11 = "2.21.0"
libzetta = "0.5.0"
pipewire = "0.7.2"

[target.'cfg(freebsd)'.dependencies]
sysctl = "0.5.5"
Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@
packages.default = hadron;

devShells.default = pkgs.mkShell {
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang}/lib";
inputsFrom = builtins.attrValues self.checks;

nativeBuildInputs = with pkgs; [
fenix-toolchain
rust-analyzer
rustfmt
clippy
pkg-config
zfs
xorg.libX11
pipewire
];
};
});
Expand Down
12 changes: 1 addition & 11 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::fs;
use std::path::Path;
use toml::de::Error;

#[derive(Deserialize)]
#[derive(Deserialize, Default)]
pub struct Config {
pub components: Components,
pub settings: Settings,
Expand Down Expand Up @@ -63,16 +63,6 @@ impl Config {
}
}

impl Default for Config {
fn default() -> Self {
Self {
components: Default::default(),
settings: Default::default(),
date: Default::default(),
}
}
}

impl Default for Components {
fn default() -> Self {
Self {
Expand Down
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,15 @@ fn main() {
let root = XRootWindow(dpy, screen);

loop {
let mut msg: String = String::new();

#[cfg(target_os = "freebsd")]
{
let jail_changes = jails.read();
if jail_changes != "" {
show_monitor(&jail_changes, dpy, root);
}
}

let mut msg: String = String::new();

#[cfg(target_os = "freebsd")]
{
msg = msg + " ";
}

Expand All @@ -119,6 +116,7 @@ fn main() {
}

put(&msg, dpy, root);

thread::sleep(duration);
}
}
Expand All @@ -133,8 +131,8 @@ fn put(msg: &str, dpy: *mut _XDisplay, root: u64) {
}
}

fn watch<'a>(
map: &'a mut Vec<(char, char, Box<dyn Monitor>)>,
fn watch(
map: &mut Vec<(char, char, Box<dyn Monitor>)>,
format_pair: (char, char),
module: Box<dyn Monitor>,
option: bool,
Expand Down
13 changes: 5 additions & 8 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ impl Monitor for Network {
let mut nic_addr: String = String::new();

interface.addresses.iter().for_each(|x| {
match x.addr {
Some(x) => {
nic_addr = match x {
net::SocketAddr::V4(ref y) => format!("{}", y.ip()),
net::SocketAddr::V6(ref y) => format!("{}", y.ip()),
}
if let Some(x) = x.addr {
nic_addr = match x {
net::SocketAddr::V4(ref y) => format!("{}", y.ip()),
net::SocketAddr::V6(ref y) => format!("{}", y.ip()),
}
None => {}
};
}
});

if nic_addr.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions src/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

use std::{fs::File, os::unix::prelude::AsRawFd};

use crate::monitor::Monitor;
#[cfg(target_os = "linux")]
use nix::libc::ioctl;
#[cfg(target_os = "freebsd")]
use nix::libc::request_code_read;

use crate::monitor::Monitor;

#[cfg(target_os = "freebsd")]
pub struct Volume {
mixer: File,
Expand Down

0 comments on commit 71705d8

Please sign in to comment.