Skip to content

Commit 28c1d07

Browse files
committed
COD-132: fix(deps): update rust crate toml to 0.9.0
1 parent 660d055 commit 28c1d07

File tree

5 files changed

+164
-53
lines changed

5 files changed

+164
-53
lines changed

CLAUDE.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
hyprland-autoname-workspaces is a Rust application that automatically renames Hyprland workspaces with icons based on running applications. It integrates with the Hyprland compositor's IPC system to monitor window events and update workspace names in real-time.
8+
9+
## Common Development Commands
10+
11+
### Building
12+
- `make build-dev` - Development build with feature flag and dependency updates
13+
- `make build` - Release build with locked dependencies
14+
- `cargo build` - Standard Rust build
15+
16+
### Testing
17+
- `make test` - Run all tests with locked dependencies
18+
- `cargo test` - Standard Rust test command
19+
- `cargo test --test <test_name>` - Run specific test
20+
21+
### Linting and Formatting
22+
- `make lint` - Run both formatter check and clippy linter
23+
- `cargo fmt` - Format code
24+
- `cargo clippy` - Run linter with warnings as errors
25+
26+
### Running
27+
- `make run` - Run the application
28+
- `cargo run -- -c path/to/config.toml` - Run with custom config
29+
30+
### Release Process
31+
- `make release` - Create new release with version bump and git tag
32+
33+
## Architecture Overview
34+
35+
### Core Components
36+
37+
1. **Main Entry Point** (`src/main.rs`):
38+
- Initializes the application
39+
- Sets up Hyprland event monitoring
40+
- Manages the main event loop
41+
42+
2. **Renamer Module** (`src/renamer/`):
43+
- `mod.rs` - Core renaming logic and workspace management
44+
- `formatter.rs` - Handles formatting of workspace names with placeholders
45+
- `icon.rs` - Icon mapping and resolution logic
46+
- `macros.rs` - Helper macros for the module
47+
48+
3. **Config Module** (`src/config/`):
49+
- Handles TOML configuration parsing
50+
- Manages config file watching for auto-reload
51+
- Provides default configuration generation
52+
53+
4. **Params Module** (`src/params/`):
54+
- Command-line argument parsing using clap
55+
56+
### Key Design Patterns
57+
58+
1. **Event-Driven Architecture**: The application subscribes to Hyprland IPC events and reacts to window/workspace changes.
59+
60+
2. **Regex-Based Matching**: Window classes and titles are matched using regex patterns for flexible icon assignment.
61+
62+
3. **Configuration Hot-Reload**: File system watching enables configuration changes without restart.
63+
64+
4. **Placeholder System**: Flexible formatting using placeholders like `{icon}`, `{class}`, `{title}`, etc.
65+
66+
## Testing Approach
67+
68+
Tests are integrated directly in source files using Rust's built-in testing framework:
69+
- Unit tests use `#[cfg(test)]` modules
70+
- Test functions are marked with `#[test]`
71+
- Key test locations: `src/renamer/mod.rs`, `src/config/mod.rs`, `src/renamer/formatter.rs`
72+
73+
## Configuration System
74+
75+
The application uses TOML configuration with these main sections:
76+
- `[format]` - Display formatting options
77+
- `[class]` - Application class to icon mappings
78+
- `[title_in_class]` - Title-based icon mappings within specific classes
79+
- `[exclude]` - Window exclusion rules
80+
- `[workspaces_name]` - Custom workspace names
81+
82+
Default config location: `~/.config/hyprland-autoname-workspaces/config.toml`
83+
84+
## Dependencies
85+
86+
Key dependencies (from Cargo.toml):
87+
- `hyprland` - Hyprland IPC integration
88+
- `clap` - Command-line parsing
89+
- `toml` & `serde` - Configuration handling
90+
- `regex` - Pattern matching
91+
- `notify` - File system watching
92+
93+
## Development Notes
94+
95+
1. The project is seeking maintainers (see README)
96+
2. Use `--features dev` for development builds
97+
3. The systemd service file enables automatic startup
98+
4. Icon generation helper script available at `contrib/generate_icons.py`
99+
5. All regex patterns support case-insensitive matching with `(?i)` flag

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ regex = "1"
1616
clap = { version = "4.3.19", features = ["derive"] }
1717
hyprland = { version = "=0.4.0-beta.2" }
1818
signal-hook = "0.3.17"
19-
toml = { version = "0.7.6", features = ["indexmap", "preserve_order"] }
19+
toml = { version = "0.9.0", features = ["preserve_order"] }
2020
xdg = "2.5.2"
2121
inotify = "0.10.2"
2222
serde = "1.0.181"

src/config/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ fn migrate_config_file(
255255

256256
pub fn create_default_config(cfg_path: &PathBuf) -> Result<String, Box<dyn Error + 'static>> {
257257
// TODO: maybe we should dump the config from the default values of the struct?
258-
let default_config = format!(r#"version = "{VERSION}"
258+
let default_config = format!(
259+
r#"version = "{VERSION}"
259260
260261
# [format]
261262
# Deduplicate icons if enable.
@@ -349,7 +350,8 @@ aProgram = "^$" # will match null title for aProgram
349350
9 = "nine"
350351
10 = "ten"
351352
352-
"#);
353+
"#
354+
);
353355

354356
let mut config_file = File::create(cfg_path)?;
355357
write!(&mut config_file, "{}", default_config.trim())?;

src/renamer/mod.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use std::error::Error;
1919
use std::path::PathBuf;
2020
use std::sync::{Arc, Mutex};
2121

22+
type WorkspaceClients = HashMap<i32, Vec<(AppClient, (i16, i16))>>;
23+
2224
pub struct Renamer {
2325
known_workspaces: Mutex<HashSet<i32>>,
2426
cfg: Mutex<Config>,
@@ -151,7 +153,7 @@ impl Renamer {
151153
active_client: String,
152154
config: &ConfigFile,
153155
) -> Result<Vec<AppWorkspace>, Box<dyn Error + '_>> {
154-
let mut workspaces: HashMap<i32, Vec<(AppClient, (i16, i16))>> = self
156+
let mut workspaces: WorkspaceClients = self
155157
.known_workspaces
156158
.lock()?
157159
.iter()
@@ -164,25 +166,22 @@ impl Renamer {
164166
let workspace_id = client.workspace.id;
165167
self.known_workspaces.lock()?.insert(workspace_id);
166168
let is_active = active_client == client.address.to_string();
167-
workspaces
168-
.entry(workspace_id)
169-
.or_insert_with(Vec::new)
170-
.push((
171-
AppClient::new(
172-
client.clone(),
169+
workspaces.entry(workspace_id).or_default().push((
170+
AppClient::new(
171+
client.clone(),
172+
is_active,
173+
is_dedup_inactive_fullscreen,
174+
self.parse_icon(
175+
client.initial_class,
176+
client.class,
177+
client.initial_title,
178+
client.title,
173179
is_active,
174-
is_dedup_inactive_fullscreen,
175-
self.parse_icon(
176-
client.initial_class,
177-
client.class,
178-
client.initial_title,
179-
client.title,
180-
is_active,
181-
config,
182-
),
180+
config,
183181
),
184-
client.at,
185-
));
182+
),
183+
client.at,
184+
));
186185
}
187186

188187
Ok(workspaces

0 commit comments

Comments
 (0)