commit 90fecb55c2daf6152514a8981874c9744eb4978f Author: Pietro Brenna Date: Fri Mar 13 13:08:30 2020 +0100 Commit iniziale, funzionano delle cose diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..309e0e2 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,509 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "atk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444daefa55f229af145ea58d77efd23725024ee1f6f3102743709aa6b18c663e" +dependencies = [ + "atk-sys", + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e552c1776737a4c80110d06b36d099f47c727335f9aaa5d942a72b6863a8ec6f" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "cacca" +version = "0.1.0" +dependencies = [ + "crossbeam-channel", + "gdk", + "gdk-sys", + "gio", + "glib", + "gtk", + "pango", + "vte-rs", +] + +[[package]] +name = "cairo-rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157049ba9618aa3a61c39d5d785102c04d3b1f40632a706c621a9aedc21e6084" +dependencies = [ + "bitflags", + "cairo-sys-rs", + "glib", + "glib-sys", + "gobject-sys", + "libc", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff65ba02cac715be836f63429ab00a767d48336efc5497c5637afb53b4f14d63" +dependencies = [ + "glib-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "cc" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "crossbeam-channel" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061" +dependencies = [ + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "futures-channel" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" + +[[package]] +name = "futures-executor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" + +[[package]] +name = "futures-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-task" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" + +[[package]] +name = "futures-util" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "gdk" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbe5e8772fc0865c52460cdd7a59d7d47700f44d9809d1dd00eecceb769a7589" +dependencies = [ + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e248220c46b329b097d4b158d2717f8c688f16dd76d0399ace82b3e98062bdd7" +dependencies = [ + "gdk-pixbuf-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "libc", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8991b060a9e9161bafd09bf4a202e6fd404f5b4dd1a08d53a1e84256fb34ab0" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "gdk-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6adf679e91d1bff0c06860287f80403e7db54c2d2424dce0a470023b56c88fbb" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", +] + +[[package]] +name = "gio" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cd10f9415cce39b53f8024bf39a21f84f8157afa52da53837b102e585a296a5" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "lazy_static", + "libc", +] + +[[package]] +name = "gio-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fad225242b9eae7ec8a063bb86974aca56885014672375e5775dc0ea3533911" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "glib" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40fb573a09841b6386ddf15fd4bc6655b4f5b106ca962f57ecaecde32a0061c0" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "glib-sys", + "gobject-sys", + "lazy_static", + "libc", +] + +[[package]] +name = "glib-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95856f3802f446c05feffa5e24859fe6a183a7cb849c8449afc35c86b1e316e2" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "gobject-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d1a804f62034eccf370006ccaef3708a71c31d561fee88564abe71177553d9" +dependencies = [ + "glib-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "gtk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e1e8d70290239c668594002d1b174fcc7d7ef5d26670ee141490ede8facf8f" +dependencies = [ + "atk", + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "cc", + "gdk", + "gdk-pixbuf", + "gdk-pixbuf-sys", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk-sys", + "lazy_static", + "libc", + "pango", + "pango-sys", +] + +[[package]] +name = "gtk-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53def660c7b48b00b510c81ef2d2fbd3c570f1527081d8d7947f471513e1a4c1" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "pango" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c6b728f1be8edb5f9f981420b651d5ea30bdb9de89f1f1262d0084a020577" +dependencies = [ + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "lazy_static", + "libc", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b93d84907b3cf0819bff8f13598ba72843bee579d5ebc2502e4b0367b4be7d" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", +] + +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" + +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" + +[[package]] +name = "proc-macro2" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "syn" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "vte-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "997bd7569d74e21d943ae4bb76ee6e4865f142fbbd45cf9a9a6a248034c9a208" +dependencies = [ + "bitflags", + "gdk", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk", + "gtk-sys", + "libc", + "pango", + "vte-sys", +] + +[[package]] +name = "vte-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "694c17dcf0b6f6f281fde66911c4450b2f7ccc3c26a90077192189e047d6a544" +dependencies = [ + "atk-sys", + "bitflags", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk-sys", + "libc", + "pango-sys", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f234fc8 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "cacca" +version = "0.1.0" +authors = ["Pietro Brenna "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +vte-rs = "*" +gio = "*" +gtk = "*" +gdk-sys="*" +gdk = "*" +pango = "*" +crossbeam-channel="*" +glib = "*" + +[[bin]] +name = "cacca" +path = "src/main.rs" + +[[bin]] +name = "wake" +path = "src/wake.rs" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..003b9ff --- /dev/null +++ b/src/main.rs @@ -0,0 +1,106 @@ +extern crate gio; +extern crate gtk; +extern crate vte; + +use gio::prelude::*; +use gtk::prelude::*; +use vte::TerminalExt; + +use gtk::SettingsExt; +use std::env::args; +use std::sync::{Arc, RwLock}; +use std::thread; +use glib::translate::{ToGlibPtr, ToGlib}; + +mod menu; +mod stato_finestra; +mod wake_listener; + +fn build_ui(application: >k::Application) { + let window = gtk::ApplicationWindow::new(application); + if let Some(settings) = window.get_settings() { + settings.set_property_gtk_enable_animations(false); + } + + window.set_title("First GTK+ Program"); + window.set_border_width(0); + window.move_(0, 0); + window.set_default_size(1920, 500); + window.set_decorated(false); + + window.set_can_focus(true); + window.set_keep_above(true); + //gtk::Window::set_interactive_debugging(true); + let vte = vte::Terminal::new(); + let accel_group = gtk::AccelGroup::new(); + let (key,modifier) = gtk::accelerator_parse("c"); + vte.add_accelerator("copy-clipboard", &accel_group, key, modifier, gtk::AccelFlags::VISIBLE); + window.add_accel_group(&accel_group); + + let font = pango::FontDescription::from_string("Iosevka Regular 13"); + vte.set_font(Some(&font)); + let c = gio::Cancellable::get_current(); + let pid = vte + .spawn_sync( + vte::PtyFlags::DEFAULT, + None, + &[&std::path::PathBuf::from("/usr/bin/fish")], + &[], + glib::SpawnFlags::DEFAULT, + Some(&mut || {}), + c.as_ref(), + ) + .unwrap(); + vte.watch_child(pid); + let button = gtk::Button::new_with_label("Click me!"); + button.connect_clicked(|_asd| { + println!("ciao"); + }); + + window.add(&vte); + + window.set_skip_taskbar_hint(true); + window.set_skip_pager_hint(true); + window.show_all(); + unsafe { + gdk_sys::gdk_window_set_skip_pager_hint(window.get_window().unwrap().to_glib_none().0, true.to_glib()); + gdk_sys::gdk_window_set_skip_taskbar_hint(window.get_window().unwrap().to_glib_none().0, true.to_glib()); + } + let stato = Arc::new(RwLock::new(stato_finestra::StatoFinestra::Su)); + let stato1 = stato.clone(); + let stato2 = stato.clone(); + + let cloned_app = application.clone(); + vte.connect_child_exited(move |_a, status| { + println!("Child exited with status {}", status); + cloned_app.quit(); + }); + window.connect_focus_out_event(move |_widget, _b| stato_finestra::focus_out(&stato1)); + window.connect_focus_in_event(move |_widget, _b| stato_finestra::focus_in(&stato2)); + vte.connect_popup_menu(move |ref vte| menu::menu(vte, None)); + vte.connect_button_press_event(move |ref vte, ev| { + if ev.get_event_type() == gdk::EventType::ButtonPress && + ev.get_button() == gdk_sys::GDK_BUTTON_SECONDARY as u32 { + menu::menu(vte, Some(ev.get_button())); + } + gtk::Inhibit(false) + }); + let (tx, rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); + rx.attach(None, move |_cmd| { + stato_finestra::esegui_toggle(&window, &vte, &stato) + }); + thread::spawn(move || { + wake_listener::listener(&tx); + }); +} + +fn main() { + let application = + gtk::Application::new(Some("net.ddns.chiocciolo.waydrop"), Default::default()) + .expect("Initialization failed..."); + + application.connect_activate(|app| { + build_ui(app); + }); + application.run(&args().collect::>()); +} diff --git a/src/menu.rs b/src/menu.rs new file mode 100644 index 0000000..1f40283 --- /dev/null +++ b/src/menu.rs @@ -0,0 +1,33 @@ +use gdk::Atom; +use gtk::prelude::*; +use gtk::{Menu, MenuItemBuilder}; +use vte::TerminalExt; +pub fn menu(widget: &vte::Terminal, btn: Option) -> bool { + let clipboard = widget.get_clipboard(&Atom::intern("CLIPBOARD")); + let w1 = widget.clone(); + let w2 = widget.clone(); + let w3 = widget.clone(); + clipboard.request_text(move |_clipboard, maybe_str| { + let ctx_menu = Menu::new(); + let cpy = MenuItemBuilder::new() + .label("Copy") + .sensitive(w3.get_has_selection()) + .parent(&ctx_menu) + .build(); + let paste = MenuItemBuilder::new() + .label("Paste") + .sensitive(maybe_str.is_some() && maybe_str != Some("")) + .parent(&ctx_menu) + .build(); + cpy.connect_activate(move |_m| { + w1.copy_clipboard(); + }); + paste.connect_activate(move |_m| { + w2.paste_clipboard(); + }); + ctx_menu.show_all(); + ctx_menu.set_property_attach_widget(Some(&w3)); + ctx_menu.popup_easy(btn.unwrap_or(1), gtk::get_current_event_time()); + }); + true +} diff --git a/src/stato_finestra.rs b/src/stato_finestra.rs new file mode 100644 index 0000000..f986c01 --- /dev/null +++ b/src/stato_finestra.rs @@ -0,0 +1,73 @@ +#[derive(Eq, PartialEq, Debug)] +pub enum StatoFinestra { + Su, + TirandoSu, + Nascondendo, + Nascosta, + SuNonFocusata, +} +use gdk::WindowExt; +use gtk::prelude::*; +use std::sync::{Arc, RwLock}; + +pub fn esegui_toggle( + window: >k::ApplicationWindow, + vte: &impl glib::IsA, + stato: &Arc>, +) -> glib::source::Continue { + let ts = gtk::get_current_event_time(); + if let Ok(mut inner) = stato.write() { + match *inner { + StatoFinestra::Nascosta | StatoFinestra::Nascondendo => { + // Shameless copy from guake + *inner = StatoFinestra::TirandoSu; + window.present(); + window.deiconify(); + window.show(); + window.get_window().unwrap().focus(ts); + window.set_type_hint(gdk::WindowTypeHint::Dock); + window.set_type_hint(gdk::WindowTypeHint::Normal); + window.get_window().unwrap().focus(0); + window.set_focus(Some(vte)); + } + StatoFinestra::SuNonFocusata => { + window.hide(); + window.show(); + window.get_window().unwrap().focus(ts); + window.get_window().unwrap().focus(0); + window.set_focus(Some(vte)); + *inner = StatoFinestra::Su; + } + StatoFinestra::Su => { + *inner = StatoFinestra::Nascondendo; + window.hide(); + } + _ => {} + } + } else { + eprintln!("Can't acquire lock!"); + } + println!("Stato: {:?}", stato); + glib::Continue(true) +} + +pub fn focus_out(stato: &Arc>) -> gtk::Inhibit { + if let Ok(mut inner) = stato.write() { + if *inner == StatoFinestra::Nascondendo { + *inner = StatoFinestra::Nascosta; + } else { + *inner = StatoFinestra::SuNonFocusata; + //widget.unstick(); + } + } + println!("Stato: {:?}", stato); + gtk::Inhibit(false) +} + +pub fn focus_in(stato: &Arc>) -> gtk::Inhibit { + if let Ok(mut inner) = stato.write() { + *inner = StatoFinestra::Su; + } + println!("Stato: {:?}", stato); + gtk::Inhibit(false) +} diff --git a/src/wake.rs b/src/wake.rs new file mode 100644 index 0000000..b1da613 --- /dev/null +++ b/src/wake.rs @@ -0,0 +1,7 @@ +use std::os::unix::net::UnixStream; +use std::io::prelude::*; +fn main() -> std::io::Result<()>{ + let mut s = UnixStream::connect("/tmp/waydrop.sock")?; + s.write_all(b"t")?; + Ok(()) +} \ No newline at end of file diff --git a/src/wake_listener.rs b/src/wake_listener.rs new file mode 100644 index 0000000..af2582f --- /dev/null +++ b/src/wake_listener.rs @@ -0,0 +1,24 @@ +use glib::Sender; +use gtk::get_current_event_time; + +pub fn listener(tx: &Sender) { + use std::io::Read; + use std::os::unix::net::UnixListener; + let _a = std::fs::remove_file("/tmp/waydrop.sock"); + let sock = UnixListener::bind("/tmp/waydrop.sock").unwrap(); + for stream in sock.incoming() { + match stream { + Ok(mut stream) => { + let mut buf = [0u8]; + if let Ok(_n) = stream.read_exact(&mut buf) { + let _s = String::from_utf8_lossy(&buf).into_owned(); + tx.send(get_current_event_time()).expect("can't send"); + } + } + Err(err) => { + eprintln!("{:?}", err); + } + } + } + +} \ No newline at end of file