From 24ac0c4cd386c0786570d0d5617f06f06ca68e23 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 24 Mar 2024 21:07:07 -0700 Subject: [PATCH] refactor(cli): avoid http reqs for sample configs re #716 --- .gitignore | 3 ++- komorebi.example.json | 27 ------------------- komorebic/Cargo.toml | 5 +++- komorebic/build.rs | 8 ++++++ komorebic/src/main.rs | 16 +++-------- whkdrc.sample | 63 ------------------------------------------- 6 files changed, 17 insertions(+), 105 deletions(-) delete mode 100644 komorebi.example.json create mode 100644 komorebic/build.rs delete mode 100644 whkdrc.sample diff --git a/.gitignore b/.gitignore index 6cbbe3e4..844c1f77 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /target CHANGELOG.md dummy.go -komorebi.ahk \ No newline at end of file +komorebi.ahk +komorebic/applications.yaml \ No newline at end of file diff --git a/komorebi.example.json b/komorebi.example.json deleted file mode 100644 index f3bc73f7..00000000 --- a/komorebi.example.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.22/schema.json", - "app_specific_configuration_path": "$Env:USERPROFILE/applications.yaml", - "window_hiding_behaviour": "Cloak", - "cross_monitor_move_behaviour": "Insert", - "default_workspace_padding": 20, - "default_container_padding": 20, - "border_padding": 8, - "border_offset": -1, - "active_window_border": false, - "active_window_border_colours": { - "single": "#42a5f5", - "stack": "#00a542", - "monocle": "#ff3399" - }, - "monitors": [ - { - "workspaces": [ - { "name": "I", "layout": "BSP" }, - { "name": "II", "layout": "VerticalStack" }, - { "name": "III", "layout": "HorizontalStack" }, - { "name": "IV", "layout": "UltrawideVerticalStack" }, - { "name": "V", "layout": "Rows" } - ] - } - ] -} diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index a0b3f776..33b27496 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -32,4 +32,7 @@ sysinfo = "0.30" thiserror = "1" uds_windows = "1" which = "6" -windows = { workspace = true } \ No newline at end of file +windows = { workspace = true } + +[build-dependencies] +reqwest = { version = "0.11", features = ["blocking"] } diff --git a/komorebic/build.rs b/komorebic/build.rs new file mode 100644 index 00000000..cd118247 --- /dev/null +++ b/komorebic/build.rs @@ -0,0 +1,8 @@ +fn main() { + if std::fs::metadata("applications.yaml").is_err() { + let applications_yaml = reqwest::blocking::get( + "https://raw.githubusercontent.com/LGUG2Z/komorebi-application-specific-configuration/master/applications.yaml" + ).unwrap().text().unwrap(); + std::fs::write("applications.yaml", applications_yaml).unwrap(); + } +} diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 5f385c15..5cb49979 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1256,8 +1256,6 @@ fn main() -> Result<()> { } } SubCommand::Quickstart => { - let version = env!("CARGO_PKG_VERSION"); - 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"); @@ -1265,21 +1263,13 @@ fn main() -> Result<()> { 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") - )?.text()?; + let komorebi_json = include_str!("../../docs/komorebi.example.json"); std::fs::write(HOME_DIR.join("komorebi.json"), komorebi_json)?; - let applications_yaml = reqwest::blocking::get( - "https://raw.githubusercontent.com/LGUG2Z/komorebi-application-specific-configuration/master/applications.yaml" - )? - .text()?; + let applications_yaml = include_str!("../applications.yaml"); std::fs::write(HOME_DIR.join("applications.yaml"), applications_yaml)?; - let whkdrc = reqwest::blocking::get(format!( - "https://raw.githubusercontent.com/LGUG2Z/komorebi/v{version}/whkdrc.sample" - ))? - .text()?; + let whkdrc = include_str!("../../docs/whkdrc.sample"); std::fs::write(config_dir.join("whkdrc"), whkdrc)?; println!("Example ~/komorebi.json, ~/.config/whkdrc and latest ~/applications.yaml files downloaded"); diff --git a/whkdrc.sample b/whkdrc.sample deleted file mode 100644 index 77c6eac7..00000000 --- a/whkdrc.sample +++ /dev/null @@ -1,63 +0,0 @@ -.shell powershell - -# Reload whkd configuration -# alt + o : taskkill /f /im whkd.exe && start /b whkd # if shell is cmd -alt + o : taskkill /f /im whkd.exe; Start-Process whkd -WindowStyle hidden # if shell is pwsh / powershell -alt + shift + o : komorebic reload-configuration - -# App shortcuts - these require shell to be pwsh / powershell -# The apps will be focused if open, or launched if not open -# alt + f : if ($wshell.AppActivate('Firefox') -eq $False) { start firefox } -# alt + b : if ($wshell.AppActivate('Chrome') -eq $False) { start chrome } - -# Focus windows -alt + h : komorebic focus left -alt + j : komorebic focus down -alt + k : komorebic focus up -alt + l : komorebic focus right -alt + shift + oem_4 : komorebic cycle-focus previous # oem_4 is [ -alt + shift + oem_6 : komorebic cycle-focus next # oem_6 is ] - -# Move windows -alt + shift + h : komorebic move left -alt + shift + j : komorebic move down -alt + shift + k : komorebic move up -alt + shift + l : komorebic move right -alt + shift + return : komorebic promote - -# Stack windows -alt + left : komorebic stack left -alt + down : komorebic stack down -alt + up : komorebic stack up -alt + right : komorebic stack right -alt + oem_1 : komorebic unstack # oem_1 is ; -alt + oem_4 : komorebic cycle-stack previous # oem_4 is [ -alt + oem_6 : komorebic cycle-stack next # oem_6 is ] - -# Resize -alt + oem_plus : komorebic resize-axis horizontal increase -alt + oem_minus : komorebic resize-axis horizontal decrease -alt + shift + oem_plus : komorebic resize-axis vertical increase -alt + shift + oem_minus : komorebic resize-axis vertical decrease - -# Manipulate windows -alt + t : komorebic toggle-float -alt + shift + f : komorebic toggle-monocle - -# Window manager options -alt + shift + r : komorebic retile -alt + p : komorebic toggle-pause - -# Layouts -alt + x : komorebic flip-layout horizontal -alt + y : komorebic flip-layout vertical - -# Workspaces -alt + 1 : komorebic focus-workspace 0 -alt + 2 : komorebic focus-workspace 1 -alt + 3 : komorebic focus-workspace 2 - -# Move windows across workspaces -alt + shift + 1 : komorebic move-to-workspace 0 -alt + shift + 2 : komorebic move-to-workspace 1 -alt + shift + 3 : komorebic move-to-workspace 2