App window size lowered

Open logs button added
Better links handling
Multiple UI fixes/improvements
etc
This commit is contained in:
Abraham 2023-05-01 16:54:50 +05:00
parent fc764c0c85
commit 488f5c0786
23 changed files with 202 additions and 114 deletions

View file

@ -1,45 +0,0 @@
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
[tasks.clean]
command = "cargo"
args = ["clean"]
[tasks.build_debug]
command = "cargo"
args = ["build"]
[tasks.run]
command = "cargo"
args = ["run"]
[tasks.build_release]
command = "cargo"
args = ["build", "--release"]
dependencies = ["clean"]
[tasks.test]
command = "cargo"
args = ["test"]
# dependencies = ["clean"]
[tasks.vosk]
script_runner = "python"
script_extension = "py"
script = { file = "vosk_build.py" }
[tasks.debug]
dependencies = [
"format",
"build_debug",
"vosk"
]
[tasks.release]
dependencies = [
"format",
"build_release",
"vosk"
]

View file

@ -28,4 +28,5 @@ list:
phrases:
- закрой калькулятор
- отключи калькулятор
- выключи калькулятор
- выключи калькулятор
- убери калькулятор

View file

@ -1,3 +1,7 @@
use std::iter::Once;
use once_cell::sync::OnceCell;
// use const_concat::const_concat;
// pub const IS_DEV: bool = cfg!(debug_assertions);// cfg!(debug_assertions);
@ -22,6 +26,8 @@ pub const LOG_FILE_NAME: &str = "log.txt";
pub const APP_VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
pub const AUTHOR_NAME: Option<&str> = option_env!("CARGO_PKG_AUTHORS");
pub const REPOSITORY_LINK: Option<&str> = option_env!("CARGO_PKG_REPOSITORY");
pub const TG_OFFICIAL_LINK: Option<&str> = Some("https://t.me/howdyho_official");
pub const FEEDBACK_LINK: Option<&str> = Some("https://t.me/jarvis_feedback_bot");
// RUSPOTTER
pub const RUSPOTTER_MIN_SCORE: f32 = 0.62;
@ -38,10 +44,11 @@ pub const VOSK_MIN_RATIO: f64 = 70.0;
// ETC
pub const CMD_RATIO_THRESHOLD: f64 = 60f64;
pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(10);
pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(15);
pub const ASSISTANT_GREET_PHRASES: [&str; 3] = ["greet1", "greet2", "greet3"];
pub const ASSISTANT_PHRASES_TBR: [&str; 16] = [
pub const ASSISTANT_PHRASES_TBR: [&str; 17] = [
"джарвис",
"сэр",
"слушаю сэр",
"всегда к услугам",

View file

@ -78,7 +78,7 @@ fn main() {
// log to file
let log_file_path = format!("{}/{}", APP_LOG_DIR.lock().unwrap(), config::LOG_FILE_NAME);
println!("!!!===============!!!\nLOGGING TO {}\n!!!===============!!!\n", &log_file_path);
simple_logging::log_to_file(log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?");
simple_logging::log_to_file(&log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?");
Ok(())
})
@ -100,10 +100,15 @@ fn main() {
tauri_commands::get_cpu_usage,
// sound commands
tauri_commands::play_sound,
// fs commands
tauri_commands::show_in_folder,
// etc commands
tauri_commands::get_app_version,
tauri_commands::get_author_name,
tauri_commands::get_repository_link
tauri_commands::get_repository_link,
tauri_commands::get_tg_official_link,
tauri_commands::get_feedback_link,
tauri_commands::get_log_file_path
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View file

@ -18,6 +18,10 @@ pub use sys::*;
mod voice;
pub use voice::*;
// import FS commands
mod fs;
pub use fs::*;
// import ETC commands
mod etc;
pub use etc::*;

View file

@ -1,13 +1,12 @@
use crate::config::APP_VERSION;
use crate::config::AUTHOR_NAME;
use crate::config::REPOSITORY_LINK;
use crate::config;
use crate::APP_LOG_DIR;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
pub fn get_app_version() -> String {
if let Some(ver) = APP_VERSION {
ver.to_string()
if let Some(res) = config::APP_VERSION {
res.to_string()
} else {
String::from("error")
}
@ -15,8 +14,8 @@ pub fn get_app_version() -> String {
#[tauri::command]
pub fn get_author_name() -> String {
if let Some(ver) = AUTHOR_NAME {
ver.to_string()
if let Some(res) = config::AUTHOR_NAME {
res.to_string()
} else {
String::from("error")
}
@ -24,9 +23,32 @@ pub fn get_author_name() -> String {
#[tauri::command]
pub fn get_repository_link() -> String {
if let Some(ver) = REPOSITORY_LINK {
if let Some(res) = config::REPOSITORY_LINK {
res.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_tg_official_link() -> String {
if let Some(ver) = config::TG_OFFICIAL_LINK {
ver.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_feedback_link() -> String {
if let Some(res) = config::FEEDBACK_LINK {
res.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_log_file_path() -> String {
format!("{}", APP_LOG_DIR.lock().unwrap())
}

View file

@ -0,0 +1,47 @@
use std::process::Command;
// taken from https://github.com/tauri-apps/tauri/issues/4062#issuecomment-1338048169
#[tauri::command]
pub fn show_in_folder(path: String) {
#[cfg(target_os = "windows")]
{
Command::new("explorer")
.args(["/select,", &path]) // The comma after select is not a typo
.spawn()
.unwrap();
}
#[cfg(target_os = "linux")]
{
if path.contains(",") {
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
let new_path = match metadata(&path).unwrap().is_dir() {
true => path,
false => {
let mut path2 = PathBuf::from(path);
path2.pop();
path2.into_os_string().into_string().unwrap()
}
};
Command::new("xdg-open")
.arg(&new_path)
.spawn()
.unwrap();
} else {
Command::new("dbus-send")
.args(["--session", "--dest=org.freedesktop.FileManager1", "--type=method_call",
"/org/freedesktop/FileManager1", "org.freedesktop.FileManager1.ShowItems",
format!("array:string:\"file://{path}\"").as_str(), "string:\"\""])
.spawn()
.unwrap();
}
}
#[cfg(target_os = "macos")]
{
Command::new("open")
.args(["-R", &path])
.spawn()
.unwrap();
}
}

View file

@ -134,6 +134,7 @@ fn keyword_callback(_keyword_index: i32) {
for tbr in config::ASSISTANT_PHRASES_TBR {
test = test.replace(tbr, "");
}
test = test.trim().into();
// infer command
if let Some((cmd_path, cmd_config)) =

View file

@ -60,8 +60,8 @@
"fullscreen": false,
"resizable": false,
"title": "Jarvis Voice Assistant",
"width": 550,
"height": 820
"width": 500,
"height": 700
}
]
}

View file

@ -1,36 +0,0 @@
# Simple python script used to
# copy Vosk libraries to the "target" directory
# after Rust build
# Note that Rust build should be run via "cargo make <cmd>" command
# in order to automate all the compile process
import os
from pathlib import Path
import shutil
# some config vars
VOSK_LIBRARIES_PATH = "D:/Rust/vosk"
TARGET_DIRS = (
os.getcwd() + "/target/debug",
os.getcwd() + "/target/release"
)
for tdir in TARGET_DIRS:
if not Path(tdir).is_dir():
continue
vosk_lib_testfile = Path(tdir + "/libvosk.dll")
if vosk_lib_testfile.is_file():
# skip
print("[Vosk] library files already exist in " + tdir)
else:
# copy lib files
src_files = os.listdir(VOSK_LIBRARIES_PATH)
for file_name in src_files:
full_file_name = os.path.join(VOSK_LIBRARIES_PATH, file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, tdir)
print("[Vosk] library files was copied to " + tdir)