Commands fixes + New commands
BIN
src-tauri/app-icon.png
Normal file
|
After Width: | Height: | Size: 406 KiB |
|
|
@ -8,6 +8,4 @@ RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\comm
|
||||||
StringGetPos, pos, BrowserFullCommand, ",,1
|
StringGetPos, pos, BrowserFullCommand, ",,1
|
||||||
pos := --pos
|
pos := --pos
|
||||||
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
|
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
|
||||||
Run, % BrowserPathandEXE
|
Run, % BrowserPathandEXE
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,4 +3,9 @@
|
||||||
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
|
||||||
Run C:/Program Files (x86)/Google/Chrome/Application/chrome.exe "https://google.com"
|
#Include _include.ahk
|
||||||
|
|
||||||
|
args = %1%
|
||||||
|
path := DefaultBrowser()
|
||||||
|
|
||||||
|
Run, %path% %args%
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
|
|
||||||
; #Warn ; Enable warnings to assist with detecting common errors.
|
|
||||||
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
|
||||||
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
|
||||||
|
|
||||||
Run C:/Program Files (x86)/Google/Chrome/Application/chrome.exe "https://youtube.com"
|
|
||||||
19
src-tauri/commands/browser/ahk/_include.ahk
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
DefaultBrowser() {
|
||||||
|
; Find the Registry key name for the default browser
|
||||||
|
RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
|
||||||
|
|
||||||
|
; Find the executable command associated with the above Registry key
|
||||||
|
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
|
||||||
|
|
||||||
|
; The above RegRead will return the path and executable name of the brower contained within quotes and optional parameters
|
||||||
|
; We only want the text contained inside the first set of quotes which is the path and executable
|
||||||
|
; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
|
||||||
|
StringGetPos, pos, BrowserFullCommand, ",,1
|
||||||
|
|
||||||
|
; Decrement the found position by one to work correctly with the StringMid function
|
||||||
|
pos := --pos
|
||||||
|
|
||||||
|
; Extract and return the path and executable of the browser
|
||||||
|
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
|
||||||
|
Return BrowserPathandEXE
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,6 @@ list:
|
||||||
- command:
|
- command:
|
||||||
action: ahk
|
action: ahk
|
||||||
exe_path: ahk/Run browser.exe
|
exe_path: ahk/Run browser.exe
|
||||||
exe_args:
|
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- ok1
|
- ok1
|
||||||
|
|
@ -11,13 +10,14 @@ list:
|
||||||
phrases:
|
phrases:
|
||||||
- открой браузер
|
- открой браузер
|
||||||
- запусти браузер
|
- запусти браузер
|
||||||
- открой гугл хром
|
- открой хром
|
||||||
- гугл хром
|
- гугл хром
|
||||||
|
|
||||||
- command:
|
- command:
|
||||||
action: ahk
|
action: ahk
|
||||||
exe_path: ahk/Run google.exe
|
exe_path: ahk/Run website.exe
|
||||||
exe_args:
|
exe_args:
|
||||||
|
- http://google.com
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- ok1
|
- ok1
|
||||||
|
|
@ -26,14 +26,14 @@ list:
|
||||||
- ok4
|
- ok4
|
||||||
phrases:
|
phrases:
|
||||||
- открой гугл
|
- открой гугл
|
||||||
- гугл
|
|
||||||
- запусти гугл
|
- запусти гугл
|
||||||
- перейди в гугл
|
- перейди в гугл
|
||||||
|
|
||||||
- command:
|
- command:
|
||||||
action: ahk
|
action: ahk
|
||||||
exe_path: ahk/Run youtube.exe
|
exe_path: ahk/Run website.exe
|
||||||
exe_args:
|
exe_args:
|
||||||
|
- http://youtube.com
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- ok1
|
- ok1
|
||||||
|
|
@ -43,4 +43,20 @@ list:
|
||||||
phrases:
|
phrases:
|
||||||
- открой ютуб
|
- открой ютуб
|
||||||
- ютуб
|
- ютуб
|
||||||
- запусти ютуб
|
- запусти ютуб
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Run website.exe
|
||||||
|
exe_args:
|
||||||
|
- https://translate.google.com
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
- ok4
|
||||||
|
phrases:
|
||||||
|
- открой переводчик
|
||||||
|
- переводчик
|
||||||
|
- запусти переводчик
|
||||||
31
src-tauri/commands/calculator/command.yaml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
list:
|
||||||
|
- command:
|
||||||
|
action: cli
|
||||||
|
cli_cmd: calc
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- открой калькулятор
|
||||||
|
- покажи калькулятор
|
||||||
|
- запусти калькулятор
|
||||||
|
- калькулятор
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: cli
|
||||||
|
cli_cmd: taskkill
|
||||||
|
cli_args:
|
||||||
|
- /f
|
||||||
|
- /im
|
||||||
|
- CalculatorApp.exe
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- закрой калькулятор
|
||||||
|
- отключи калькулятор
|
||||||
|
- выключи калькулятор
|
||||||
7
src-tauri/commands/jarvis/ahk/reboot.ahk
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
WinKill, AHK_exe jarvis-app.exe
|
||||||
|
Process, Close, jarvis-app.exe
|
||||||
|
sleep 3000
|
||||||
|
Run shell:AppsFolder\com.priler.jarvis
|
||||||
|
sleep 2000
|
||||||
|
WinMinimize jarvis-app
|
||||||
|
WinMinimize Jarvis Voice Assistant
|
||||||
BIN
src-tauri/commands/jarvis/ahk/reboot.exe
Normal file
|
|
@ -1,8 +1,46 @@
|
||||||
list:
|
list:
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/reboot.exe
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- перезагрузись
|
||||||
|
- перезагрузи себя
|
||||||
|
- выполни перезагрузку
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: voice
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- stupid
|
||||||
|
phrases:
|
||||||
|
- ты дурак
|
||||||
|
- ты дебил
|
||||||
|
- ты глупый
|
||||||
|
- ты тупой
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: voice
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- thanks
|
||||||
|
phrases:
|
||||||
|
- спасибо
|
||||||
|
- молодец
|
||||||
|
- респект
|
||||||
|
- ты супер
|
||||||
|
- отличная работа
|
||||||
|
- ты крут
|
||||||
|
- ты большой молодец
|
||||||
|
- ты реально крут
|
||||||
|
- ты афигенный
|
||||||
|
|
||||||
- command:
|
- command:
|
||||||
action: voice
|
action: voice
|
||||||
exe_path:
|
|
||||||
exe_args:
|
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- joke1
|
- joke1
|
||||||
|
|
@ -29,8 +67,6 @@ list:
|
||||||
|
|
||||||
- command:
|
- command:
|
||||||
action: voice
|
action: voice
|
||||||
exe_path:
|
|
||||||
exe_args:
|
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- thanks
|
- thanks
|
||||||
2
src-tauri/commands/steam/ahk/Close steam.ahk
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
WinKill, AHK_exe Steam.exe
|
||||||
|
Process, Close, Steam.exe
|
||||||
BIN
src-tauri/commands/steam/ahk/Close steam.exe
Normal file
4
src-tauri/commands/steam/ahk/Open steam.ahk
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
WinKill, AHK_exe Steam.exe
|
||||||
|
Process, Close, Steam.exe
|
||||||
|
|
||||||
|
Run, steam://open/bigpicture
|
||||||
BIN
src-tauri/commands/steam/ahk/Open steam.exe
Normal file
36
src-tauri/commands/steam/command.yaml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
list:
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Open steam.exe
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- game_mode
|
||||||
|
phrases:
|
||||||
|
- включи игровой режим
|
||||||
|
- перейди в игровой режим
|
||||||
|
- я хочу поиграть
|
||||||
|
- включи стим
|
||||||
|
- запусти стим
|
||||||
|
- открой стим
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Close steam.exe
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
- ok4
|
||||||
|
phrases:
|
||||||
|
- рабочий режим
|
||||||
|
- вернись в рабочий режим
|
||||||
|
- отключи игровой режим
|
||||||
|
- выйди из игрового режима
|
||||||
|
- выход с игрового режима
|
||||||
|
- рабочее пространство
|
||||||
|
- выключи игровой режим
|
||||||
|
- выключи стим
|
||||||
|
- отключи стим
|
||||||
|
- выйди из стима
|
||||||
|
- закрой стим
|
||||||
15
src-tauri/commands/stop/command.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
list:
|
||||||
|
- command:
|
||||||
|
action: stop_chaining
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- thanks
|
||||||
|
- ok1
|
||||||
|
phrases:
|
||||||
|
- всё
|
||||||
|
- хватит
|
||||||
|
- отмена
|
||||||
|
- не слушай
|
||||||
|
- перестань слушать
|
||||||
|
- отдыхай
|
||||||
|
- на этом всё
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
list:
|
|
||||||
- command:
|
|
||||||
action: voice
|
|
||||||
exe_path:
|
|
||||||
exe_args:
|
|
||||||
voice:
|
|
||||||
sounds:
|
|
||||||
- stupid
|
|
||||||
phrases:
|
|
||||||
- ты дурак
|
|
||||||
- ты дебил
|
|
||||||
- ты глупый
|
|
||||||
- ты тупой
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
list:
|
list:
|
||||||
- command:
|
- command:
|
||||||
action: terminate
|
action: terminate
|
||||||
exe_path:
|
|
||||||
exe_args:
|
|
||||||
voice:
|
voice:
|
||||||
sounds:
|
sounds:
|
||||||
- off
|
- off
|
||||||
phrases:
|
phrases:
|
||||||
- выключись
|
- выключись
|
||||||
- вырубись
|
- вырубись
|
||||||
- завершить работу
|
|
||||||
- закройся
|
- закройся
|
||||||
- отключись
|
- отключись
|
||||||
- заверши свою работу
|
- заверши свою работу
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
list:
|
|
||||||
- command:
|
|
||||||
action: voice
|
|
||||||
exe_path:
|
|
||||||
exe_args:
|
|
||||||
voice:
|
|
||||||
sounds:
|
|
||||||
- thanks
|
|
||||||
phrases:
|
|
||||||
- спасибо
|
|
||||||
- молодец
|
|
||||||
- респект
|
|
||||||
- ты супер
|
|
||||||
- отличная работа
|
|
||||||
- ты крут
|
|
||||||
- ты большой молодец
|
|
||||||
- ты реально крут
|
|
||||||
- ты афигенный
|
|
||||||
- ты отец
|
|
||||||
- вечно ты молодец
|
|
||||||
1
src-tauri/commands/volume/ahk/Set sound.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
SoundSet, %1%
|
||||||
1
src-tauri/commands/windows/ahk/Empty trash.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
FileRecycleEmpty,
|
||||||
BIN
src-tauri/commands/windows/ahk/Empty trash.exe
Normal file
1
src-tauri/commands/windows/ahk/Roll up windows.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
WinMinimizeAll
|
||||||
BIN
src-tauri/commands/windows/ahk/Roll up windows.exe
Normal file
1
src-tauri/commands/windows/ahk/Set language.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Send, {Shift down}{Alt}{Shift up}
|
||||||
BIN
src-tauri/commands/windows/ahk/Set language.exe
Normal file
1
src-tauri/commands/windows/ahk/Task manager open.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Run taskmgr.exe
|
||||||
BIN
src-tauri/commands/windows/ahk/Task manager open.exe
Normal file
1
src-tauri/commands/windows/ahk/blocking.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DllCall("LockWorkStation")
|
||||||
BIN
src-tauri/commands/windows/ahk/blocking.exe
Normal file
1
src-tauri/commands/windows/ahk/clipboard.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Send #v
|
||||||
BIN
src-tauri/commands/windows/ahk/clipboard.exe
Normal file
1
src-tauri/commands/windows/ahk/screenshot.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Send, #{PrintScreen}
|
||||||
BIN
src-tauri/commands/windows/ahk/screenshot.exe
Normal file
1
src-tauri/commands/windows/ahk/sleep.ahk
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 1, "int", 1)
|
||||||
BIN
src-tauri/commands/windows/ahk/sleep.exe
Normal file
124
src-tauri/commands/windows/command.yaml
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
list:
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Roll up windows.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- сверни все окна
|
||||||
|
- сверни окна
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Empty trash.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- очисти корзину
|
||||||
|
- почисти корзину
|
||||||
|
- очистка корзины
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Task manager open.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- запусти диспетчер задач
|
||||||
|
- открой диспетчер задач
|
||||||
|
- диспетчер задач
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/screenshot.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- сделай скриншот
|
||||||
|
- сделай снимок экрана
|
||||||
|
- сними экран
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/blocking.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
- ok4
|
||||||
|
phrases:
|
||||||
|
- заблокируй компьютер
|
||||||
|
- заблокируй комп
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/sleep.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
- ok4
|
||||||
|
phrases:
|
||||||
|
- спящий режим
|
||||||
|
- ждущий режим
|
||||||
|
- иди поспи
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/clipboard.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- открой буфер обмена
|
||||||
|
- покажи буфер обмена
|
||||||
|
- запусти буфер обмена
|
||||||
|
- буфер обмена
|
||||||
|
|
||||||
|
- command:
|
||||||
|
action: ahk
|
||||||
|
exe_path: ahk/Set language.exe
|
||||||
|
exe_args:
|
||||||
|
voice:
|
||||||
|
sounds:
|
||||||
|
- ok1
|
||||||
|
- ok2
|
||||||
|
- ok3
|
||||||
|
phrases:
|
||||||
|
- смени раскладку
|
||||||
|
- поменяй раскладку
|
||||||
|
- смени язык
|
||||||
|
- поменяй язык
|
||||||
|
- переключи на русский
|
||||||
|
- переключи на английский
|
||||||
|
- смени раскладку на русскую
|
||||||
|
- поменяй раскладку на русскую
|
||||||
|
- поменяй раскладку на английскую
|
||||||
|
- смени раскладку на английскую
|
||||||
|
- смени язык на русский
|
||||||
|
- поменяй язык на русский
|
||||||
|
- смени язык на английский
|
||||||
|
- поменяй язык на английский
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 151 KiB |
|
|
@ -7,8 +7,7 @@ use log::{info, warn, error};
|
||||||
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Child;
|
use std::process::{Command, Child};
|
||||||
use std::process::Command;
|
|
||||||
// use tauri::Manager;
|
// use tauri::Manager;
|
||||||
|
|
||||||
mod structs;
|
mod structs;
|
||||||
|
|
@ -34,14 +33,16 @@ pub fn parse_commands() -> Result<Vec<AssistantCommand>, String> {
|
||||||
let cc_yaml: CommandsList;
|
let cc_yaml: CommandsList;
|
||||||
|
|
||||||
// try parse command.yaml
|
// try parse command.yaml
|
||||||
if let Ok(parse_result) = serde_yaml::from_reader::<File, CommandsList>(cc_reader) {
|
match serde_yaml::from_reader::<File, CommandsList>(cc_reader) {
|
||||||
cc_yaml = parse_result;
|
Ok(parse_result) => {
|
||||||
} else {
|
cc_yaml = parse_result;
|
||||||
warn!("Can't parse {}, skipping ...", &cc_file.display());
|
},
|
||||||
continue;
|
Err(msg) => {
|
||||||
// return Err(format!("Can't parse {}", &cc_file.display()));
|
warn!("Can't parse {}, skipping ...\nCommand parse error is: {:?}", &cc_file.display(), msg);
|
||||||
|
eprintln!("Can't parse {}, skipping ...\nCommand parse error is: {:?}", &cc_file.display(), msg);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything seems to be Ok
|
// everything seems to be Ok
|
||||||
commands.push(AssistantCommand {
|
commands.push(AssistantCommand {
|
||||||
path: _cpath,
|
path: _cpath,
|
||||||
|
|
@ -109,11 +110,30 @@ pub fn execute_exe(exe: &str, args: &Vec<String>) -> std::io::Result<Child> {
|
||||||
Command::new(exe).args(args).spawn()
|
Command::new(exe).args(args).spawn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn execute_cli(cmd: &str, args: &Vec<String>) -> std::io::Result<Child> {
|
||||||
|
|
||||||
|
println!("Spawning cmd as: cmd /C {} {:?}", cmd, args);
|
||||||
|
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new("cmd")
|
||||||
|
.arg("/C")
|
||||||
|
.arg(cmd)
|
||||||
|
.args(args)
|
||||||
|
.spawn()
|
||||||
|
} else {
|
||||||
|
Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(cmd)
|
||||||
|
.args(args)
|
||||||
|
.spawn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn execute_command(
|
pub fn execute_command(
|
||||||
cmd_path: &PathBuf,
|
cmd_path: &PathBuf,
|
||||||
cmd_config: &Config,
|
cmd_config: &Config,
|
||||||
app_handle: &tauri::AppHandle,
|
app_handle: &tauri::AppHandle,
|
||||||
) -> Result<(), String> {
|
) -> Result<bool, String> {
|
||||||
match cmd_config.command.action.as_str() {
|
match cmd_config.command.action.as_str() {
|
||||||
"voice" => {
|
"voice" => {
|
||||||
// VOICE command type
|
// VOICE command type
|
||||||
|
|
@ -124,7 +144,7 @@ pub fn execute_command(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
events::play(random_cmd_sound, app_handle);
|
events::play(random_cmd_sound, app_handle);
|
||||||
|
|
||||||
Ok(())
|
Ok(true)
|
||||||
}
|
}
|
||||||
"ahk" => {
|
"ahk" => {
|
||||||
// AutoHotkey command type
|
// AutoHotkey command type
|
||||||
|
|
@ -146,7 +166,7 @@ pub fn execute_command(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
events::play(random_cmd_sound, app_handle);
|
events::play(random_cmd_sound, app_handle);
|
||||||
|
|
||||||
Ok(())
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
error!("AHK process spawn error (does exe path is valid?)");
|
error!("AHK process spawn error (does exe path is valid?)");
|
||||||
Err("AHK process spawn error (does exe path is valid?)".into())
|
Err("AHK process spawn error (does exe path is valid?)".into())
|
||||||
|
|
@ -154,28 +174,26 @@ pub fn execute_command(
|
||||||
}
|
}
|
||||||
"cli" => {
|
"cli" => {
|
||||||
// CLI command type
|
// CLI command type
|
||||||
let exe_path_absolute = Path::new(&cmd_config.command.exe_path);
|
let cli_cmd = &cmd_config.command.cli_cmd;
|
||||||
let exe_path_local = Path::new(&cmd_path).join(&cmd_config.command.exe_path);
|
|
||||||
|
|
||||||
if let Ok(_) = execute_exe(
|
match execute_cli(
|
||||||
if exe_path_absolute.exists() {
|
cli_cmd,
|
||||||
exe_path_absolute.to_str().unwrap()
|
&cmd_config.command.cli_args,
|
||||||
} else {
|
|
||||||
exe_path_local.to_str().unwrap()
|
|
||||||
},
|
|
||||||
&cmd_config.command.exe_args,
|
|
||||||
) {
|
) {
|
||||||
let random_cmd_sound = cmd_config
|
Ok(_) => {
|
||||||
.voice
|
let random_cmd_sound = cmd_config
|
||||||
.sounds
|
.voice
|
||||||
.choose(&mut rand::thread_rng())
|
.sounds
|
||||||
.unwrap();
|
.choose(&mut rand::thread_rng())
|
||||||
events::play(random_cmd_sound, app_handle);
|
.unwrap();
|
||||||
|
events::play(random_cmd_sound, app_handle);
|
||||||
|
|
||||||
Ok(())
|
Ok(true)
|
||||||
} else {
|
},
|
||||||
error!("Shell process spawn error (does cli command is valid?)");
|
Err(msg) => {
|
||||||
Err("Shell process spawn error (does cli command is valid?)".into())
|
error!("CLI command error ({})", msg);
|
||||||
|
Err(format!("Shell command error ({})", msg).into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"terminate" => {
|
"terminate" => {
|
||||||
|
|
@ -190,6 +208,17 @@ pub fn execute_command(
|
||||||
std::thread::sleep(Duration::from_secs(2));
|
std::thread::sleep(Duration::from_secs(2));
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
"stop_chaining" => {
|
||||||
|
// STOP_CHAINING command type
|
||||||
|
let random_cmd_sound = cmd_config
|
||||||
|
.voice
|
||||||
|
.sounds
|
||||||
|
.choose(&mut rand::thread_rng())
|
||||||
|
.unwrap();
|
||||||
|
events::play(random_cmd_sound, app_handle);
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
error!("Command type unknown");
|
error!("Command type unknown");
|
||||||
Err("Command type unknown".into())
|
Err("Command type unknown".into())
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,32 @@ pub struct CommandsList {
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub command: ConfigCommandSection,
|
pub command: ConfigCommandSection,
|
||||||
|
|
||||||
pub voice: ConfigVoiceSection,
|
pub voice: ConfigVoiceSection,
|
||||||
|
|
||||||
pub phrases: Vec<String>,
|
pub phrases: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct ConfigCommandSection {
|
pub struct ConfigCommandSection {
|
||||||
pub action: String,
|
pub action: String,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
pub exe_path: String,
|
pub exe_path: String,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
pub exe_args: Vec<String>,
|
pub exe_args: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub cli_cmd: String,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub cli_args: Vec<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct ConfigVoiceSection {
|
pub struct ConfigVoiceSection {
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
pub sounds: Vec<String>,
|
pub sounds: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ pub const AUTHOR_NAME: Option<&str> = option_env!("CARGO_PKG_AUTHORS");
|
||||||
pub const REPOSITORY_LINK: Option<&str> = option_env!("CARGO_PKG_REPOSITORY");
|
pub const REPOSITORY_LINK: Option<&str> = option_env!("CARGO_PKG_REPOSITORY");
|
||||||
|
|
||||||
// RUSPOTTER
|
// RUSPOTTER
|
||||||
pub const RUSPOTTER_MIN_SCORE: f32 = 0.64;
|
pub const RUSPOTTER_MIN_SCORE: f32 = 0.62;
|
||||||
|
|
||||||
// PICOVOICE
|
// PICOVOICE
|
||||||
pub const COMMANDS_PATH: &str = "commands/";
|
pub const COMMANDS_PATH: &str = "commands/";
|
||||||
|
|
|
||||||
|
|
@ -111,17 +111,6 @@ pub fn stop_recording() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn update_selected_microphone_index() -> i32 {
|
|
||||||
// let selected_microphone: i32 = get_selected_microphone_index();
|
|
||||||
|
|
||||||
// // store current microphone idx
|
|
||||||
// SELECTED_MICROPHONE_IDX.store(selected_microphone, Ordering::SeqCst);
|
|
||||||
|
|
||||||
// // return microphone index
|
|
||||||
// info!("Selected microphone index = {selected_microphone}");
|
|
||||||
// selected_microphone
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn get_selected_microphone_index() -> i32 {
|
pub fn get_selected_microphone_index() -> i32 {
|
||||||
let selected_microphone: i32;
|
let selected_microphone: i32;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use porcupine::{Porcupine, PorcupineBuilder};
|
use porcupine::{Porcupine, PorcupineBuilder};
|
||||||
|
use std::ops::Sub;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use log::{info, warn, error};
|
use log::{info, warn, error};
|
||||||
|
|
@ -149,9 +150,17 @@ fn keyword_callback(_keyword_index: i32) {
|
||||||
);
|
);
|
||||||
|
|
||||||
match cmd_result {
|
match cmd_result {
|
||||||
Ok(_) => {
|
Ok(chain) => {
|
||||||
println!("Command executed successfully!");
|
println!("Command executed successfully!");
|
||||||
start = SystemTime::now(); // listen for more commands
|
|
||||||
|
if chain {
|
||||||
|
// continue chaining commands
|
||||||
|
start = SystemTime::now(); // listen for more commands
|
||||||
|
} else {
|
||||||
|
// skip forward if chaining is not required
|
||||||
|
start = start.checked_sub(core::time::Duration::from_secs(1000)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Err(error_message) => {
|
Err(error_message) => {
|
||||||
|
|
@ -317,7 +326,7 @@ fn rustpotter_init() -> Result<bool, String> {
|
||||||
avg_threshold: 0.,
|
avg_threshold: 0.,
|
||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
min_scores: 15,
|
min_scores: 15,
|
||||||
score_mode: ScoreMode::Max,
|
score_mode: ScoreMode::Average,
|
||||||
comparator_band_size: 5,
|
comparator_band_size: 5,
|
||||||
comparator_ref: 0.22
|
comparator_ref: 0.22
|
||||||
},
|
},
|
||||||
|
|
@ -325,7 +334,7 @@ fn rustpotter_init() -> Result<bool, String> {
|
||||||
gain_normalizer: GainNormalizationConfig {
|
gain_normalizer: GainNormalizationConfig {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
gain_ref: None,
|
gain_ref: None,
|
||||||
min_gain: 0.5,
|
min_gain: 0.7,
|
||||||
max_gain: 1.0,
|
max_gain: 1.0,
|
||||||
},
|
},
|
||||||
band_pass: BandPassConfig {
|
band_pass: BandPassConfig {
|
||||||
|
|
|
||||||