Add a bunch of example dbus programs

This commit is contained in:
Savanni D'Gerinel 2023-02-07 09:32:02 -05:00
parent 4632e59dec
commit 477530c8d1
4 changed files with 75 additions and 25 deletions

View File

@ -0,0 +1,20 @@
/*
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of the Luminescent Dreams Tools.
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
use dbus::ffidisp::Connection;
use music_player::audio::list_devices;
fn main() {
for device in list_devices(Connection::new_session().unwrap()).unwrap() {
println!("Device: [{}] {}", device.address, device.name);
}
}

View File

@ -11,25 +11,16 @@ You should have received a copy of the GNU General Public License along with Lum
*/ */
use dbus::ffidisp::Connection; use dbus::ffidisp::Connection;
use music_player::audio::{list_devices, Message, MprisDevice}; use music_player::audio::{Message, MprisDevice};
use std::{io, thread}; use std::{env, io, thread};
fn main() { fn main() {
for device in list_devices(Connection::new_session().expect("connection to dbus session")) let device_address = env::var("DEVICE").unwrap();
.expect("to list devices")
{
println!("Device: [{}] {}", device.address, device.name);
}
/*
let progress_thread = thread::spawn(|| MprisDevice::monitor_progress(":1.1611".to_owned()));
let event_thread = thread::spawn(|| MprisDevice::scan_event_stream(":1.1611".to_owned()));
*/
let (tx, rx) = std::sync::mpsc::channel(); let (tx, rx) = std::sync::mpsc::channel();
let app_thread = thread::spawn(move || { let app_thread = thread::spawn(move || {
let mut device = MprisDevice::new(":1.1611".to_owned()).expect("to get a device"); let mut device = MprisDevice::new(device_address).unwrap();
device.run(rx); device.monitor(rx);
}); });
let stdin = io::stdin(); let stdin = io::stdin();
@ -38,15 +29,4 @@ fn main() {
let _ = tx.send(Message::Quit); let _ = tx.send(Message::Quit);
let _ = app_thread.join(); let _ = app_thread.join();
/*
println!(
"{:?}",
device.capabilities().expect("can retrieve capabilities")
);
// println!("{:?}", device.state().expect("play-pause to succeed"));
let _ = progress_thread.join();
let _ = event_thread.join();
*/
} }

View File

@ -0,0 +1,22 @@
/*
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of the Luminescent Dreams Tools.
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
use dbus::ffidisp::Connection;
use music_player::audio::{Message, MprisDevice};
use std::{env, io, thread};
fn main() {
let device_address = env::var("DEVICE").unwrap();
let connection = Connection::new_session().unwrap();
let player = mpris::Player::new(connection, device_address, 1000).unwrap();
player.
}

View File

@ -0,0 +1,28 @@
/*
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of the Luminescent Dreams Tools.
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
use dbus::ffidisp::Connection;
use music_player::audio::{AudioPlayer, MprisDevice};
use std::env;
fn main() {
let device_address = env::var("DEVICE").unwrap();
let args = env::args();
let track = args.skip(1).next();
let device = MprisDevice::new(device_address).unwrap();
println!("Track: {:?}", track);
match track {
Some(track_id) => device.play(track_id),
None => device.play_pause(),
}
.expect("play to start");
}