Skip to content

Commit e1dc5b8

Browse files
committed
1.2.0 - Wildcard and Regex Rules
1 parent 540d8a5 commit e1dc5b8

File tree

5 files changed

+248
-25
lines changed

5 files changed

+248
-25
lines changed

Cargo.lock

Lines changed: 97 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wooting-profile-switcher"
33
description = "Automatically switch Wooting keyboard profiles based on focused window"
4-
version = "1.1.0"
4+
version = "1.2.0"
55
authors = ["Shayne Hartford <shaybox@shaybox.com>"]
66
edition = "2021"
77
readme = "README.md"
@@ -14,8 +14,10 @@ license = "MIT"
1414
active-win-pos-rs = "0.8"
1515
anyhow = "1"
1616
clap = { version = "4.3", features = ["derive"] }
17+
regex = "1.8"
1718
serde = { version = "1", features = ["derive"] }
1819
serde_json = "1"
20+
wildflower = "0.3"
1921
wooting-rgb-sys = "0.2"
2022

2123
# https://github.com/johnthagen/min-sized-rust

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,69 @@
1010
# WootingProfileSwitcher
1111

1212
Automatically switch Wooting keyboard profiles based on focused window
13+
14+
## Installation
15+
16+
You can [Download] and Extract the latest release for your operating system
17+
You can also install via cargo:
18+
`$ cargo install --git https://github.com/ShayBox/WootingProfileSwitcher`
19+
20+
## Configuration
21+
22+
The config file is generated on first run with the following format
23+
24+
```json
25+
{
26+
"loop_sleep_ms": 250,
27+
"send_sleep_ms": 250,
28+
"rules": [
29+
{
30+
"app_name": null,
31+
"process_name": "Isaac",
32+
"process_path": null,
33+
"profile_index": 1,
34+
"title": null
35+
},
36+
{
37+
"app_name": null,
38+
"process_name": "isaac-ng.exe",
39+
"process_path": null,
40+
"profile_index": 2,
41+
"title": null
42+
}
43+
]
44+
}
45+
```
46+
47+
The `sleep_ms` variables allow you to customize the duration between checking the active process, and duration between sending Wooting USB commands.
48+
The `rules` variable is a list of rules that supports [Wildcard] and [Regex] for `app_name`, `process_name`, `process_path` and `title` variables.
49+
50+
### Examples:
51+
52+
#### Matching a window title with a date variable
53+
54+
```json
55+
{
56+
"app_name": null,
57+
"process_name": null,
58+
"process_path": null,
59+
"profile_index": 0,
60+
"title": "VRCX ????.??.??"
61+
}
62+
```
63+
64+
#### Matching a window title with a version variable
65+
66+
```json
67+
{
68+
"app_name": null,
69+
"process_name": null,
70+
"process_path": null,
71+
"profile_index": 0,
72+
"title": "Minecraft [\d]+.[\d]+.[\d]+"
73+
}
74+
```
75+
76+
[Download]: https://github.com/ShayBox/WootingProfileSwitcher/releases/latest
77+
[Wildcard]: https://crates.io/crates/wildflower
78+
[Regex]: https://crates.io/crates/regex

src/config.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,40 @@ use serde::{Deserialize, Serialize};
1010
const CARGO_CRATE_NAME: &str = env!("CARGO_CRATE_NAME");
1111

1212
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
13-
pub struct Process {
14-
pub process_name: String,
13+
pub struct Rule {
14+
pub app_name: Option<String>,
15+
pub process_name: Option<String>,
16+
pub process_path: Option<String>,
1517
pub profile_index: u8,
18+
pub title: Option<String>,
1619
}
1720

1821
#[derive(Clone, Debug, Deserialize, Serialize)]
1922
pub struct Config {
2023
pub loop_sleep_ms: u64,
2124
pub send_sleep_ms: u64,
22-
pub process_list: Vec<Process>,
25+
pub rules: Vec<Rule>,
2326
}
2427

2528
impl Default for Config {
2629
fn default() -> Self {
2730
Self {
2831
loop_sleep_ms: 250,
2932
send_sleep_ms: 250,
30-
process_list: vec![
31-
Process {
32-
process_name: String::from("Isaac"),
33+
rules: vec![
34+
Rule {
35+
app_name: None,
36+
process_name: Some(String::from("Isaac")),
37+
process_path: None,
3338
profile_index: 1,
39+
title: None,
3440
},
35-
Process {
36-
process_name: String::from("isaac-ng.exe"),
41+
Rule {
42+
app_name: None,
43+
process_name: Some(String::from("isaac-ng.exe")),
44+
process_path: None,
3745
profile_index: 2,
46+
title: None,
3847
},
3948
],
4049
}

0 commit comments

Comments
 (0)