SpellLock

Struct SpellLock 

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

SpellLock is a struct which represents a window lock. It can be run and initialised on a custom lockscreen implementation with slint.

Remember, with great power comes great responsibility. The struct doen't implement pointer events so you would need to make sure that your lock screen has a text input field and it is in focus on startup. Also spell doesn't add any restrictions on what you can have in your lockscreen so that is a bonus
Know limitations include the abscence to verify from fingerprints and unideal issues on multi-monitor setup. You can add the path of binary of your lock in your compositor config and idle manager config to use the program. It will be linked to spell-cli directly in coming releases.

§Example

Here is a minimal example.

use std::{env, error::Error, time::Duration};

use slint::ComponentHandle;
use spell_framework::{
    layer_properties::{TimeoutAction, Timer},
    wayland_adapter::{run_lock, SpellLock, SpellSlintLock},
};
slint::include_modules!();

fn main() -> Result<(), Box<dyn Error>> {
    let (mut lock, event_loop, event_queue, handle) = SpellLock::invoke_lock_spell();
    let lock_ui = LockScreen::new().unwrap();
    let looop_handle = event_loop.handle().clone();
    SpellSlintLock::build(&mut lock, handle);
    lock_ui.on_check_pass({
        let lock_handle = lock_ui.as_weak();
        move |string_val| {
            // let lock_handle_a = lock_handle.clone();
            let lock_handle_a = lock_handle.clone().unwrap();
            looop_handle
                .insert_source(
                    Timer::from_duration(Duration::from_secs(5)),
                    move |_, _, app_data| {
                        if app_data.unlock(None, string_val.as_str()).is_err() {
                            lock_handle_a.set_lock_error(true);
                        }
                        TimeoutAction::Drop
                    },
                )
                .unwrap();
        }
    });

    run_lock(lock, event_loop, event_queue)
}

Implementations§

Source§

impl SpellLock

Source

pub fn invoke_lock_spell() -> (Self, EventLoop<'static, SpellLock>, EventQueue<SpellLock>)

Source

pub fn unlock( &mut self, username: Option<&str>, password: &str, ) -> PamResult<()>

call this method to unlock Spelllock

Trait Implementations§

Source§

impl CompositorHandler for SpellLock

Source§

fn scale_factor_changed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _new_factor: i32, )

The surface has either been moved into or out of an output and the output has a different scale factor.
Source§

fn transform_changed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _new_transform: Transform, )

The surface has either been moved into or out of an output and the output has different transform.
Source§

fn frame( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, _surface: &WlSurface, _time: u32, )

A frame callback has been completed. Read more
Source§

fn surface_enter( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _output: &WlOutput, )

The surface has entered an output.
Source§

fn surface_leave( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _output: &WlOutput, )

The surface has left an output.
Source§

impl Dispatch<ExtSessionLockManagerV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockManagerV1, event: <ExtSessionLockManagerV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ExtSessionLockSurfaceV1, SessionLockSurfaceData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockSurfaceV1, event: <ExtSessionLockSurfaceV1 as Proxy>::Event, data: &SessionLockSurfaceData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ExtSessionLockV1, SessionLockData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockV1, event: <ExtSessionLockV1 as Proxy>::Event, data: &SessionLockData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlCallback, WlSurface> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlCallback, event: <WlCallback as Proxy>::Event, data: &WlSurface, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlCompositor, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlCompositor, event: <WlCompositor as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlKeyboard, KeyboardData<SpellLock>> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlKeyboard, event: <WlKeyboard as Proxy>::Event, data: &KeyboardData<SpellLock>, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlOutput, OutputData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlOutput, event: <WlOutput as Proxy>::Event, data: &OutputData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlRegistry, GlobalListContents> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlRegistry, event: <WlRegistry as Proxy>::Event, data: &GlobalListContents, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlSeat, SeatData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlSeat, event: <WlSeat as Proxy>::Event, data: &SeatData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlShm, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlShm, event: <WlShm as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlSurface, SurfaceData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlSurface, event: <WlSurface as Proxy>::Event, data: &SurfaceData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ZxdgOutputManagerV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ZxdgOutputManagerV1, event: <ZxdgOutputManagerV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ZxdgOutputV1, OutputData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ZxdgOutputV1, event: <ZxdgOutputV1 as Proxy>::Event, data: &OutputData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl KeyboardHandler for SpellLock

Source§

fn enter( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _surface: &WlSurface, _serial: u32, _raw: &[u32], _keysyms: &[Keysym], )

The keyboard has entered a surface. Read more
Source§

fn leave( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _surface: &WlSurface, _serial: u32, )

The keyboard has left a surface. Read more
Source§

fn press_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, event: KeyEvent, )

A key has been pressed on the keyboard. Read more
Source§

fn release_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, event: KeyEvent, )

A key has been released. Read more
Source§

fn update_modifiers( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, _modifiers: Modifiers, _raw_modifiers: RawModifiers, _layout: u32, )

Keyboard modifiers have been updated. Read more
Source§

fn repeat_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, _event: KeyEvent, )

A key has been previously pressed and is now repeating. Read more
Source§

fn update_repeat_info( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _info: RepeatInfo, )

The keyboard has updated the rate and delay between repeating key inputs. Read more
Source§

fn update_keymap( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _keymap: Keymap<'_>, )

Keyboard keymap has been updated. Read more
Source§

impl OutputHandler for SpellLock

Source§

fn output_state(&mut self) -> &mut OutputState

Source§

fn new_output( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

A new output has been advertised.
Source§

fn update_output( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

An existing output has changed.
Source§

fn output_destroyed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

An output is no longer advertised. Read more
Source§

impl ProvidesRegistryState for SpellLock

Source§

fn registry(&mut self) -> &mut RegistryState

Returns a mutable reference to the registry state.
Source§

fn runtime_add_global( &mut self, conn: &Connection, qh: &QueueHandle<Self>, name: u32, interface: &str, version: u32, )

Called when a new global has been advertised by the compositor. Read more
Source§

fn runtime_remove_global( &mut self, conn: &Connection, qh: &QueueHandle<Self>, name: u32, interface: &str, )

Called when a global has been destroyed by the compositor.
Source§

impl SeatHandler for SpellLock

Source§

fn seat_state(&mut self) -> &mut SeatState

Source§

fn new_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: WlSeat)

A new seat has been created. Read more
Source§

fn new_capability( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, seat: WlSeat, capability: Capability, )

A new capability is available on the seat. Read more
Source§

fn remove_capability( &mut self, _conn: &Connection, _: &QueueHandle<Self>, _: WlSeat, capability: Capability, )

A capability has been removed from the seat. Read more
Source§

fn remove_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: WlSeat)

A seat has been removed. Read more
Source§

impl SessionLockHandler for SpellLock

Source§

fn locked( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _session_lock: SessionLock, )

The session lock is active, and the client may create lock surfaces.
Source§

fn finished( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _session_lock: SessionLock, )

Session lock is not active and should be destroyed. Read more
Source§

fn configure( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, _surface: SessionLockSurface, _configure: SessionLockSurfaceConfigure, _serial: u32, )

Compositor has requested size for surface.
Source§

impl ShmHandler for SpellLock

Source§

fn shm_state(&mut self) -> &mut Shm

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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