0 purchases
ubuntu session
ubuntu_session.dart #
Native Dart client library to access Ubuntu desktop session managers
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();
}
copied to clipboard
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();
}
copied to clipboard
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();
}
copied to clipboard
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();
}
copied to clipboard
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.