Struct xrandr::XHandle

source ·
pub struct XHandle { /* private fields */ }

Implementations§

source§

impl XHandle

source

pub fn open() -> Result<Self, XrandrError>

Open a handle to the lib-xrandr backend. This will be used for nearly all interactions with the xrandr lib

Errors
  • XrandrError::Open - Getting the handle failed.
Examples
let xhandle = XHandle.open()?;
let mon1 = xhandle.monitors()?[0];
source

pub fn monitors(&mut self) -> Result<Vec<Monitor>, XrandrError>

List every monitor

Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let mon1 = xhandle.monitors()?[0];
source

pub fn all_outputs(&mut self) -> Result<Vec<Output>, XrandrError>

List every monitor’s outputs

Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = xhandle.all_outputs()?[0];
source

pub fn enable(&mut self, output: &Output) -> Result<(), XrandrError>

Enable the given output by setting it to its preferred mode

Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = xhandle.all_outputs()?[0];
xhandle.enable(dp_1)?;
source

pub fn disable(&mut self, output: &Output) -> Result<(), XrandrError>

Disable the given output

Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = xhandle.all_outputs()?[0];
xhandle.disable(dp_1)?;
source

pub fn set_primary(&mut self, o: &Output)

Sets the given output as the primary output

Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = xhandle.all_outputs()?[0];
xhandle.set_primary(dp_1)?;
source

pub fn set_mode( &mut self, output: &Output, mode: &Mode ) -> Result<(), XrandrError>

Sets the mode of a given output, relative to another

Arguments
  • output - The output to change mode for
  • mode - The mode to change to
Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = xhandle.all_outputs()?[0];
let mode = dp_1.preferred_modes[0];
xhandle.set_mode(dp_1, mode)?;
source

pub fn set_position( &mut self, output: &Output, relation: &Relation, relative_output: &Output ) -> Result<(), XrandrError>

Sets the position of a given output, relative to another

Arguments
  • output - The output to reposition
  • relation - The relation output will have to rel_output
  • rel_output - The output to position relative to
Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = outputs[0];
let hdmi_1 = outputs[3];
xhandle.set_position(dp_1, Relation::LeftOf, hdmi_1)?;
source

pub fn set_rotation( &mut self, output: &Output, rotation: &Rotation ) -> Result<(), XrandrError>

Sets the position of a given output, relative to another

Arguments
  • output - The output to rotate
  • rotation
Errors
  • XrandrError::_ - various calls to the xrandr backend may fail
Examples
let dp_1 = outputs[0];
xhandle.set_rotation(dp_1, Rotation::Inverted)?;

Trait Implementations§

source§

impl Debug for XHandle

source§

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

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

impl Drop for XHandle

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.