Skip to content

Commit

Permalink
fix(cli): create local appdata dir w/ quickstart
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LGUG2Z committed Feb 16, 2024
1 parent 5495008 commit d52715a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
9 changes: 0 additions & 9 deletions docs/installation.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion komorebi/src/windows_api.rs
Expand Up @@ -264,7 +264,7 @@ impl WindowsApi {
}
.ok()
{
Ok(_) => {}
Ok(()) => {}
Err(error) => {
tracing::error!("enum_display_devices: {}", error);
return Err(error.into());
Expand Down
1 change: 1 addition & 0 deletions komorebi/src/workspace.rs
Expand Up @@ -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")]
Expand Down
8 changes: 6 additions & 2 deletions komorebic/src/main.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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}");
}
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit d52715a

Please sign in to comment.