From d52715a8faebb355d98cf346793bc71f822acfae Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 16 Feb 2024 13:15:04 -0800 Subject: [PATCH] fix(cli): create local appdata dir w/ quickstart This commit ensures that the $Env:LOCALAPPDATA/komorebi dir is created by the quickstart command, as it cannot be assumed that this will always exist, especially on new machines with recent versions of Windows 11. fix #671 --- docs/installation.md | 9 --------- komorebi/src/windows_api.rs | 2 +- komorebi/src/workspace.rs | 1 + komorebic/src/main.rs | 8 ++++++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index affba0ec..3d40ae9b 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -44,15 +44,6 @@ running the following command in an Administrator Terminal before installing Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 ``` -## Local data directory - -If you are installing `komorebi` for the first time on a new machine, create a -dedicated folder for `komorebi` in `$Env:LOCALAPPDATA`. - -```powershell -mkdir "$Env:LOCALAPPDATA\komorebi" -ea 0 -``` - ## Scoop Make sure you have installed [`scoop`](https://scoop.sh) and verified that diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index f1858586..a2ba0246 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -264,7 +264,7 @@ impl WindowsApi { } .ok() { - Ok(_) => {} + Ok(()) => {} Err(error) => { tracing::error!("enum_display_devices: {}", error); return Err(error.into()); diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index be5641ea..61ee0eb3 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -31,6 +31,7 @@ use crate::INITIAL_CONFIGURATION_LOADED; use crate::NO_TITLEBAR; use crate::REMOVE_TITLEBARS; +#[allow(clippy::struct_field_names)] #[derive(Debug, Clone, Serialize, Getters, CopyGetters, MutGetters, Setters, JsonSchema)] pub struct Workspace { #[getset(get = "pub", set = "pub")] diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 76ada7c7..564f26f0 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -20,6 +20,7 @@ use clap::ValueEnum; use color_eyre::eyre::anyhow; use color_eyre::eyre::bail; use color_eyre::Result; +use dirs::data_local_dir; use fs_tail::TailedFile; use heck::ToKebabCase; use komorebi_core::resolve_home_path; @@ -1247,7 +1248,10 @@ fn main() -> Result<()> { let home_dir = dirs::home_dir().expect("could not find home dir"); let config_dir = home_dir.join(".config"); + let local_appdata_dir = data_local_dir().expect("could not find localdata dir"); + let data_dir = local_appdata_dir.join("komorebi"); std::fs::create_dir_all(&config_dir)?; + std::fs::create_dir_all(data_dir)?; let komorebi_json = reqwest::blocking::get( format!("https://raw.githubusercontent.com/LGUG2Z/komorebi/v{version}/komorebi.example.json") @@ -1438,7 +1442,7 @@ fn main() -> Result<()> { let color_log = std::env::temp_dir().join("komorebi.log"); let file = TailedFile::new(File::open(color_log)?); let locked = file.lock(); - #[allow(clippy::significant_drop_in_scrutinee)] + #[allow(clippy::significant_drop_in_scrutinee, clippy::lines_filter_map_ok)] for line in locked.lines().flatten() { println!("{line}"); } @@ -1735,7 +1739,7 @@ fn main() -> Result<()> { let exec = if let Ok(output) = Command::new("where.exe").arg("komorebi.ps1").output() { let stdout = String::from_utf8(output.stdout)?; match stdout.trim() { - stdout if stdout.is_empty() => None, + "" => None, // It's possible that a komorebi.ps1 config will be in %USERPROFILE% - ignore this stdout if !stdout.contains("scoop") => None, stdout => {