HyprlandConfig

Struct HyprlandConfig 

Source
pub struct HyprlandConfig {
    pub content: Vec<String>,
    pub sections: HashMap<String, (usize, usize)>,
    pub sourced_content: Vec<Vec<String>>,
    pub sourced_sections: HashMap<String, (usize, usize)>,
    pub sourced_paths: Vec<String>,
}
Expand description

Core structure of the config

Fields§

§content: Vec<String>§sections: HashMap<String, (usize, usize)>§sourced_content: Vec<Vec<String>>§sourced_sections: HashMap<String, (usize, usize)>§sourced_paths: Vec<String>

Implementations§

Source§

impl HyprlandConfig

Source

pub fn new() -> Self

Source

pub fn parse(&mut self, config_str: &str, sourced: bool)

Parse one configuration file

Source

pub fn add_entry(&mut self, category: &str, entry: &str)

Add an entry to a mutable HyprlandConfig

Source

pub fn add_entry_headless(&mut self, key: &str, value: &str)

Add a headless entry to a mutable HyprlandConfig

Example of a headless entry in Hyprland’s configuration:

windowrulev2 = float,class:^(hyprutils.hyprwall)$
Source

pub fn add_sourced(&mut self, config: Vec<String>)

Source

pub fn parse_color(&self, color_str: &str) -> Option<(f32, f32, f32, f32)>

Parse a color from Hyprland’s config into float RGBA values

Examples:

let config = HyprlandConfig::new();

let rgba = config.parse_color("rgba(1E4632FF)");
let rgb = config.parse_color("rgb(1E4632)");
let argb = config.parse_color("0xFF1E4632");

let expected = Some((0.11764706, 0.27450982, 0.19607843, 1.0));

assert_eq!(expected, rgba);
assert_eq!(expected, rgb);
assert_eq!(expected, argb);
Source

pub fn format_color( &self, red: f32, green: f32, blue: f32, alpha: f32, ) -> String

Format a float RGBA color into Hyprland’s RGBA

Trait Implementations§

Source§

impl Debug for HyprlandConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HyprlandConfig

Source§

fn default() -> HyprlandConfig

Returns the “default value” for a type. Read more
Source§

impl Display for HyprlandConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for HyprlandConfig

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.