ubuntu_session 0.0.4 copy "ubuntu_session: ^0.0.4" to clipboard
ubuntu_session: ^0.0.4 copied to clipboard

PlatformLinux

Native Dart client library to access the GNOME Session Manager

ubuntu_session.dart #

Native Dart client library to access Ubuntu desktop session managers

CI codecov

Simplified API #

The simplified API provides a small set of methods common among different Ubuntu desktop managers. It will try to detect the current desktop environment and invoke the methods provided by the respective session manager.

Currently provided methods:

  • logout()
  • reboot()
  • shutdown()

If the desktop environment is unknwon (or the API is not implemented yet..) it will use systemd-logind as a fallback. Warning - the fallback API will not show a confirmation dialog for logout(), reboot() or shutdown(). You can use fallback: false to disable the fallback.

import 'package:ubuntu_session/ubuntu_session.dart';

void main() {
  final session = UbuntuSession();
  print('Detected desktop environment: ${session.desktop}');
  session.reboot();
}

GNOME Session Manager #

import 'package:dbus/dbus.dart';
import 'package:ubuntu_session/ubuntu_session.dart';

void main() async {
  final manager = GnomeSessionManager();
  await manager.connect();
  try {
    await manager.reboot();
  } on DBusMethodResponseException catch (e) {
    print('Error: $e');
  }
  await manager.close();
}

Implemented so far: #

org.gnome.SessionManager #

Methods

  • Shutdown()
  • Reboot()
  • CanShutdown()
  • IsSessionRunning()
  • Logout()
  • Inhibit()
  • Uninhibit()
  • IsInhibited()

Properties

  • Renderer
  • SessionName
  • SessionIsActive

Please refer to the GNOME Session documentation for further details.

MATE Session Manager #

import 'package:dbus/dbus.dart';
import 'package:ubuntu_session/ubuntu_session.dart';

void main() async {
  final manager = MateSessionManager();
  await manager.connect();
  try {
    await manager.shutdown();
  } on DBusMethodResponseException catch (e) {
    print('Error: $e');
  }
  await manager.close();
}

Implemented so far: #

org.gnome.SessionManager #

Methods

  • Shutdown()
  • CanShutdown()
  • IsSessionRunning()
  • Logout()
  • Inhibit()
  • Uninhibit()
  • IsInhibited()

Properties

  • Renderer

Please refer to the GNOME Session documentation for further details. Note that the MATE session manager only implements a subset of the org.gnome.SessionManager interface

Since Reboot is not provided by the MATE session manager, UbuntuSession().reboot() invokes the Shutdown method in the MATE desktop environment, as it shows a dialog that provides options to suspend, reboot and shutdown the system.

systemd-logind #

import 'package:ubuntu_session/ubuntu_session.dart';

void main() async {
  final manager = SystemdSessionManager();
  await manager.connect();
  await manager.reboot(true);
  await manager.close();
}

Implemented so far: #

org.freedesktop.login1.Manager #

Methods

  • Halt()
  • Hibernate()
  • PowerOff()
  • Reboot()
  • Suspend()
  • CanHalt()
  • CanHibernate()
  • CanPowerOff()
  • CanReboot()
  • CanSuspend()
  • ListSessions()
  • Inhibit()

Properties

  • OnExternalPower

org.freedesktop.login1.Session #

Methods

  • Lock()
  • Terminate()

Properties

  • Id
  • Active

Please refer to the systemd-logind documentation for further details.

Contributing to ubuntu_session.dart #

We welcome contributions! See the contribution guide for more details.

5
likes
140
pub points
76%
popularity

Publisher

verified publishercanonical.com

Native Dart client library to access the GNOME Session Manager

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MPL-2.0 (LICENSE)

Dependencies

dbus, meta

More

Packages that depend on ubuntu_session