diff --git a/src/app.rs b/src/app.rs index d9da9ea..e7c7db0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -15,7 +15,6 @@ use iced::{ }, window::{self, Id, Settings}, }; -use std::path::Path; #[cfg(target_os = "macos")] use crate::macos::{focus_this_app, transform_process_to_ui_element}; @@ -146,9 +145,6 @@ pub fn default_settings() -> Settings { } } -#[derive(Debug, Clone)] -pub struct Temp {} - #[derive(Debug, Clone)] pub struct Tile { theme: iced::Theme, @@ -170,7 +166,7 @@ pub struct Tile { impl Tile { /// A base window pub fn new(keybind_id: u32, config: &Config) -> (Self, Task) { - let mut settings = default_settings(); + let settings = default_settings(); #[cfg(target_os = "windows")] { // get normal settings and modify position diff --git a/src/utils.rs b/src/utils.rs index b7cb5bb..7390751 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,9 +5,8 @@ use std::{ process::exit, }; -use crate::app::{DEFAULT_WINDOW_HEIGHT, WINDOW_WIDTH}; use global_hotkey::hotkey::Code; -use iced::{futures::io::Window, widget::image::Handle}; +use iced::widget::image::Handle; use icns::IconFamily; use image::RgbaImage; use rayon::iter::{IntoParallelIterator, ParallelIterator}; @@ -300,29 +299,26 @@ pub fn to_key_code(key_str: &str) -> Option { } pub fn get_config_installation_dir() -> String { - let path = if cfg!(target_os = "windows") { + if cfg!(target_os = "windows") { std::env::var("LOCALAPPDATA").unwrap() } else { std::env::var("HOME").unwrap() - }; - - return path; + } } pub fn get_config_file_path() -> String { let home = get_config_installation_dir(); - let file_path = if cfg!(target_os = "windows") { + + if cfg!(target_os = "windows") { home + "\\rustcast\\config.toml" } else { home + "/.config/rustcast/config.toml" - }; - - return file_path; + } } use crate::config::Config; pub fn read_config_file(file_path: &str) -> Result { - let config: Config = match std::fs::read_to_string(&file_path) { + let config: Config = match std::fs::read_to_string(file_path) { Ok(a) => toml::from_str(&a).unwrap(), Err(_) => Config::default(), }; @@ -335,10 +331,10 @@ pub fn create_config_file_if_not_exists( config: &Config, ) -> Result<(), std::io::Error> { // check if file exists - if let Ok(exists) = std::fs::metadata(&file_path) { - if exists.is_file() { - return Ok(()); - } + if let Ok(exists) = std::fs::metadata(file_path) + && exists.is_file() + { + return Ok(()); } let path = Path::new(&file_path); @@ -347,7 +343,7 @@ pub fn create_config_file_if_not_exists( } std::fs::write( - &file_path, + file_path, toml::to_string(&config).unwrap_or_else(|x| x.to_string()), ) .unwrap(); @@ -355,7 +351,7 @@ pub fn create_config_file_if_not_exists( Ok(()) } -pub fn open_application(path: &String) { +pub fn open_application(path: &str) { #[cfg(target_os = "windows")] { use std::process::Command;