Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hyprutils/hyprparser
A parser for hyprland written in rust 🚀🦀
https://github.com/hyprutils/hyprparser
hyprland hyprutils parser rust wayland
Last synced: 2 months ago
JSON representation
A parser for hyprland written in rust 🚀🦀
- Host: GitHub
- URL: https://github.com/hyprutils/hyprparser
- Owner: hyprutils
- License: gpl-2.0
- Created: 2024-10-11T23:59:40.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-24T04:21:48.000Z (2 months ago)
- Last Synced: 2024-11-24T04:37:56.309Z (2 months ago)
- Topics: hyprland, hyprutils, parser, rust, wayland
- Language: Rust
- Homepage:
- Size: 88.9 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
HyprParser
A parser for Hyprland's configuration files written in Rust 🚀🦀
[![Crates.io Version](https://img.shields.io/crates/v/hyprparser)](https://crates.io/crates/hyprparser)
[Hyprland Configuration Documentation](https://wiki.hyprland.org/Configuring/Configuring-Hyprland)
## Usage
HyprParser is available on [Crates.io](https://crates.io/crates/hyprparser). It can be added as a dependency with:```bash
$ cargo add hyprparser
```Here's an example usage:
```toml
# Cargo.toml[dependencies]
hyprparser = "0.1.2"
``````rust
// main.rsuse hyprparser::parse_config;
use std::{env, fs, path::Path};fn main() {
let config_path = Path::new(&env::var("XDG_CONFIG_HOME").unwrap_or_else(|_| {
let home = env::var("HOME").unwrap_or_else(|_| ".".to_string());
format!("{}/.config", home)
}))
.join("hypr/hyprland.conf");let config_str = fs::read_to_string(&config_path).unwrap();
let mut parsed_config = parse_config(&config_str);
parsed_config.add_entry("decoration", "rounding = 10");
parsed_config.add_entry("decoration.blur", "enabled = true");
parsed_config.add_entry("decoration.blur", "size = 10");
parsed_config.add_entry_headless("$terminal", "kitty");let updated_config_str = parsed_config.to_string();
fs::write(&config_path, updated_config_str).unwrap();
println!("Updated hyprland.conf with new configuration.");
}
```## TODO
- [ ] Color formatting tests## Credits
- [Nyx](https://github.com/nnyyxxxx) - The parser (everything), [HyprGUI](https://github.com/hyprutils/hyprgui)
- [Adam](https://github.com/adamperkowski) - Code optimization, unit tests, documentation updates, [HyprGUI](https://github.com/hyprutils/hyprgui)
- [Vaxry](https://github.com/vaxerski) - Hyprland
- [Hyprland](https://github.com/hyprwm/Hyprland) - The wayland compositorCopyright (C) 2024 HyprUtils