Skip to main content

Module remote_desktop

Module remote_desktop 

Source
Available on crate feature remote_desktop only.
Expand description

Start a remote desktop session and interact with it.

§Examples

use ashpd::desktop::{
    PersistMode,
    remote_desktop::{DeviceType, KeyState, RemoteDesktop, SelectDevicesOptions},
};

async fn run() -> ashpd::Result<()> {
    let proxy = RemoteDesktop::new().await?;
    let session = proxy.create_session(Default::default()).await?;
    proxy
        .select_devices(
            &session,
            SelectDevicesOptions::default()
                .set_devices(DeviceType::Keyboard | DeviceType::Pointer),
        )
        .await?;

    let response = proxy
        .start(&session, None, Default::default())
        .await?
        .response()?;
    println!("{:#?}", response.devices());

    // 13 for Enter key code
    proxy
        .notify_keyboard_keycode(&session, 13, KeyState::Pressed, Default::default())
        .await?;

    Ok(())
}

You can also use the Remote Desktop portal with the ScreenCast one. In order to do so, you need to call Screencast::select_sources() on the session created with RemoteDesktop::create_session()

use ashpd::desktop::{
    PersistMode,
    remote_desktop::{DeviceType, KeyState, RemoteDesktop, SelectDevicesOptions},
    screencast::{CursorMode, Screencast, SelectSourcesOptions, SourceType},
};

async fn run() -> ashpd::Result<()> {
    let remote_desktop = RemoteDesktop::new().await?;
    let screencast = Screencast::new().await?;
    let session = remote_desktop.create_session(Default::default()).await?;

    remote_desktop
        .select_devices(
            &session,
            SelectDevicesOptions::default()
                .set_devices(DeviceType::Keyboard | DeviceType::Pointer),
        )
        .await?;
    screencast
        .select_sources(
            &session,
            SelectSourcesOptions::default()
                .set_cursor_mode(CursorMode::Metadata)
                .set_sources(SourceType::Monitor | SourceType::Window)
                .set_multiple(true)
                .set_persist_mode(PersistMode::DoNot),
        )
        .await?;

    let response = remote_desktop
        .start(&session, None, Default::default())
        .await?
        .response()?;
    println!("{:#?}", response.devices());
    println!("{:#?}", response.streams());

    // 13 for Enter key code
    remote_desktop
        .notify_keyboard_keycode(&session, 13, KeyState::Pressed, Default::default())
        .await?;

    Ok(())
}

Structs§

ConnectToEISOptions
Specified options for a RemoteDesktop::connect_to_eis request.
NotifyKeyboardKeycodeOptions
Specified options for a RemoteDesktop::notify_keyboard_keycode request.
NotifyKeyboardKeysymOptions
Specified options for a RemoteDesktop::notify_keyboard_keysym request.
NotifyPointerAxisDiscreteOptions
Specified options for a RemoteDesktop::notify_pointer_axis_discrete request.
NotifyPointerAxisOptions
Specified options for a RemoteDesktop::notify_pointer_axis request.
NotifyPointerButtonOptions
Specified options for a RemoteDesktop::notify_pointer_button request.
NotifyPointerMotionAbsoluteOptions
Specified options for a RemoteDesktop::notify_pointer_motion_absolute request.
NotifyPointerMotionOptions
Specified options for a RemoteDesktop::notify_pointer_motion request.
NotifyTouchDownOptions
Specified options for a RemoteDesktop::notify_touch_down request.
NotifyTouchMotionOptions
Specified options for a RemoteDesktop::notify_touch_motion request.
NotifyTouchUpOptions
Specified options for a RemoteDesktop::notify_touch_up request.
RemoteDesktop
The interface lets sandboxed applications create remote desktop sessions.
SelectDevicesOptions
Specified options for a RemoteDesktop::select_devices request.
SelectedDevices
A response to a RemoteDesktop::select_devices request.
StartOptions
Specified options for a RemoteDesktop::start request.

Enums§

Axis
The available axis.
DeviceType
A bit flag for the available devices.
KeyState
The keyboard key state.