linux-rust: bump dependencies and clean up media_controller

This commit is contained in:
Kavish Devar
2026-04-06 13:54:33 +05:30
parent a0cdbb2842
commit 2f1208ca87
10 changed files with 2184 additions and 2384 deletions

3321
linux-rust/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,24 +4,24 @@ version = "0.1.0"
edition = "2024"
[dependencies]
tokio = {version = "1.47.1", features = ["full"]}
tokio = {version = "1.50.0", features = ["full"]}
bluer = { version = "0.17.4", features = ["full"] }
env_logger = {version = "0.11.8", features = ["auto-color"]}
uuid = "1.18.1"
log = "0.4.28"
dbus = "0.9.9"
env_logger = {version = "0.11.10", features = ["auto-color"]}
uuid = "1.23.0"
log = "0.4.29"
dbus = "0.9.10"
hex = "0.4.3"
iced = { version = "0.13.1", features = ["tokio", "image"] }
iced = { version = "0.14.0", features = ["tokio", "image"] }
libpulse-binding = "2.30.1"
ksni = "0.3.1"
image = "0.25.8"
imageproc = "0.25.0"
imageproc = "0.26.1"
ab_glyph = "0.2.32"
clap = { version = "4.5.50", features = ["derive"] }
clap = { version = "4.6.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
aes = "0.8.4"
futures = "0.3.31"
aes = "0.9.0-rc.4"
futures = "0.3.32"
[profile.release]
opt-level = "s"

View File

@@ -3,8 +3,8 @@ use crate::devices::enums::{DeviceData, DeviceInformation, DeviceType};
use crate::ui::tray::MyTray;
use crate::utils::{ah, get_devices_path, get_preferences_path};
use aes::Aes128;
use aes::cipher::generic_array::GenericArray;
use aes::cipher::{BlockDecrypt, KeyInit};
use aes::cipher::Array;
use aes::cipher::{BlockCipherDecrypt, KeyInit};
use bluer::monitor::{Monitor, MonitorEvent, Pattern};
use bluer::{Address, Session};
use futures::StreamExt;
@@ -17,8 +17,8 @@ use std::sync::Arc;
use tokio::sync::Mutex;
fn decrypt(key: &[u8; 16], data: &[u8; 16]) -> [u8; 16] {
let cipher = Aes128::new(&GenericArray::from(*key));
let mut block = GenericArray::from(*data);
let cipher = Aes128::new(&Array::from(*key));
let mut block = Array::from(*data);
cipher.decrypt_block(&mut block);
block.into()
}

View File

@@ -55,14 +55,14 @@ impl AirPodsDevice {
error!("Failed to send handshake to AirPods device: {}", e);
}
sleep(Duration::from_millis(100)).await;
sleep(Duration::from_millis(300)).await;
info!("Setting feature flags");
if let Err(e) = aacp_manager.send_set_feature_flags_packet().await {
error!("Failed to set feature flags: {}", e);
}
sleep(Duration::from_millis(100)).await;
sleep(Duration::from_millis(300)).await;
info!("Requesting notifications");
if let Err(e) = aacp_manager.send_notification_request().await {

View File

@@ -22,7 +22,7 @@ use ksni::TrayMethods;
use log::{info, warn};
use std::collections::HashMap;
use std::env;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::{AtomicBool};
use std::sync::Arc;
use tokio::sync::RwLock;
use tokio::sync::mpsc::unbounded_channel;
@@ -64,18 +64,18 @@ fn main() -> iced::Result {
}
let log_level = if args.debug { "debug" } else { "info" };
let wayland_display = env::var("WAYLAND_DISPLAY").is_ok();
if wayland_display && env::var("WGPU_BACKEND").is_err() {
unsafe { env::set_var("WGPU_BACKEND", "gl") };
}
// let wayland_display = env::var("WAYLAND_DISPLAY").is_ok();
// if wayland_display && env::var("WGPU_BACKEND").is_err() {
// unsafe { env::set_var("WGPU_BACKEND", "gl") };
// }
if env::var("RUST_LOG").is_err() {
unsafe {
env::set_var(
"RUST_LOG",
log_level.to_owned()
+ &format!(
",winit=warn,tracing=warn,iced_wgpu=warn,wgpu_hal=warn,wgpu_core=warn,cosmic_text=warn,naga=warn,iced_winit=warn,librepods_rust::bluetooth::le={}",
if args.le_debug { "debug" } else { "warn" }
",zbus=warn,winit=warn,tracing=warn,iced_wgpu=warn,wgpu_hal=warn,wgpu_core=warn,cosmic_text=warn,naga=warn,iced_winit=warn,librepods::bluetooth::le={}",
if args.le_debug { "debug" } else { "info" }
),
)
};

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ use iced::overlay::menu;
use iced::widget::button::Style;
use iced::widget::rule::FillMode;
use iced::widget::{
Rule, Space, button, column, combo_box, container, row, rule, text, text_input, toggler,
Space, button, column, combo_box, container, row, rule, text, text_input, toggler,
};
use iced::{Background, Border, Center, Color, Length, Padding, Theme};
use log::error;
@@ -30,13 +30,13 @@ pub fn airpods_view<'a>(
let aacp_manager_for_rename = aacp_manager.clone();
let rename_input = container(
row![
Space::with_width(10),
Space::new().width(10),
text("Name").size(16).style(|theme: &Theme| {
let mut style = text::Style::default();
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text_input("", &state.device_name)
.padding(Padding {
top: 5.0,
@@ -99,7 +99,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
{
let state_clone = state.clone();
let mac = mac.clone();
@@ -159,6 +159,7 @@ pub fn airpods_view<'a>(
selected_background: Background::Color(
theme.palette().primary.scale_alpha(0.3),
),
shadow: Default::default()
})
}
]
@@ -242,13 +243,13 @@ pub fn airpods_view<'a>(
.align_y(Center)
.spacing(8)
},
Rule::horizontal(8).style(
rule::horizontal(1).style(
|theme: &Theme| {
rule::Style {
color: theme.palette().text,
width: 1,
color: theme.palette().text.scale_alpha(0.2),
radius: Radius::from(12),
fill_mode: FillMode::Full
fill_mode: FillMode::Full,
snap: false
}
}
),
@@ -371,7 +372,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(airpods_info.model_number.clone()).size(16)
],
row![
@@ -380,7 +381,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(airpods_info.manufacturer.clone()).size(16)
],
row![
@@ -389,7 +390,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
button(text(airpods_info.serial_number.clone()).size(16))
.style(|theme: &Theme, _status| {
let mut style = Style::default();
@@ -406,7 +407,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
button(text(airpods_info.left_serial_number.clone()).size(16))
.style(|theme: &Theme, _status| {
let mut style = Style::default();
@@ -425,7 +426,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
button(text(airpods_info.right_serial_number.clone()).size(16))
.style(|theme: &Theme, _status| {
let mut style = Style::default();
@@ -444,7 +445,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(airpods_info.version1.clone()).size(16)
],
row![
@@ -453,7 +454,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(airpods_info.version2.clone()).size(16)
],
row![
@@ -462,7 +463,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(airpods_info.version3.clone()).size(16)
]
]
@@ -508,13 +509,13 @@ pub fn airpods_view<'a>(
container(column![
rename_input,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
listening_mode,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
audio_settings_col,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
off_listening_mode_toggle,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
information_col
])
.padding(20)

View File

@@ -29,14 +29,14 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().primary);
style
}))
.push(Space::with_height(iced::Length::from(10)))
.push(Space::new().height(iced::Length::from(10)))
.push(iced::widget::row![
text("Serial Number").size(16).style(|theme: &Theme| {
let mut style = text::Style::default();
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(nothing_info.serial_number.clone()).size(16)
])
.push(iced::widget::row![
@@ -45,7 +45,7 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
text(nothing_info.firmware_version.clone()).size(16)
]);
}
@@ -57,7 +57,7 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().text);
style
}),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
{
let state_clone = state.clone();
let mac = mac.clone();
@@ -137,6 +137,7 @@ pub fn nothing_view<'a>(
selected_background: Background::Color(
theme.palette().primary.scale_alpha(0.3),
),
shadow: Default::default()
})
}
]
@@ -159,7 +160,7 @@ pub fn nothing_view<'a>(
container(column![
noise_control_mode,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
container(information_col)
.style(|theme: &Theme| {
let mut style = container::Style::default();

View File

@@ -17,12 +17,9 @@ use iced::widget::button::Style;
use iced::widget::rule::FillMode;
use iced::widget::{
Space, button, column, combo_box, container, pane_grid, row, rule, scrollable, text,
text_input, toggler, vertical_rule,
};
use iced::{
Background, Border, Center, Element, Font, Length, Padding, Size, Subscription, Task, Theme,
daemon, window,
text_input, toggler
};
use iced::{Background, Border, Center, Element, Font, Length, Padding, Size, Subscription, Task, Theme, daemon, window, Settings};
use log::{debug, error};
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -36,12 +33,30 @@ pub fn start_ui(
device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>,
stem_control: Arc<AtomicBool>,
) -> iced::Result {
daemon(App::title, App::update, App::view)
.subscription(App::subscription)
.theme(App::theme)
.font(include_bytes!("../../assets/font/sf_pro.otf").as_slice())
.default_font(Font::with_name("SF Pro Text"))
.run_with(move || App::new(ui_rx, start_minimized, device_managers, stem_control))
let ui_rx = Arc::new(Mutex::new(ui_rx));
// not sure if this is a good idea
daemon(
move || {
App::new(
Arc::clone(&ui_rx),
start_minimized,
Arc::clone(&device_managers),
Arc::clone(&stem_control),
)
},
App::update,
App::view,
)
.subscription(App::subscription)
.theme(App::theme)
.settings(Settings {
id: Some("librepods".to_string()),
fonts: vec![include_bytes!("../../assets/font/sf_pro.otf").as_slice().into()],
default_font: Font::with_name("SF Pro Text"),
..Settings::default()
})
.run()
}
pub struct App {
@@ -109,7 +124,7 @@ pub enum Pane {
impl App {
pub fn new(
ui_rx: UnboundedReceiver<BluetoothUIMessage>,
ui_rx: Arc<Mutex<UnboundedReceiver<BluetoothUIMessage>>>,
start_minimized: bool,
device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>,
stem_control: Arc<AtomicBool>,
@@ -118,7 +133,6 @@ impl App {
let split = panes.split(pane_grid::Axis::Vertical, first_pane, Pane::Content);
panes.resize(split.unwrap().1, 0.2);
let ui_rx = Arc::new(Mutex::new(ui_rx));
let wait_task = Task::perform(wait_for_message(Arc::clone(&ui_rx)), |msg| msg);
@@ -773,46 +787,47 @@ impl App {
let content = column![
row![
text("Devices").size(18),
Space::with_width(Length::Fill),
button(
container(text("+").size(18)).center_x(Length::Fill).center_y(Length::Fill)
)
.style(
|theme: &Theme, _status| {
let mut style = Style::default();
style.text_color = theme.palette().text;
style.background = Some(Background::Color(theme.palette().primary.scale_alpha(0.1)));
style.border = Border {
width: 1.0,
color: theme.palette().primary.scale_alpha(0.1),
radius: Radius::from(8.0),
};
style
}
)
.padding(0)
.width(Length::from(28))
.height(Length::from(28))
.on_press(Message::ShowNewDialogTab)
// Removing until I actually add support for devices other than AirPods
// Space::new().width(Length::Fill),
// button(
// container(text("+").size(18)).center_x(Length::Fill).center_y(Length::Fill)
// )
// .style(
// |theme: &Theme, _status| {
// let mut style = Style::default();
// style.text_color = theme.palette().text;
// style.background = Some(Background::Color(theme.palette().primary.scale_alpha(0.1)));
// style.border = Border {
// width: 1.0,
// color: theme.palette().primary.scale_alpha(0.1),
// radius: Radius::from(8.0),
// };
// style
// }
// )
// .padding(0)
// .width(Length::from(28))
// .height(Length::from(28))
// .on_press(Message::ShowNewDialogTab)
]
.align_y(Center)
.padding(4),
Space::with_height(Length::from(8)),
Space::new().height(Length::from(8)),
devices,
Space::with_height(Length::Fill),
Space::new().height(Length::Fill),
settings
]
.padding(12);
pane_grid::Content::new(
row![
content,
vertical_rule(1).style(
rule::vertical(1).style(
|theme: &Theme| {
rule::Style{
color: theme.palette().primary.scale_alpha(0.2),
width: 2,
radius: Radius::from(8.0),
fill_mode: FillMode::Full
fill_mode: FillMode::Full,
snap: false
}
}
)
@@ -957,7 +972,7 @@ impl App {
row![
text("Theme")
.size(16),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
combo_box(
&self.theme_state,
"Select theme",
@@ -992,6 +1007,7 @@ impl App {
text_color: theme.palette().text,
selected_text_color: theme.palette().text,
selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)),
shadow: Default::default()
}
}
)
@@ -1088,9 +1104,9 @@ impl App {
container(
column![
appearance_settings_col,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
tray_text_mode_toggle,
Space::with_height(Length::from(20)),
Space::new().height(Length::from(20)),
controls_settings_col,
]
)
@@ -1102,7 +1118,7 @@ impl App {
container(
column![
text("Pick a paired device to add:").size(18),
Space::with_height(Length::from(10)),
Space::new().height(Length::from(10)),
{
let mut list_col = column![].spacing(12);
for device in self.paired_devices.clone() {
@@ -1113,7 +1129,7 @@ impl App {
text(device.0.to_string()).size(16),
text(device.1.to_string()).size(12)
].into(),
Space::with_width(Length::Fill).into(),
Space::new().height(Length::Fill).into(),
];
if !matches!(&self.pending_add_device, Some((_, addr)) if addr == &device.1) {
row_elements.push(
@@ -1145,7 +1161,7 @@ impl App {
item_col = item_col.push(
row![
text("Device Type:").size(16),
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
combo_box(
&self.device_type_state,
"Select device type",
@@ -1180,6 +1196,7 @@ impl App {
text_color: theme.palette().text,
selected_text_color: theme.palette().text,
selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)),
shadow: Default::default()
}
}
)
@@ -1188,7 +1205,7 @@ impl App {
);
item_col = item_col.push(
row![
Space::with_width(Length::Fill),
Space::new().width(Length::Fill),
button(text("Cancel").size(16).width(Length::Fill).center())
.on_press(Message::CancelAddDevice)
.style(|theme: &Theme, _status| {
@@ -1200,7 +1217,7 @@ impl App {
})
.width(Length::from(120))
.padding(4),
Space::with_width(Length::from(20)),
Space::new().width(Length::from(20)),
button(text("Add Device").size(16).width(Length::Fill).center())
.on_press(Message::ConfirmAddDevice)
.style(|theme: &Theme, _status| {

View File

@@ -1,6 +1,6 @@
use aes::Aes128;
use aes::cipher::generic_array::GenericArray;
use aes::cipher::{BlockEncrypt, KeyInit};
use aes::cipher::Array;
use aes::cipher::{BlockCipherEncrypt, KeyInit};
use iced::Theme;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
@@ -34,8 +34,8 @@ fn e(key: &[u8; 16], data: &[u8; 16]) -> [u8; 16] {
swapped_key.reverse();
let mut swapped_data = *data;
swapped_data.reverse();
let cipher = Aes128::new(&GenericArray::from(swapped_key));
let mut block = GenericArray::from(swapped_data);
let cipher = Aes128::new(&Array::from(swapped_key));
let mut block = Array::from(swapped_data);
cipher.encrypt_block(&mut block);
let mut result: [u8; 16] = block.into();
result.reverse();