refactor(ahk): remove derive-ahk and references
This commit finally sunsets the derive-ahk proc macro and the ahk-library cli command. There is now a dedicated, stripped down komorebi.ahk example on the docs website which mirrors the contents and style of the sample whkdrc: https://lgug2z.github.io/komorebi/common-workflows/autohotkey.html
This commit is contained in:
parent
340c137342
commit
03fdbea5cd
|
@ -1116,15 +1116,6 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive-ahk"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
|
@ -2400,11 +2391,9 @@ dependencies = [
|
|||
"chrono",
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"derive-ahk",
|
||||
"dirs",
|
||||
"dunce",
|
||||
"fs-tail",
|
||||
"heck 0.5.0",
|
||||
"komorebi-client",
|
||||
"komorebi-core",
|
||||
"lazy_static",
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
resolver = "2"
|
||||
members = [
|
||||
"derive-ahk",
|
||||
"komorebi",
|
||||
"komorebi-client",
|
||||
"komorebi-core",
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
[package]
|
||||
name = "derive-ahk"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
syn = "1.0"
|
||||
quote = "1.0"
|
|
@ -1,225 +0,0 @@
|
|||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
#![no_implicit_prelude]
|
||||
|
||||
use ::std::clone::Clone;
|
||||
use ::std::convert::From;
|
||||
use ::std::convert::Into;
|
||||
use ::std::format;
|
||||
use ::std::iter::Extend;
|
||||
use ::std::iter::Iterator;
|
||||
use ::std::matches;
|
||||
use ::std::option::Option::Some;
|
||||
use ::std::string::String;
|
||||
use ::std::string::ToString;
|
||||
use ::std::unreachable;
|
||||
use ::std::vec::Vec;
|
||||
|
||||
use ::quote::quote;
|
||||
use ::syn::parse_macro_input;
|
||||
use ::syn::Data;
|
||||
use ::syn::DataEnum;
|
||||
use ::syn::DeriveInput;
|
||||
use ::syn::Fields;
|
||||
use ::syn::FieldsNamed;
|
||||
use ::syn::FieldsUnnamed;
|
||||
use ::syn::Meta;
|
||||
use ::syn::NestedMeta;
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[proc_macro_derive(AhkFunction)]
|
||||
pub fn ahk_function(input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let name = input.ident;
|
||||
|
||||
match input.data {
|
||||
Data::Struct(s) => match s.fields {
|
||||
Fields::Named(FieldsNamed { named, .. }) => {
|
||||
let argument_idents = named
|
||||
.iter()
|
||||
// Filter out the flags
|
||||
.filter(|&f| {
|
||||
let mut include = true;
|
||||
for attribute in &f.attrs {
|
||||
if let ::std::result::Result::Ok(Meta::List(list)) =
|
||||
attribute.parse_meta()
|
||||
{
|
||||
for nested in list.nested {
|
||||
if let NestedMeta::Meta(Meta::Path(path)) = nested {
|
||||
if path.is_ident("long") {
|
||||
include = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include
|
||||
})
|
||||
.map(|f| &f.ident);
|
||||
|
||||
let argument_idents_clone = argument_idents.clone();
|
||||
|
||||
let called_arguments = quote! {#(%#argument_idents_clone%) *}
|
||||
.to_string()
|
||||
.replace(" %", "%")
|
||||
.replace("% ", "%")
|
||||
.replace("%%", "% %");
|
||||
|
||||
let flag_idents = named
|
||||
.iter()
|
||||
// Filter only the flags
|
||||
.filter(|f| {
|
||||
let mut include = false;
|
||||
|
||||
for attribute in &f.attrs {
|
||||
if let ::std::result::Result::Ok(Meta::List(list)) =
|
||||
attribute.parse_meta()
|
||||
{
|
||||
for nested in list.nested {
|
||||
if let NestedMeta::Meta(Meta::Path(path)) = nested {
|
||||
// Identify them using the --long flag name
|
||||
if path.is_ident("long") {
|
||||
include = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include
|
||||
})
|
||||
.map(|f| &f.ident);
|
||||
|
||||
let has_flags = flag_idents.clone().count() != 0;
|
||||
|
||||
if has_flags {
|
||||
let flag_idents_concat = flag_idents.clone();
|
||||
let argument_idents_concat = argument_idents.clone();
|
||||
|
||||
// Concat the args and flag args if there are flags
|
||||
let all_arguments =
|
||||
quote! {#(#argument_idents_concat,) * #(#flag_idents_concat), *}
|
||||
.to_string();
|
||||
|
||||
let flag_idents_clone = flag_idents.clone();
|
||||
let flags = quote! {#(--#flag_idents_clone) *}
|
||||
.to_string()
|
||||
.replace("- - ", "--")
|
||||
.replace('_', "-");
|
||||
|
||||
let called_flag_arguments = quote! {#(%#flag_idents%) *}
|
||||
.to_string()
|
||||
.replace(" %", "%")
|
||||
.replace("% ", "%")
|
||||
.replace("%%", "% %");
|
||||
|
||||
let flags_split: Vec<_> = flags.split(' ').collect();
|
||||
let flag_args_split: Vec<_> = called_flag_arguments.split(' ').collect();
|
||||
let mut consolidated_flags: Vec<String> = Vec::new();
|
||||
|
||||
for (idx, flag) in flags_split.iter().enumerate() {
|
||||
consolidated_flags.push(format!("{} {}", flag, flag_args_split[idx]));
|
||||
}
|
||||
|
||||
let all_flags = consolidated_flags.join(" ");
|
||||
|
||||
quote! {
|
||||
impl AhkFunction for #name {
|
||||
fn generate_ahk_function() -> String {
|
||||
::std::format!(r#"
|
||||
{}({}) {{
|
||||
RunWait, komorebic.exe {} {} {}, , Hide
|
||||
}}"#,
|
||||
::std::stringify!(#name),
|
||||
#all_arguments,
|
||||
::std::stringify!(#name).to_kebab_case(),
|
||||
#called_arguments,
|
||||
#all_flags,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let arguments = quote! {#(#argument_idents), *}.to_string();
|
||||
|
||||
quote! {
|
||||
impl AhkFunction for #name {
|
||||
fn generate_ahk_function() -> String {
|
||||
::std::format!(r#"
|
||||
{}({}) {{
|
||||
RunWait, komorebic.exe {} {}, , Hide
|
||||
}}"#,
|
||||
::std::stringify!(#name),
|
||||
#arguments,
|
||||
::std::stringify!(#name).to_kebab_case(),
|
||||
#called_arguments
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!("only to be used on structs with named fields"),
|
||||
},
|
||||
_ => unreachable!("only to be used on structs"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(AhkLibrary)]
|
||||
pub fn ahk_library(input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let name = input.ident;
|
||||
|
||||
match input.data {
|
||||
Data::Enum(DataEnum { variants, .. }) => {
|
||||
let enums = variants.iter().filter(|&v| {
|
||||
matches!(v.fields, Fields::Unit) || matches!(v.fields, Fields::Unnamed(..))
|
||||
});
|
||||
|
||||
let mut stream = ::proc_macro2::TokenStream::new();
|
||||
|
||||
for variant in enums.clone() {
|
||||
match &variant.fields {
|
||||
Fields::Unnamed(FieldsUnnamed { unnamed, .. }) => {
|
||||
for field in unnamed {
|
||||
stream.extend(quote! {
|
||||
v.push(#field::generate_ahk_function());
|
||||
});
|
||||
}
|
||||
}
|
||||
Fields::Unit => {
|
||||
let name = &variant.ident;
|
||||
stream.extend(quote! {
|
||||
v.push(::std::format!(r#"
|
||||
{}() {{
|
||||
RunWait, komorebic.exe {}, , Hide
|
||||
}}"#,
|
||||
::std::stringify!(#name),
|
||||
::std::stringify!(#name).to_kebab_case()
|
||||
));
|
||||
});
|
||||
}
|
||||
Fields::Named(_) => {
|
||||
unreachable!("only to be used with unnamed and unit fields");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
quote! {
|
||||
impl #name {
|
||||
fn generate_ahk_library() -> String {
|
||||
let mut v: Vec<String> = vec![String::from("; Generated by komorebic.exe")];
|
||||
|
||||
#stream
|
||||
|
||||
v.join("\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!("only to be used on enums"),
|
||||
}
|
||||
.into()
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
|
||||
pub use komorebi::colour::Colour;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)]
|
||||
|
||||
use std::path::Path;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(clippy::assigning_clones)]
|
||||
#![warn(clippy::all)]
|
||||
|
||||
use eframe::egui;
|
||||
use eframe::egui::color_picker::Alpha;
|
||||
|
@ -715,7 +715,7 @@ impl eframe::App for KomorebiGui {
|
|||
.text_edit_singleline(workspace_name)
|
||||
.lost_focus()
|
||||
{
|
||||
workspace.name = workspace_name.clone();
|
||||
workspace.name.clone_from(workspace_name);
|
||||
komorebi_client::send_message(
|
||||
&SocketMessage::WorkspaceName(
|
||||
monitor_idx,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![warn(clippy::all)]
|
||||
|
||||
pub mod border_manager;
|
||||
pub mod com;
|
||||
#[macro_use]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(
|
||||
clippy::missing_errors_doc,
|
||||
clippy::redundant_pub_crate,
|
||||
|
|
|
@ -493,20 +493,16 @@ impl From<&WindowManager> for StaticConfig {
|
|||
}
|
||||
|
||||
impl StaticConfig {
|
||||
#[allow(
|
||||
clippy::cognitive_complexity,
|
||||
clippy::too_many_lines,
|
||||
clippy::assigning_clones
|
||||
)]
|
||||
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
||||
fn apply_globals(&mut self) -> Result<()> {
|
||||
if let Some(monitor_index_preferences) = &self.monitor_index_preferences {
|
||||
let mut preferences = MONITOR_INDEX_PREFERENCES.lock();
|
||||
*preferences = monitor_index_preferences.clone();
|
||||
preferences.clone_from(monitor_index_preferences);
|
||||
}
|
||||
|
||||
if let Some(display_index_preferences) = &self.display_index_preferences {
|
||||
let mut preferences = DISPLAY_INDEX_PREFERENCES.lock();
|
||||
*preferences = display_index_preferences.clone();
|
||||
preferences.clone_from(display_index_preferences);
|
||||
}
|
||||
|
||||
if let Some(behaviour) = self.window_hiding_behaviour {
|
||||
|
|
|
@ -11,7 +11,6 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
derive-ahk = { path = "../derive-ahk" }
|
||||
komorebi-core = { path = "../komorebi-core" }
|
||||
komorebi-client = { path = "../komorebi-client" }
|
||||
|
||||
|
@ -21,7 +20,6 @@ color-eyre = { workspace = true }
|
|||
dirs = { workspace = true }
|
||||
dunce = { workspace = true }
|
||||
fs-tail = "0.1"
|
||||
heck = "0.5"
|
||||
lazy_static = "1"
|
||||
miette = { version = "7", features = ["fancy"] }
|
||||
paste = "1"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(clippy::missing_errors_doc, clippy::doc_markdown)]
|
||||
|
||||
use chrono::Local;
|
||||
|
@ -24,7 +24,6 @@ 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;
|
||||
use lazy_static::lazy_static;
|
||||
use miette::NamedSource;
|
||||
|
@ -39,8 +38,6 @@ use windows::Win32::UI::WindowsAndMessaging::ShowWindow;
|
|||
use windows::Win32::UI::WindowsAndMessaging::SHOW_WINDOW_CMD;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_RESTORE;
|
||||
|
||||
use derive_ahk::AhkFunction;
|
||||
use derive_ahk::AhkLibrary;
|
||||
use komorebi_client::StaticConfig;
|
||||
use komorebi_core::config_generation::ApplicationConfigurationGenerator;
|
||||
use komorebi_core::ApplicationIdentifier;
|
||||
|
@ -102,15 +99,6 @@ lazy_static! {
|
|||
};
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait AhkLibrary {
|
||||
fn generate_ahk_library() -> String;
|
||||
}
|
||||
|
||||
trait AhkFunction {
|
||||
fn generate_ahk_function() -> String;
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug, miette::Diagnostic)]
|
||||
#[error("{message}")]
|
||||
#[diagnostic(code(komorebi::configuration), help("try fixing this syntax error"))]
|
||||
|
@ -142,7 +130,7 @@ macro_rules! gen_enum_subcommand_args {
|
|||
( $( $name:ident: $element:ty ),+ $(,)? ) => {
|
||||
$(
|
||||
paste! {
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
#[clap(value_enum)]
|
||||
[<$element:snake>]: $element
|
||||
|
@ -182,7 +170,7 @@ macro_rules! gen_target_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
/// Target index (zero-indexed)
|
||||
target: usize,
|
||||
|
@ -207,7 +195,7 @@ macro_rules! gen_named_target_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -231,7 +219,7 @@ macro_rules! gen_workspace_subcommand_args {
|
|||
( $( $name:ident: $(#[enum] $(@$value_enum:tt)?)? $value:ty ),+ $(,)? ) => (
|
||||
paste! {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct [<Workspace $name>] {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -263,7 +251,7 @@ macro_rules! gen_named_workspace_subcommand_args {
|
|||
( $( $name:ident: $(#[enum] $(@$value_enum:tt)?)? $value:ty ),+ $(,)? ) => (
|
||||
paste! {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct [<NamedWorkspace $name>] {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -285,7 +273,7 @@ gen_named_workspace_subcommand_args! {
|
|||
Tiling: #[enum] BooleanState,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct ClearWorkspaceLayoutRules {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -294,7 +282,7 @@ pub struct ClearWorkspaceLayoutRules {
|
|||
workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct WorkspaceCustomLayout {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -306,7 +294,7 @@ pub struct WorkspaceCustomLayout {
|
|||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct NamedWorkspaceCustomLayout {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -315,7 +303,7 @@ pub struct NamedWorkspaceCustomLayout {
|
|||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct WorkspaceLayoutRule {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -330,7 +318,7 @@ pub struct WorkspaceLayoutRule {
|
|||
layout: DefaultLayout,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct NamedWorkspaceLayoutRule {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -342,7 +330,7 @@ pub struct NamedWorkspaceLayoutRule {
|
|||
layout: DefaultLayout,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct WorkspaceCustomLayoutRule {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -357,7 +345,7 @@ pub struct WorkspaceCustomLayoutRule {
|
|||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct NamedWorkspaceCustomLayoutRule {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -369,7 +357,7 @@ pub struct NamedWorkspaceCustomLayoutRule {
|
|||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct Resize {
|
||||
#[clap(value_enum)]
|
||||
edge: OperationDirection,
|
||||
|
@ -377,7 +365,7 @@ struct Resize {
|
|||
sizing: Sizing,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct ResizeAxis {
|
||||
#[clap(value_enum)]
|
||||
axis: Axis,
|
||||
|
@ -385,13 +373,13 @@ struct ResizeAxis {
|
|||
sizing: Sizing,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct ResizeDelta {
|
||||
/// The delta of pixels by which to increase or decrease window dimensions when resizing
|
||||
pixels: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct InvisibleBorders {
|
||||
/// Size of the left invisible border
|
||||
left: i32,
|
||||
|
@ -403,7 +391,7 @@ struct InvisibleBorders {
|
|||
bottom: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct GlobalWorkAreaOffset {
|
||||
/// Size of the left work area offset (set right to left * 2 to maintain right padding)
|
||||
left: i32,
|
||||
|
@ -415,7 +403,7 @@ struct GlobalWorkAreaOffset {
|
|||
bottom: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct MonitorWorkAreaOffset {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -429,7 +417,7 @@ struct MonitorWorkAreaOffset {
|
|||
bottom: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct MonitorIndexPreference {
|
||||
/// Preferred monitor index (zero-indexed)
|
||||
index_preference: usize,
|
||||
|
@ -443,7 +431,7 @@ struct MonitorIndexPreference {
|
|||
bottom: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct DisplayIndexPreference {
|
||||
/// Preferred monitor index (zero-indexed)
|
||||
index_preference: usize,
|
||||
|
@ -451,7 +439,7 @@ struct DisplayIndexPreference {
|
|||
display: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct EnsureWorkspaces {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -459,7 +447,7 @@ struct EnsureWorkspaces {
|
|||
workspace_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct EnsureNamedWorkspaces {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -467,7 +455,7 @@ struct EnsureNamedWorkspaces {
|
|||
names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct FocusMonitorWorkspace {
|
||||
/// Target monitor index (zero-indexed)
|
||||
target_monitor: usize,
|
||||
|
@ -475,7 +463,7 @@ struct FocusMonitorWorkspace {
|
|||
target_workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct SendToMonitorWorkspace {
|
||||
/// Target monitor index (zero-indexed)
|
||||
target_monitor: usize,
|
||||
|
@ -483,7 +471,7 @@ pub struct SendToMonitorWorkspace {
|
|||
target_workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
pub struct MoveToMonitorWorkspace {
|
||||
/// Target monitor index (zero-indexed)
|
||||
target_monitor: usize,
|
||||
|
@ -495,7 +483,7 @@ macro_rules! gen_focused_workspace_padding_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
/// Pixels size to set as an integer
|
||||
size: i32,
|
||||
|
@ -513,7 +501,7 @@ macro_rules! gen_padding_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
/// Monitor index (zero-indexed)
|
||||
monitor: usize,
|
||||
|
@ -535,7 +523,7 @@ macro_rules! gen_named_padding_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
/// Target workspace name
|
||||
workspace: String,
|
||||
|
@ -556,7 +544,7 @@ macro_rules! gen_padding_adjustment_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
#[clap(value_enum)]
|
||||
sizing: Sizing,
|
||||
|
@ -576,7 +564,7 @@ macro_rules! gen_application_target_subcommand_args {
|
|||
// SubCommand Pattern
|
||||
( $( $name:ident ),+ $(,)? ) => {
|
||||
$(
|
||||
#[derive(clap::Parser, derive_ahk::AhkFunction)]
|
||||
#[derive(clap::Parser)]
|
||||
pub struct $name {
|
||||
#[clap(value_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
|
@ -597,7 +585,7 @@ gen_application_target_subcommand_args! {
|
|||
RemoveTitleBar,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct InitialWorkspaceRule {
|
||||
#[clap(value_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
|
@ -609,7 +597,7 @@ struct InitialWorkspaceRule {
|
|||
workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct InitialNamedWorkspaceRule {
|
||||
#[clap(value_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
|
@ -619,7 +607,7 @@ struct InitialNamedWorkspaceRule {
|
|||
workspace: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct WorkspaceRule {
|
||||
#[clap(value_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
|
@ -631,7 +619,7 @@ struct WorkspaceRule {
|
|||
workspace: usize,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct NamedWorkspaceRule {
|
||||
#[clap(value_enum)]
|
||||
identifier: ApplicationIdentifier,
|
||||
|
@ -641,13 +629,13 @@ struct NamedWorkspaceRule {
|
|||
workspace: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct ToggleFocusFollowsMouse {
|
||||
#[clap(value_enum, short, long, default_value = "windows")]
|
||||
implementation: FocusFollowsMouseImplementation,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct FocusFollowsMouse {
|
||||
#[clap(value_enum, short, long, default_value = "windows")]
|
||||
implementation: FocusFollowsMouseImplementation,
|
||||
|
@ -655,13 +643,13 @@ struct FocusFollowsMouse {
|
|||
boolean_state: BooleanState,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct Border {
|
||||
#[clap(value_enum)]
|
||||
boolean_state: BooleanState,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct BorderColour {
|
||||
#[clap(value_enum, short, long, default_value = "single")]
|
||||
window_kind: WindowKind,
|
||||
|
@ -673,19 +661,19 @@ struct BorderColour {
|
|||
b: u32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct BorderWidth {
|
||||
/// Desired width of the window border
|
||||
width: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct BorderOffset {
|
||||
/// Desired offset of the window border
|
||||
offset: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
struct Start {
|
||||
/// Allow the use of komorebi's custom focus-follows-mouse implementation
|
||||
|
@ -708,56 +696,56 @@ struct Start {
|
|||
ahk: bool,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct Stop {
|
||||
/// Stop whkd if it is running as a background process
|
||||
#[clap(long)]
|
||||
whkd: bool,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct SaveResize {
|
||||
/// File to which the resize layout dimensions should be saved
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct LoadResize {
|
||||
/// File from which the resize layout dimensions should be loaded
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct LoadCustomLayout {
|
||||
/// JSON or YAML file from which the custom layout definition should be loaded
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct SubscribeSocket {
|
||||
/// Name of the socket to send event notifications to
|
||||
socket: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct UnsubscribeSocket {
|
||||
/// Name of the socket to stop sending event notifications to
|
||||
socket: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct SubscribePipe {
|
||||
/// Name of the pipe to send event notifications to (without "\\.\pipe\" prepended)
|
||||
named_pipe: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct UnsubscribePipe {
|
||||
/// Name of the pipe to stop sending event notifications to (without "\\.\pipe\" prepended)
|
||||
named_pipe: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct AhkAppSpecificConfiguration {
|
||||
/// YAML file from which the application-specific configurations should be loaded
|
||||
path: PathBuf,
|
||||
|
@ -765,7 +753,7 @@ struct AhkAppSpecificConfiguration {
|
|||
override_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct PwshAppSpecificConfiguration {
|
||||
/// YAML file from which the application-specific configurations should be loaded
|
||||
path: PathBuf,
|
||||
|
@ -773,19 +761,19 @@ struct PwshAppSpecificConfiguration {
|
|||
override_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct FormatAppSpecificConfiguration {
|
||||
/// YAML file from which the application-specific configurations should be loaded
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct AltFocusHack {
|
||||
#[clap(value_enum)]
|
||||
boolean_state: BooleanState,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkFunction)]
|
||||
#[derive(Parser)]
|
||||
struct EnableAutostart {
|
||||
/// Path to a static configuration JSON file
|
||||
#[clap(action, short, long)]
|
||||
|
@ -808,7 +796,7 @@ struct Opts {
|
|||
subcmd: SubCommand,
|
||||
}
|
||||
|
||||
#[derive(Parser, AhkLibrary)]
|
||||
#[derive(Parser)]
|
||||
enum SubCommand {
|
||||
#[clap(hide = true)]
|
||||
Docgen,
|
||||
|
@ -1180,8 +1168,6 @@ enum SubCommand {
|
|||
MouseFollowsFocus(MouseFollowsFocus),
|
||||
/// Toggle mouse follows focus on all workspaces
|
||||
ToggleMouseFollowsFocus,
|
||||
/// Generate a library of AutoHotKey helper functions
|
||||
AhkLibrary,
|
||||
/// Generate common app-specific configurations and fixes to use in komorebi.ahk
|
||||
#[clap(arg_required_else_help = true)]
|
||||
#[clap(alias = "ahk-asc")]
|
||||
|
@ -1465,35 +1451,6 @@ fn main() -> Result<()> {
|
|||
println!("{}", whkdrc.display());
|
||||
}
|
||||
}
|
||||
SubCommand::AhkLibrary => {
|
||||
let library = HOME_DIR.join("komorebic.lib.ahk");
|
||||
let mut file = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(library.clone())?;
|
||||
|
||||
let output: String = SubCommand::generate_ahk_library();
|
||||
let fixed_id = output.replace("%id%", "\"%id%\"");
|
||||
let fixed_stop_def = fixed_id.replace("Stop(whkd)", "Stop()");
|
||||
let fixed_output =
|
||||
fixed_stop_def.replace("komorebic.exe stop --whkd %whkd%", "komorebic.exe stop");
|
||||
|
||||
file.write_all(fixed_output.as_bytes())?;
|
||||
|
||||
println!(
|
||||
"\nAHKv1 helper library for komorebic written to {}",
|
||||
library.to_string_lossy()
|
||||
);
|
||||
|
||||
println!("\nYou can convert this file to AHKv2 syntax using https://github.com/mmikeww/AHK-v2-script-converter");
|
||||
|
||||
println!(
|
||||
"\nYou can include the converted library at the top of your komorebi.ahk config with this line:"
|
||||
);
|
||||
|
||||
println!("\n#Include komorebic.lib.ahk");
|
||||
}
|
||||
SubCommand::Log => {
|
||||
let timestamp = Local::now().format("%Y-%m-%d").to_string();
|
||||
let color_log = std::env::temp_dir().join(format!("komorebi.log.{timestamp}"));
|
||||
|
|
Loading…
Reference in New Issue