Skip to main content

Config

Struct Config 

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

The heart of the River configuration, holding values for default and mouse-related keybinds, colors and modifier

Each value can only be changed with methods, because it is Rust, baby! For more info, check associated structs and implemented methods.

Implementations§

Source§

impl Config

Source§

impl Config

Source

pub fn set_keybind(&mut self, keys: &str, command: &str) -> &mut Self

Sets the single keybind

§Example
use river_rs::config::Config;

let mut config = Config::default();
let key = String::from("Q");
let command = String::from("spanw foo");
config.set_keybind(&key, &command);
Source

pub fn set_keybinds(&mut self, keybinds: Vec<[&str; 2]>) -> &mut Self

Sets keybinds based on the vector of lists with 2 values

Second command can be written with spaces, no need to define every argument separatly.

Takes the ownership of the vector and modifies it to supply riverctl

§Examples
use river_rs::config::Config;

let mut config = Config::default();
let keybinds = vec![
  ["Q", "spawn foo"],
  ["E", "exit"],
  ["M", "spawn bruh"]
];
config.set_keybinds(keybinds);
Source

pub fn set_mouse_keybinds( &mut self, left: Option<&str>, right: Option<&str>, middle: Option<&str>, ) -> &mut Self

Every keybind is optional, so you can just provide it with None keyword

§Example
use river_rs::config::Config;

let mut config = Config::default();
config.set_mouse_keybinds(Some("move-view"), Some("resize-view"), None);
Source§

impl Config

Source

pub fn set_repeat(&mut self, repeat_rate: u32, repeat_delay: u32) -> &mut Self

Sets xkb settings related to repeat_rate and repeat_delay.

The typematic delay indicates the amount of time (typically in milliseconds) a key needs to be pressed and held in order for the repeating process to begin. After the repeating process has been triggered, the character will be repeated with a certain frequency (usually given in Hz) specified by the typematic rate. (Taken from the Arch Wiki)

Source

pub fn set_layout_generator(&mut self, layout: Layout) -> &mut Self

Source

pub fn set_keyboard_layout(&mut self, layout: KeyboardLayout<&str>) -> &mut Self

Set xkb settings for window manager. To check available settings, look at KeyboardLayout struct.

Source

pub fn change_super(&mut self, key: &str) -> &mut Self

Changes the River Modifier key.

Useful when chaining set_keybinds with different modifiers.

§Example
use river_rs::config::Config;

let mut config = Config::default();

let keybinds = vec![
    ["C", "close"],
    ["J", "focus-view next"],
    ["K", "focus-view previous"],
];
let shift_keybinds = vec![
    ["E", "exit"],
    ["J", "swap next"],
    ["K", "swap previous"],
];
config
    .set_keybinds(keybinds)
    .change_super("Super+Shift")
    .set_keybinds(shift_keybinds)
    .apply()
    .unwrap();
Source

pub fn set_tags(&mut self, modifier: &str, switch_modifier: &str) -> &mut Self

Sets tags from 1 to 9 based on passed modifiers

Source

pub fn autostart(&mut self, applications: Vec<&str>) -> &mut Self

Set your autostart programs to spawn on launching River

§Example
use crate::river_rs::config::Config;
let autostart = vec![
    "firefox",
    "kitty"
];

let mut config = Config::default();
config.autostart(autostart);
Source

pub fn apply(&mut self) -> Result<()>

Finish setting up the config.

Needs to be run at the end of setup via chaining.

Trait Implementations§

Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

Creates empty config with no keybinds.

The default modifier is Super. To check the default colors visit Colors struct.

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, 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.