Skip to content

Commit 02f4bd6

Browse files
committed
1.8.0 - Profile Names
1 parent a0fb09e commit 02f4bd6

File tree

7 files changed

+226
-16
lines changed

7 files changed

+226
-16
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wooting-profile-switcher"
33
description = "WootingProfileSwitcher"
4-
version = "1.7.0"
4+
version = "1.8.0"
55
authors = ["Shayne Hartford <shaybox@shaybox.com>"]
66
edition = "2021"
77
readme = "README.md"
@@ -19,10 +19,14 @@ anyhow = "1"
1919
clap = { version = "4", features = ["derive"] }
2020
ctrlc = { version = "3", features = ["termination"] }
2121
dirs = "5"
22+
encoding_rs = "0.8"
2223
parking_lot = "0.12"
2324
regex = "1"
25+
rusty-leveldb = "2"
2426
serde = { version = "1", features = ["derive"] }
2527
serde_json = "1"
28+
serde_with = { version = "3", features = ["json"] }
29+
structstruck = "0.4.1"
2630
tauri = { version = "1", features = ["shell-open", "updater", "system-tray"] }
2731
wildflower = "0.3"
2832
wooting-rgb-sys = "0.2"

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The system tray icon allows you to pause/resume, reload, quit, and set the activ
2424
The config file is generated on first-run in the following location and format
2525

2626
| Platform | Location |
27-
|----------|------------------------------------------|
27+
| -------- | ---------------------------------------- |
2828
| Portable | Same location as the binary |
2929
| Windows | `C:\Users\...\AppData\Roaming` |
3030
| macOS | `/Users/.../Library/Application Support` |
@@ -40,6 +40,13 @@ The config file is generated on first-run in the following location and format
4040
"send_sleep_ms": 250,
4141
// Swap the lighting effects with the keyboard profile
4242
"swap_lighting": true,
43+
// List of profile names, pulled from Wootility
44+
"profiles" [
45+
"Typing Profile",
46+
"Rapid Profile",
47+
"Racing Profile",
48+
"Mixed Movement",
49+
],
4350
// List of rule objects, all match rules support Wildcard and Regex
4451
"rules": [
4552
{

src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct Config {
2525
pub loop_sleep_ms: u64,
2626
pub send_sleep_ms: u64,
2727
pub swap_lighting: bool,
28+
pub profiles: Vec<String>,
2829
pub rules: Vec<Rule>,
2930
}
3031

@@ -35,6 +36,12 @@ impl Default for Config {
3536
loop_sleep_ms: 250,
3637
send_sleep_ms: 250,
3738
swap_lighting: true,
39+
profiles: vec![
40+
String::from("Typing Profile"),
41+
String::from("Rapid Profile"),
42+
String::from("Racing Profile"),
43+
String::from("Mixed Movement"),
44+
],
3845
rules: vec![
3946
Rule {
4047
app_name: None,

src/main.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
22
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
33

4-
use std::{ffi::OsStr, sync::Arc, time::Duration};
4+
use std::{ffi::OsStr, time::Duration};
55

66
use active_win_pos_rs::ActiveWindow;
77
use anyhow::Result;
@@ -20,18 +20,13 @@ use tauri::{
2020
SystemTrayMenuItem,
2121
};
2222
use wildflower::Pattern;
23+
use wootility::Wootility;
2324
use wooting_profile_switcher as wps;
2425

2526
use crate::config::{Config, Rule};
2627

2728
mod config;
28-
29-
const MENU_ITEMS: [&str; 4] = [
30-
"Digital Profile",
31-
"Analog Profile 1",
32-
"Analog Profile 2",
33-
"Analog Profile 3",
34-
];
29+
mod wootility;
3530

3631
#[derive(Debug, Parser)]
3732
#[command(author, version, about)]
@@ -79,10 +74,20 @@ fn main() -> Result<()> {
7974
std::process::exit(0);
8075
}
8176

77+
// Load active profile names from Wootility
78+
if let Ok(wootility) = Wootility::load() {
79+
config.write().profiles = wootility
80+
.profiles
81+
.device
82+
.into_iter()
83+
.map(|device| device.details.name)
84+
.collect();
85+
}
86+
8287
let tray_handle = app.tray_handle();
8388
let mut system_tray_menu = SystemTrayMenu::new();
8489

85-
for (i, title) in MENU_ITEMS.into_iter().enumerate() {
90+
for (i, title) in config.read().profiles.iter().enumerate() {
8691
let id = &i.to_string();
8792
let menu_item = CustomMenuItem::new(id, title).selected();
8893
system_tray_menu = system_tray_menu.add_item(menu_item);
@@ -164,7 +169,7 @@ fn active_window_polling_task(app: AppHandle) -> Result<()> {
164169

165170
// Update the selected profile system tray menu item
166171
if let Some(profile_index) = args.read().profile_index {
167-
for i in 0..MENU_ITEMS.len() {
172+
for i in 0..config.read().profiles.len() {
168173
let id = &i.to_string();
169174
let tray_handle = app.tray_handle();
170175
let item_handle = tray_handle.get_item(id);

0 commit comments

Comments
 (0)