Struct ConfigBuilder

Source
pub struct ConfigBuilder { /* private fields */ }
Expand description

Builder struct for generating user Config

§Example

use penrose::core::{config::Config, layout::{LayoutConf, Layout, side_stack, monocle}};

fn my_layouts() -> Vec<Layout> {
    let mono_conf = LayoutConf {
        follow_focus: true,
        gapless: true,
        ..Default::default()
    };
    let n_main = 1;
    let ratio = 0.6;

    vec![
        Layout::new("[side]", LayoutConf::default(), side_stack, n_main, ratio),
        Layout::new("[mono]", mono_conf, monocle, n_main, ratio),
    ]
}

let mut config_builder = Config::default().builder();
let config = config_builder
    .floating_classes(vec!["rofi", "dmenu", "dunst", "pinentry-gtk-2"])
    .layouts(my_layouts())
    .border_px(4)
    .focused_border("#ebdbb2")
    .unwrap()
    .build()
    .expect("failed to build config");

Implementations§

Source§

impl ConfigBuilder

Source

pub fn build(&self) -> Result<Config, String>

Validate and build the underlying struct

Source

pub fn workspaces<T, U>(&mut self, val: T) -> &mut ConfigBuilder
where T: IntoIterator<Item = U>, U: Into<String>,

Set the value of the initial available workspaces.

§Constraints

You must provide at least one workspace per screen

Source

pub fn floating_classes<T, U>(&mut self, val: T) -> &mut ConfigBuilder
where T: IntoIterator<Item = U>, U: Into<String>,

Set the value of the window classes that will always be considered floating

Source

pub fn layouts(&mut self, val: Vec<Layout>) -> &mut ConfigBuilder

Set the value of the Layout functions to be used by each Workspace

§Constraints

You must provide at least one layout function

Source

pub fn focused_border<T>(&mut self, val: T) -> Result<&mut ConfigBuilder>
where T: TryInto<Color, Error = DrawError>,

Set the value of the focused border color as a hex literal

Source

pub fn unfocused_border<T>(&mut self, val: T) -> Result<&mut ConfigBuilder>
where T: TryInto<Color, Error = DrawError>,

Set the value of the unfocused border color as a hex literal

Source

pub fn border_px(&mut self, val: u32) -> &mut ConfigBuilder

Set the value of the border width of each window in pixels

Source

pub fn gap_px(&mut self, val: u32) -> &mut ConfigBuilder

Set the value of the gap between tiled windows in pixels

Source

pub fn main_ratio_step(&mut self, val: f32) -> &mut ConfigBuilder

Set the value of the percentage of the screen to grow the main region by when incrementing

Source

pub fn show_bar(&mut self, val: bool) -> &mut ConfigBuilder

Set the value of whether or not space should be reserved for a status bar

Source

pub fn top_bar(&mut self, val: bool) -> &mut ConfigBuilder

Set the value of whether or not the reserved space for a status bar is at the top of the sceen

Source

pub fn bar_height(&mut self, val: u32) -> &mut ConfigBuilder

Set the value of the height of the space to be reserved for a status bar in pixels

Trait Implementations§

Source§

impl Debug for ConfigBuilder

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more