Skip to content

Instantly share code, notes, and snippets.

@cdrage
Created April 3, 2023 14:21
Show Gist options
  • Save cdrage/beb190a32eaf1909bf19c76f93f1f926 to your computer and use it in GitHub Desktop.
Save cdrage/beb190a32eaf1909bf19c76f93f1f926 to your computer and use it in GitHub Desktop.
systemd test with electron
import { Gio } from 'imports.gi';
const bus = Gio.bus_get_sync(Gio.BusType.SYSTEM);
const interface = 'org.freedesktop.systemd1.Manager';
const objectPath = '/org/freedesktop/systemd1';
// Create a proxy
const proxy = Gio.DBusProxy.new_sync(
bus,
Gio.DBusProxyFlags.NONE,
null,
'org.freedesktop.systemd1',
objectPath,
interface,
null
);
const enableUnitFilesResult = await proxy.call_method_sync(
'EnableUnitFiles',
new GLib.Variant('(sbb)', ['/path/to/unit/file.service', false, true]),
Gio.DBusCallFlags.NONE,
-1,
null
);
// Check the result
if (enableUnitFilesResult[0].get_boolean()) {
console.log('Unit file enabled successfully');
} else {
console.error('Failed to enable unit file');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment