Remove warnings and add espanso version to logs
This commit is contained in:
parent
14268b1bc7
commit
8e6c536673
|
@ -17,8 +17,6 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::process::{Command, Stdio};
|
||||
use std::io::{Write};
|
||||
use widestring::U16CString;
|
||||
use crate::bridge::windows::{set_clipboard, get_clipboard};
|
||||
|
||||
|
|
|
@ -22,27 +22,22 @@ use crate::bridge::windows::*;
|
|||
use crate::event::{Event, KeyEvent, KeyModifier, ActionType};
|
||||
use crate::event::KeyModifier::*;
|
||||
use std::ffi::c_void;
|
||||
use std::fs::create_dir_all;
|
||||
use std::{fs, thread, time};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{fs};
|
||||
use widestring::U16CString;
|
||||
use log::{info, debug, error};
|
||||
use log::{info};
|
||||
|
||||
const BMP_BINARY : &'static [u8] = include_bytes!("../res/win/espanso.bmp");
|
||||
const ICO_BINARY : &'static [u8] = include_bytes!("../res/win/espanso.ico");
|
||||
|
||||
pub struct WindowsContext {
|
||||
send_channel: Sender<Event>,
|
||||
id: Arc<Mutex<i32>>
|
||||
}
|
||||
|
||||
impl WindowsContext {
|
||||
pub fn new(send_channel: Sender<Event>) -> Box<WindowsContext> {
|
||||
// Initialize image resources
|
||||
|
||||
let data_dir = dirs::data_dir().expect("Can't obtain data_dir(), terminating.");
|
||||
let espanso_dir = data_dir.join("espanso");
|
||||
let res = create_dir_all(&espanso_dir);
|
||||
let espanso_dir = super::get_data_dir();
|
||||
|
||||
info!("Initializing Espanso resources in {}", espanso_dir.as_path().display());
|
||||
|
||||
|
@ -69,12 +64,10 @@ impl WindowsContext {
|
|||
let bmp_icon = espanso_bmp_image.to_str().unwrap_or_default();
|
||||
let ico_icon = espanso_ico_image.to_str().unwrap_or_default();
|
||||
|
||||
let id = Arc::new(Mutex::new(0));
|
||||
let send_channel = send_channel;
|
||||
|
||||
let context = Box::new(WindowsContext{
|
||||
send_channel,
|
||||
id
|
||||
});
|
||||
|
||||
unsafe {
|
||||
|
|
|
@ -48,9 +48,6 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
|||
pub fn new(keyboard_manager: &'a S, clipboard_manager: &'a C,
|
||||
config_manager: &'a M, ui_manager: &'a U,
|
||||
extensions: Vec<Box<dyn Extension>>) -> Engine<'a, S, C, M, U> {
|
||||
clipboard_manager.set_clipboard("nicetomeetyou");
|
||||
println!("{}", clipboard_manager.get_clipboard().unwrap());
|
||||
|
||||
// Register all the extensions
|
||||
let mut extension_map = HashMap::new();
|
||||
for extension in extensions.into_iter() {
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::os::raw::{c_void};
|
||||
use widestring::{U16CString};
|
||||
use crate::bridge::windows::*;
|
||||
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -30,7 +30,7 @@ use std::time::Duration;
|
|||
|
||||
use clap::{App, Arg, SubCommand, ArgMatches};
|
||||
use fs2::FileExt;
|
||||
use log::{error, info, warn, LevelFilter};
|
||||
use log::{info, warn, LevelFilter};
|
||||
use simplelog::{CombinedLogger, SharedLogger, TerminalMode, TermLogger, WriteLogger};
|
||||
|
||||
use crate::config::ConfigSet;
|
||||
|
@ -226,6 +226,7 @@ fn daemon_main(config_set: ConfigSet) {
|
|||
// Activate logging for panics
|
||||
log_panics::init();
|
||||
|
||||
info!("espanso version {}", VERSION);
|
||||
info!("starting daemon...");
|
||||
|
||||
let (send_channel, receive_channel) = mpsc::channel();
|
||||
|
@ -289,11 +290,11 @@ fn start_main(config_set: ConfigSet) {
|
|||
|
||||
precheck_guard();
|
||||
|
||||
detach_daemon();
|
||||
detach_daemon(config_set);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn detach_daemon() {
|
||||
fn detach_daemon(_: ConfigSet) {
|
||||
unsafe {
|
||||
let res = bridge::windows::start_daemon_process();
|
||||
if res < 0 {
|
||||
|
@ -303,11 +304,11 @@ fn detach_daemon() {
|
|||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn detach_daemon() {
|
||||
fn detach_daemon(config_set: ConfigSet) {
|
||||
unsafe {
|
||||
let pid = libc::fork();
|
||||
if pid < 0 {
|
||||
error!("Unable to fork.");
|
||||
println!("Unable to fork.");
|
||||
exit(4);
|
||||
}
|
||||
if pid > 0 { // Parent process exit
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::io::{BufReader, Read};
|
||||
use std::io::Write;
|
||||
use log::{info, error, warn};
|
||||
use log::{info};
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::net::{TcpListener, TcpStream, SocketAddr};
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
use super::IPCCommand;
|
||||
|
||||
use crate::context;
|
||||
use crate::event::*;
|
||||
use crate::protocol::{process_event, send_command};
|
||||
use crate::config::ConfigSet;
|
||||
|
|
|
@ -17,20 +17,14 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::process::Command;
|
||||
use crate::bridge::windows::{show_notification, close_notification, WindowsMenuItem, show_context_menu};
|
||||
use widestring::U16CString;
|
||||
use std::{fs, thread, time};
|
||||
use log::{info, debug};
|
||||
use std::{thread, time};
|
||||
use log::{debug};
|
||||
use std::sync::Mutex;
|
||||
use std::sync::Arc;
|
||||
use std::fs::create_dir_all;
|
||||
use std::os::raw::c_void;
|
||||
use crate::ui::{MenuItem, MenuItemType};
|
||||
|
||||
const BMP_BINARY : &'static [u8] = include_bytes!("../res/win/espanso.bmp");
|
||||
const ICO_BINARY : &'static [u8] = include_bytes!("../res/win/espanso.ico");
|
||||
|
||||
pub struct WindowsUIManager {
|
||||
id: Arc<Mutex<i32>>
|
||||
}
|
||||
|
@ -45,8 +39,8 @@ impl super::UIManager for WindowsUIManager {
|
|||
|
||||
// Setup a timeout to close the notification
|
||||
let id = Arc::clone(&self.id);
|
||||
thread::Builder::new().name("notification_thread".to_string()).spawn(move || {
|
||||
for i in 1..10 {
|
||||
let _ = thread::Builder::new().name("notification_thread".to_string()).spawn(move || {
|
||||
for _ in 1..10 {
|
||||
let duration = time::Duration::from_millis(200);
|
||||
thread::sleep(duration);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user