mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 01:58:51 +02:00
feat(cli): add check command for useful info
This commit adds a new komorebic command, check, to output useful information that will aid in understanding unexpected behaviour reported by users.
This commit is contained in:
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -32,6 +32,20 @@ OS Name: Microsoft Windows 11 Pro
|
|||||||
OS Version: 10.0.22000 N/A Build 22000
|
OS Version: 10.0.22000 N/A Build 22000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**`komorebic check` Output**
|
||||||
|
Provide the output of `komorebic check`
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\LGUG2Z
|
||||||
|
|
||||||
|
Looking for configuration files in C:\Users\LGUG2Z
|
||||||
|
|
||||||
|
No komorebi configuration found in C:\Users\LGUG2Z
|
||||||
|
|
||||||
|
If running 'komorebic start --await-configuration', you will manually have to call the following command to begin tiling: komorebic complete-configuration
|
||||||
|
```
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ use std::io::ErrorKind;
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
@@ -46,6 +48,7 @@ use komorebi_core::StateQuery;
|
|||||||
use komorebi_core::WindowKind;
|
use komorebi_core::WindowKind;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
static ref HAS_CUSTOM_CONFIG_HOME: AtomicBool = AtomicBool::new(false);
|
||||||
static ref HOME_DIR: PathBuf = {
|
static ref HOME_DIR: PathBuf = {
|
||||||
std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(
|
std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(
|
||||||
|_| dirs::home_dir().expect("there is no home directory"),
|
|_| dirs::home_dir().expect("there is no home directory"),
|
||||||
@@ -53,6 +56,7 @@ lazy_static! {
|
|||||||
let home = PathBuf::from(&home_path);
|
let home = PathBuf::from(&home_path);
|
||||||
|
|
||||||
if home.as_path().is_dir() {
|
if home.as_path().is_dir() {
|
||||||
|
HAS_CUSTOM_CONFIG_HOME.store(true, Ordering::SeqCst);
|
||||||
home
|
home
|
||||||
} else {
|
} else {
|
||||||
panic!(
|
panic!(
|
||||||
@@ -661,6 +665,8 @@ enum SubCommand {
|
|||||||
Start(Start),
|
Start(Start),
|
||||||
/// Stop the komorebi.exe process and restore all hidden windows
|
/// Stop the komorebi.exe process and restore all hidden windows
|
||||||
Stop,
|
Stop,
|
||||||
|
/// Output various important komorebi-related environment values
|
||||||
|
Check,
|
||||||
/// Show a JSON representation of the current window manager state
|
/// Show a JSON representation of the current window manager state
|
||||||
State,
|
State,
|
||||||
/// Query the current window manager state
|
/// Query the current window manager state
|
||||||
@@ -988,6 +994,45 @@ fn main() -> Result<()> {
|
|||||||
let opts: Opts = Opts::parse();
|
let opts: Opts = Opts::parse();
|
||||||
|
|
||||||
match opts.subcmd {
|
match opts.subcmd {
|
||||||
|
SubCommand::Check => {
|
||||||
|
let home = HOME_DIR.clone();
|
||||||
|
let home_lossy_string = home.to_string_lossy();
|
||||||
|
if HAS_CUSTOM_CONFIG_HOME.load(Ordering::SeqCst) {
|
||||||
|
println!("KOMOREBI_CONFIG_HOME detected: {home_lossy_string}\n");
|
||||||
|
} else {
|
||||||
|
println!(
|
||||||
|
"No KOMOREBI_CONFIG_HOME detected, defaulting to {}\n",
|
||||||
|
dirs::home_dir()
|
||||||
|
.expect("could not find home dir")
|
||||||
|
.to_string_lossy()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Looking for configuration files in {home_lossy_string}\n");
|
||||||
|
|
||||||
|
let mut config_pwsh = home.clone();
|
||||||
|
config_pwsh.push("komorebi.ps1");
|
||||||
|
|
||||||
|
let mut config_ahk = home.clone();
|
||||||
|
config_ahk.push("komorebi.ahk");
|
||||||
|
|
||||||
|
if config_pwsh.exists() {
|
||||||
|
println!("Found komorebi.ps1; this file will be autoloaded by komorebi\n");
|
||||||
|
let mut config_whkd = dirs::home_dir().expect("could not find home dir");
|
||||||
|
config_whkd.push(".config");
|
||||||
|
config_whkd.push("whkdrc");
|
||||||
|
if config_whkd.exists() {
|
||||||
|
println!("Found ~/.config/whkdrc; key bindings will be loaded from here when whkd is started\n");
|
||||||
|
} else {
|
||||||
|
println!("No ~/.config/whkdrc found; you may not be able to control komorebi with your keyboard\n");
|
||||||
|
}
|
||||||
|
} else if config_ahk.exists() {
|
||||||
|
println!("Found komorebi.ahk; this file will be autoloaded by komorebi\n");
|
||||||
|
} else {
|
||||||
|
println!("No komorebi configuration found in {home_lossy_string}\n");
|
||||||
|
println!("If running 'komorebic start --await-configuration', you will manually have to call the following command to begin tiling: komorebic complete-configuration\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
SubCommand::AhkLibrary => {
|
SubCommand::AhkLibrary => {
|
||||||
let mut library = HOME_DIR.clone();
|
let mut library = HOME_DIR.clone();
|
||||||
library.push("komorebic.lib.ahk");
|
library.push("komorebic.lib.ahk");
|
||||||
|
|||||||
Reference in New Issue
Block a user