From cd5f660455a10a86c6c6d95279817d6570db6933 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 27 Sep 2025 13:04:21 -0700 Subject: [PATCH] feat(cli): add permissions prompts to quickstart --- docs/example-configurations.md | 12 +++++++++++- docs/installation.md | 12 ++---------- komorebi/src/lib.rs | 2 +- komorebic/src/main.rs | 27 +++++++++++++++++++++++++-- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/docs/example-configurations.md b/docs/example-configurations.md index f1562ac8..9c861faf 100644 --- a/docs/example-configurations.md +++ b/docs/example-configurations.md @@ -16,7 +16,17 @@ the example files have been downloaded. For most new users this will be in the komorebic quickstart ``` -With the example configurations downloaded, you can now start `komorebi` + +### Granting Permissions + +The `quickstart` command will also prompt you to grant komorebi the permissions +it requires to run, and will open the following System Settings tabs for you: + +* Settings -> Privacy & Security -> Accessibility +* Settings -> Privacy & Security -> Screen & System Audio Recording + +With the example configurations downloaded and permissions granted, you can now +start `komorebi` ```powershell komorebic start diff --git a/docs/installation.md b/docs/installation.md index 14075266..d0db4ded 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -33,16 +33,8 @@ cargo +stable install --path komorebic --locked --target-dir ~/.cargo/bin If the binaries have been built and added to your `$PATH` correctly, you should see some output when running `komorebi --help` and `komorebic --help` -## Granting Permissions - -Users will need to manually add `~/.cargo/bin/komorebi` to: - -* Settings -> Privacy & Security -> Accessibility -* Settings -> Privacy & Security -> Screen & System Audio Recording - -Once komorebi is installed, and these permissions have been granted, proceed to -get the [example -configurations](example-configurations.md). +Once komorebi is installed, proceed to get +the [example configurations](example-configurations.md). ## Uninstallation diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index d3b86b06..58118b10 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -86,7 +86,7 @@ lazy_static! { assert!( home.is_dir(), - "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory" + "$KOMOREBI_CONFIG_HOME is set to \"{home_path}\", which is not a valid directory" ); home diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 5e219889..7223a45f 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -47,7 +47,7 @@ lazy_static! { home } else { panic!( - "$KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory", + "$KOMOREBI_CONFIG_HOME is set to \"{home_path}\", which is not a valid directory", ); } }, @@ -1244,7 +1244,30 @@ fn main() -> eyre::Result<()> { written_files.join("\n") ); } - println!("\nYou can now run: komorebic start"); + + let mut current_exe = std::env::current_exe().expect("unable to get exec path"); + current_exe.pop(); + let komorebi_exe = current_exe.join("komorebi"); + + println!("\nPlease grant Accessibility permissions to \"{}\"", komorebi_exe.display()); + println!("Accessibility permissions are required for komorebi to to manage windows"); + Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility").spawn()?; + + println!("\nHit return when done..."); + std::io::stdout().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + + println!("Please grant Screen Recording permissions to \"{}\"", komorebi_exe.display()); + println!("Screen Recording permissions are required to for komorebi to read window titles"); + Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture").spawn()?; + + println!("\nHit return when done..."); + std::io::stdout().flush()?; + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + + println!("You can now run: komorebic start"); println!( "\nIf you have skhd hotkey daemon installed, you can also run: skhd --config {}", skhdrc_path.display()