mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-28 23:17:21 +02:00
feat(ahk): autoload config on start
When AutoHotKey is detected, and %USERPROFILE%\komorebi.ahk exists, komorebi.exe will now try to run the ahk script after starting the command listener. For this to work smoothly, it is important to set the #SingleInstance directive to Force in komorebi.ahk, which will ensure that duplicates of the script are not run, and a new version of the script is loaded without displaying a GUI confirmation prompt. resolve #3
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -363,6 +363,7 @@ dependencies = [
|
|||||||
"tracing-appender",
|
"tracing-appender",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"uds_windows",
|
"uds_windows",
|
||||||
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1060,6 +1061,17 @@ version = "0.10.2+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "4.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ by `komorebic`.
|
|||||||
|
|
||||||
You can similarly stop the process by running `komorebic stop`.
|
You can similarly stop the process by running `komorebic stop`.
|
||||||
|
|
||||||
|
If you have AutoHotKey installed and a `komorebi.ahk` file in your home directory (run `$Env:UserProfile` at a
|
||||||
|
PowerShell prompt to find your home directory), `komorebi` will automatically try to load it when starting.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
As previously mentioned, this project does not handle anything related to keybindings and shortcuts directly. I
|
As previously mentioned, this project does not handle anything related to keybindings and shortcuts directly. I
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#SingleInstance Force
|
||||||
|
|
||||||
; Enable focus follows mouse
|
; Enable focus follows mouse
|
||||||
Run, komorebic.exe focus-follows-mouse enable
|
Run, komorebic.exe focus-follows-mouse enable
|
||||||
|
|
||||||
|
|||||||
@@ -28,3 +28,4 @@ tracing = "0.1"
|
|||||||
tracing-appender = "0.1"
|
tracing-appender = "0.1"
|
||||||
tracing-subscriber = "0.2"
|
tracing-subscriber = "0.2"
|
||||||
uds_windows = "1"
|
uds_windows = "1"
|
||||||
|
which = "4"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||||
#![allow(clippy::missing_errors_doc)]
|
#![allow(clippy::missing_errors_doc)]
|
||||||
|
|
||||||
|
use std::process::Command;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ use sysinfo::SystemExt;
|
|||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
use which::which;
|
||||||
|
|
||||||
use crate::process_command::listen_for_commands;
|
use crate::process_command::listen_for_commands;
|
||||||
use crate::process_event::listen_for_events;
|
use crate::process_event::listen_for_events;
|
||||||
@@ -115,6 +117,16 @@ fn main() -> Result<()> {
|
|||||||
listen_for_commands(wm.clone());
|
listen_for_commands(wm.clone());
|
||||||
listen_for_events(wm.clone());
|
listen_for_events(wm.clone());
|
||||||
|
|
||||||
|
let home = dirs::home_dir().context("there is no home directory")?;
|
||||||
|
let mut config = home;
|
||||||
|
config.push("komorebi.ahk");
|
||||||
|
|
||||||
|
if config.exists() && which("autohotkey.exe").is_ok() {
|
||||||
|
Command::new("autohotkey.exe")
|
||||||
|
.arg(config.as_os_str())
|
||||||
|
.output()?;
|
||||||
|
}
|
||||||
|
|
||||||
let (ctrlc_sender, ctrlc_receiver) = crossbeam_channel::bounded(1);
|
let (ctrlc_sender, ctrlc_receiver) = crossbeam_channel::bounded(1);
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
ctrlc_sender
|
ctrlc_sender
|
||||||
|
|||||||
Reference in New Issue
Block a user