Created
February 2, 2022 04:40
-
-
Save DevSrSouza/b013d1a8119f50615a493b36cf0b9b56 to your computer and use it in GitHub Desktop.
Revisions
-
DevSrSouza created this gist
Feb 2, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ @file:DependsOn("com.github.hypfvieh:dbus-java-core:4.0.0") @file:DependsOn("com.github.hypfvieh:dbus-java-transport-jnr-unixsocket:4.0.0") @file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.0") import org.freedesktop.dbus.annotations.DBusInterfaceName import org.freedesktop.dbus.connections.impl.DBusConnection import org.freedesktop.dbus.interfaces.DBusInterface import org.freedesktop.dbus.types.Variant val connection = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION) @DBusInterfaceName("org.freedesktop.portal.Settings") interface SettingsInterface : DBusInterface { fun Read(namespace: String, key: String): Variant<*> } val settingsInterface = connection.getRemoteObject( "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", SettingsInterface::class.java ) val theme = settingsInterface.Read("org.freedesktop.appearance", "color-scheme") fun recursiveVariantValue(variant: Variant<*>): Any { val value = variant.value if(value !is Variant<*>) return value else return recursiveVariantValue(value) } println(recursiveVariantValue(theme))