Module ashpd::desktop::remote_desktop
source · Expand description
Start a remote desktop session and interact with it.
§Examples
use ashpd::{
desktop::{
remote_desktop::{DeviceType, KeyState, RemoteDesktop},
PersistMode,
},
WindowIdentifier,
};
async fn run() -> ashpd::Result<()> {
let proxy = RemoteDesktop::new().await?;
let session = proxy.create_session().await?;
proxy
.select_devices(
&session,
DeviceType::Keyboard | DeviceType::Pointer,
None,
PersistMode::DoNot,
)
.await?;
let response = proxy
.start(&session, &WindowIdentifier::default())
.await?
.response()?;
println!("{:#?}", response.devices());
// 13 for Enter key code
proxy
.notify_keyboard_keycode(&session, 13, KeyState::Pressed)
.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::{
remote_desktop::{DeviceType, KeyState, RemoteDesktop},
screencast::{CursorMode, Screencast, SourceType},
PersistMode,
},
WindowIdentifier,
};
async fn run() -> ashpd::Result<()> {
let remote_desktop = RemoteDesktop::new().await?;
let screencast = Screencast::new().await?;
let identifier = WindowIdentifier::default();
let session = remote_desktop.create_session().await?;
remote_desktop
.select_devices(
&session,
DeviceType::Keyboard | DeviceType::Pointer,
None,
PersistMode::DoNot,
)
.await?;
screencast
.select_sources(
&session,
CursorMode::Metadata,
SourceType::Monitor | SourceType::Window,
true,
None,
PersistMode::DoNot,
)
.await?;
let response = remote_desktop
.start(&session, &identifier)
.await?
.response()?;
println!("{:#?}", response.devices());
println!("{:#?}", response.streams());
// 13 for Enter key code
remote_desktop
.notify_keyboard_keycode(&session, 13, KeyState::Pressed)
.await?;
Ok(())
}
Structs§
- The interface lets sandboxed applications create remote desktop sessions.
- A response to a
RemoteDesktop::select_devices
request.
Enums§
- The available axis.
- A bit flag for the available devices.
- The keyboard key state.