GlobalShortcutsPortal

class GlobalShortcutsPortal(connection: DBusConnection)(source)

Wrapper around the org.freedesktop.portal.GlobalShortcuts D-Bus interface. Provides convenient methods to register and listen for global keyboard shortcuts.

This portal maintains an active session internally. After calling createSession, shortcuts can be bound using bindShortcuts and activation events can be observed via activations.

Constructors

Link copied to clipboard
constructor(connection: DBusConnection)

Properties

Link copied to clipboard
val activeSession: DBusPath?

The currently active session handle, set automatically by createSession.

Link copied to clipboard

Returns the interface version.

Functions

Link copied to clipboard

Returns a Flow of shortcut activation events for the active session.

Link copied to clipboard
suspend fun bindShortcuts(shortcuts: List<Shortcut>, parentWindow: String = ""): Result<List<BoundShortcut>>

Bind shortcuts to the active session. This allows the application to receive activation events when the user triggers the shortcuts.

suspend fun bindShortcuts(sessionHandle: DBusPath, shortcuts: List<Shortcut>, parentWindow: String = ""): Result<List<BoundShortcut>>

Bind shortcuts to the session. This allows the application to receive activation events when the user triggers the shortcuts.

Link copied to clipboard

Clears the active session.

Link copied to clipboard
fun configureShortcuts(parentWindow: String = ""): Result<Unit>

Opens the system dialog for configuring shortcuts using the active session.

fun configureShortcuts(sessionHandle: DBusPath, parentWindow: String = ""): Result<Unit>

Opens the system dialog for configuring shortcuts.

Link copied to clipboard

Creates a new global shortcuts session and sets it as the active session.

Link copied to clipboard

List all shortcuts bound to the active session.

suspend fun listShortcuts(sessionHandle: DBusPath): Result<List<BoundShortcut>>

List all shortcuts bound to the session.

Link copied to clipboard

Returns a Flow that emits when the active session is closed.