Compare commits
No commits in common. "17d3c6469ec07ed9c6abb1c093bf090f6188a9cf" and "ad1d0bde3530dddf28f380564afcf2d6b20d0c52" have entirely different histories.
17d3c6469e
...
ad1d0bde35
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -303,20 +303,6 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures"
|
|
||||||
version = "0.3.29"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335"
|
|
||||||
dependencies = [
|
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
|
||||||
"futures-io",
|
|
||||||
"futures-sink",
|
|
||||||
"futures-task",
|
|
||||||
"futures-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.29"
|
version = "0.3.29"
|
||||||
|
@ -324,7 +310,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"
|
checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -333,12 +318,6 @@ version = "0.3.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
|
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-io"
|
|
||||||
version = "0.3.29"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-sink"
|
name = "futures-sink"
|
||||||
version = "0.3.29"
|
version = "0.3.29"
|
||||||
|
@ -358,7 +337,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
|
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
|
@ -1028,7 +1006,6 @@ dependencies = [
|
||||||
"dbus-codegen",
|
"dbus-codegen",
|
||||||
"dbus-tokio",
|
"dbus-tokio",
|
||||||
"eyre",
|
"eyre",
|
||||||
"futures",
|
|
||||||
"local-ip-address",
|
"local-ip-address",
|
||||||
"log",
|
"log",
|
||||||
"maxminddb",
|
"maxminddb",
|
||||||
|
|
|
@ -13,7 +13,6 @@ chrono-tz = "0.8"
|
||||||
dbus = "0.9"
|
dbus = "0.9"
|
||||||
dbus-tokio = "0.7"
|
dbus-tokio = "0.7"
|
||||||
eyre = "0.6"
|
eyre = "0.6"
|
||||||
futures = { version = "0.3", default-features = false }
|
|
||||||
local-ip-address = "0.5"
|
local-ip-address = "0.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
maxminddb = "0.23"
|
maxminddb = "0.23"
|
||||||
|
|
|
@ -3,14 +3,11 @@ use crate::tile::TileData;
|
||||||
use crate::tiles;
|
use crate::tiles;
|
||||||
|
|
||||||
use dbus::nonblock::SyncConnection;
|
use dbus::nonblock::SyncConnection;
|
||||||
use futures::FutureExt;
|
|
||||||
use log::error;
|
use log::error;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
use smart_default::SmartDefault;
|
use smart_default::SmartDefault;
|
||||||
|
|
||||||
use std::convert::Infallible;
|
|
||||||
use std::env::var;
|
use std::env::var;
|
||||||
use std::future::Future;
|
|
||||||
use std::iter::FromIterator as _;
|
use std::iter::FromIterator as _;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -206,38 +203,31 @@ pub async fn read_config() -> eyre::Result<Config> {
|
||||||
Ok(toml::from_str(&string)?)
|
Ok(toml::from_str(&string)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn<F>(future: F, tile_id: usize) -> JoinHandle<()>
|
|
||||||
where
|
|
||||||
F: Future<Output = eyre::Result<Infallible>> + Send + 'static,
|
|
||||||
{
|
|
||||||
tokio::spawn(future.map(move |r| match r {
|
|
||||||
Ok(i) => match i {},
|
|
||||||
Err(e) => error!("Tile {} exited with error: {:?}", tile_id, e),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn launch_tile(
|
pub fn launch_tile(
|
||||||
tile: TileConfig,
|
tile: TileConfig,
|
||||||
sender: mpsc::Sender<TileData>,
|
sender: mpsc::Sender<TileData>,
|
||||||
tile_id: usize,
|
tile_id: usize,
|
||||||
dbus_conn: &Arc<SyncConnection>,
|
dbus_conn: Arc<SyncConnection>,
|
||||||
) -> JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
let output_chan = OutputChannel::with_random_uuid(sender.clone(), tile_id);
|
tokio::spawn(async move {
|
||||||
match tile.clone() {
|
let output_chan = OutputChannel::with_random_uuid(sender, tile_id);
|
||||||
TileConfig::Battery(c) => spawn(tiles::battery(c, output_chan), tile_id),
|
let result = match tile {
|
||||||
TileConfig::Hostname(c) => {
|
TileConfig::Battery(c) => tiles::battery(c, output_chan).await,
|
||||||
spawn(tiles::hostname(c, output_chan, dbus_conn.clone()), tile_id)
|
TileConfig::Hostname(c) => tiles::hostname(c, output_chan, dbus_conn).await,
|
||||||
|
TileConfig::Load(c) => tiles::load(c, output_chan).await,
|
||||||
|
TileConfig::Memory(c) => tiles::memory(c, output_chan).await,
|
||||||
|
TileConfig::UtcTime(c) => tiles::utc_time(c, output_chan).await,
|
||||||
|
TileConfig::Iwd(c) => tiles::iwd(c, output_chan, dbus_conn).await,
|
||||||
|
TileConfig::SystemTime(c) => tiles::system_time(c, output_chan).await,
|
||||||
|
TileConfig::LocalTime(c) => tiles::local_time(c, output_chan).await,
|
||||||
|
TileConfig::InternetTime(c) => tiles::internet_time(c, output_chan).await,
|
||||||
|
TileConfig::NetworkManager(c) => {
|
||||||
|
tiles::network_manager(c, output_chan, dbus_conn).await
|
||||||
}
|
}
|
||||||
TileConfig::Load(c) => spawn(tiles::load(c, output_chan), tile_id),
|
};
|
||||||
TileConfig::Memory(c) => spawn(tiles::memory(c, output_chan), tile_id),
|
match result {
|
||||||
TileConfig::UtcTime(c) => spawn(tiles::utc_time(c, output_chan), tile_id),
|
Ok(t) => match t {},
|
||||||
TileConfig::Iwd(c) => spawn(tiles::iwd(c, output_chan, dbus_conn.clone()), tile_id),
|
Err(e) => error!("Tile {} exited with error: {:?}", tile_id, e),
|
||||||
TileConfig::SystemTime(c) => spawn(tiles::system_time(c, output_chan), tile_id),
|
|
||||||
TileConfig::LocalTime(c) => spawn(tiles::local_time(c, output_chan), tile_id),
|
|
||||||
TileConfig::InternetTime(c) => spawn(tiles::internet_time(c, output_chan), tile_id),
|
|
||||||
TileConfig::NetworkManager(c) => spawn(
|
|
||||||
tiles::network_manager(c, output_chan, dbus_conn.clone()),
|
|
||||||
tile_id,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,9 @@ async fn main() -> eyre::Result<()> {
|
||||||
.tile
|
.tile
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(sender_id, tile)| config::launch_tile(tile, sender.clone(), sender_id, &dbus_conn))
|
.map(|(sender_id, tile)| {
|
||||||
|
config::launch_tile(tile, sender.clone(), sender_id, dbus_conn.clone())
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let num_tiles = tiles.len();
|
let num_tiles = tiles.len();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::tile::{Block, TileData};
|
use crate::tile::{Block, TileData};
|
||||||
use eyre::OptionExt;
|
use eyre::OptionExt;
|
||||||
use serde::{ser::SerializeSeq, Serialize};
|
use serde::{Serialize, ser::SerializeSeq};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::{self, AsyncWriteExt},
|
io::{self, AsyncWriteExt},
|
||||||
|
@ -51,7 +51,7 @@ pub async fn run(num_tiles: usize, mut receiver: mpsc::Receiver<TileData>) -> ey
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
*block = Some(message.block);
|
*block = Some(message.block);
|
||||||
let mut serialized = serde_json::to_vec(&NoneSkipper(&blocks)).unwrap();
|
let mut serialized = serde_json::to_vec(&blocks).unwrap();
|
||||||
serialized.extend_from_slice(b",\n");
|
serialized.extend_from_slice(b",\n");
|
||||||
stdout.write_all(&serialized).await?;
|
stdout.write_all(&serialized).await?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,30 @@ pub async fn network_manager(
|
||||||
_output: OutputChannel,
|
_output: OutputChannel,
|
||||||
dbus_conn: Arc<SyncConnection>,
|
dbus_conn: Arc<SyncConnection>,
|
||||||
) -> eyre::Result<Infallible> {
|
) -> eyre::Result<Infallible> {
|
||||||
|
let root_proxy = Proxy::new(
|
||||||
|
"org.freedesktop.NetworkManager",
|
||||||
|
"/org/freedesktop/NetworkManager",
|
||||||
|
Duration::from_secs(5),
|
||||||
|
dbus_conn.as_ref(),
|
||||||
|
);
|
||||||
|
|
||||||
let destination = "org.freedesktop.NetworkManager";
|
let primary_connection = root_proxy.primary_connection().await?;
|
||||||
let timeout = Duration::from_secs(5);
|
let primary_connection_proxy = Proxy::new(
|
||||||
let connection = dbus_conn.as_ref();
|
"org.freedesktop.NetworkManager",
|
||||||
let make_proxy = |path| Proxy::new(destination, path, timeout, connection);
|
primary_connection,
|
||||||
|
Duration::from_secs(5),
|
||||||
|
dbus_conn.as_ref(),
|
||||||
|
);
|
||||||
|
|
||||||
let primary_connection = make_proxy("/org/freedesktop/NetworkManager".into()).primary_connection().await?;
|
let specific_object = primary_connection_proxy.specific_object().await?;
|
||||||
let specific_object = make_proxy(primary_connection).specific_object().await?;
|
let specific_object_proxy = Proxy::new(
|
||||||
let ssid = make_proxy(specific_object).ssid().await?;
|
"org.freedesktop.NetworkManager",
|
||||||
|
specific_object,
|
||||||
|
Duration::from_secs(5),
|
||||||
|
dbus_conn.as_ref(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let ssid = specific_object_proxy.ssid().await?;
|
||||||
|
|
||||||
log::warn!("got ssid: {}", String::from_utf8_lossy(&ssid));
|
log::warn!("got ssid: {}", String::from_utf8_lossy(&ssid));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue