Created
April 3, 2023 14:21
-
-
Save cdrage/beb190a32eaf1909bf19c76f93f1f926 to your computer and use it in GitHub Desktop.
systemd test with electron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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