Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for color-scheme preference on Linux #51

Merged
merged 17 commits into from
Mar 29, 2023

Conversation

l0drex
Copy link
Contributor

@l0drex l0drex commented Apr 14, 2022

Linux support for all desktops that implement the color-scheme preference. Implementation is based on this gist.
First time using Gradle and Kotlin, any help is welcome 😄


Fix #56
Fix #50
Fix #33
Fix #20

@l0drex
Copy link
Contributor Author

l0drex commented Apr 14, 2022

I wasn't able to run it yet, it always hangs while processing resources and compiling Kotlin

Copy link
Owner

@weisJ weisJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments. I'm not sure why it's spinning on prepareResources for you though. What command are you using for building? Also this doesn't seem to actually implement detecting changes to the org.freedesktop.appearance/color-scheme. Will this be added?

linux/xdg-desktop-portal/build.gradle.kts Outdated Show resolved Hide resolved
linux/xdg-desktop-portal/build.gradle.kts Outdated Show resolved Hide resolved
linux/xdg-desktop-portal/build.gradle.kts Outdated Show resolved Hide resolved
@l0drex
Copy link
Contributor Author

l0drex commented Apr 14, 2022

I can implement detecting changes, there is a signal for that. For now, I just wanted basic functionality and worry about that once I know the concept works.

To test the implementation, I wrote a test under .../xdg-desktop-portal/src/test/... and run it using the green arrow that IDEA shows next to the test. I also tried to write scratch files, but that didn't work either. Please let me know if there is a better way 😅

@weisJ
Copy link
Owner

weisJ commented Apr 15, 2022

To test the implementation, I wrote a test under .../xdg-desktop-portal/src/test/... and run it using the green arrow that IDEA shows next to the test. I also tried to write scratch files, but that didn't work either. Please let me know if there is a better way 😅

You'll have to setup the gradle project to use junit.

depenencies {
...
testImplementation(libs.test.junit.api)
testRuntimeOnly(libs.test.junit.engine)
}

tasks  {
    test {
        testLogging {
            exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
            showStandardStreams = true
        }
        useJUnitPlatform()
    }
}

IntelliJ should automatically pick up the gradel task to run tests. If not use gradlew :auto-dark-mode-linux-xdg-desktop-portal:test

If you run into the build spinning on prepareResources you can try to run gradlew build [whatever command you wanted to execute]. It seems like there are same issues with task ordering where multiple tasks wait on each other causing the dead-lock. I'll have to investigate what is causing it.

@l0drex
Copy link
Contributor Author

l0drex commented Apr 16, 2022

Thanks a lot, its now working!

I now have some questions on the implementation:

  1. Should isDarkThemeEnabled throw an exception if its not supported (or otherwise does not know what theme is active) or should it rather return dark / light as a fallback?
  2. There is no way to detect high contrast themes yet, should I leave that TODO as is or return a value?

@weisJ
Copy link
Owner

weisJ commented Apr 18, 2022

Thanks a lot, its now working!

I now have some questions on the implementation:

  1. Should isDarkThemeEnabled throw an exception if its not supported (or otherwise does not know what theme is active) or should it rather return dark / light as a fallback?

In this case it should just return the current state i.e. not result in a change at all.

  1. There is no way to detect high contrast themes yet, should I leave that TODO as is or return a value?

Please simply return false in this case.

@l0drex
Copy link
Contributor Author

l0drex commented Apr 18, 2022

I have some issues implementing the event handling. I guess createEventHandler and deleteEventHandler both implement an observer pattern and are called to register or remove event handlers. The creator returns a pointer to the registered callback, whereas the delete method points to the callback that should be deleted.
My issue is the NativePointer type. From what I understand, these are used together with C/C++ code, but I don't have that.
I found a way to cast the native pointer in the delete method to a callable:

val callback = eventHandle.castSafelyTo<() -> Unit>()

However, I couldn't find a way to cast a callable to a native pointer...

Another thing I couldn't find was a way to return the currently used theme mode of the IDE. Is there a boolean that stores the current theme mode, or can I check if the currently used theme is dark?

@weisJ
Copy link
Owner

weisJ commented Apr 19, 2022

I have some issues implementing the event handling. I guess createEventHandler and deleteEventHandler both implement an observer pattern and are called to register or remove event handlers. The creator returns a pointer to the registered callback, whereas the delete method points to the callback that should be deleted. My issue is the NativePointer type. From what I understand, these are used together with C/C++ code, but I don't have that.

The contract of the class is that createEventHandler and deleteEventHandler are only called once (and after each other).
In createEventHandler you can simply initialize the listener and return any NativePointer e.g. NativePointer(0). Then in
deleteEventHandler just revert whatever happened during initialization. No need for casting.

However, I couldn't find a way to cast a callable to a native pointer...

Because it isn't possible ;)

Another thing I couldn't find was a way to return the currently used theme mode of the IDE. Is there a boolean that stores the current theme mode, or can I check if the currently used theme is dark?

There are two options here. Either keep track of the current state yourself and return it, or change the type of callback from () -> Unit to ThemeInfo -> Unit, where

data class ThemeInfo(val isDark, val isHighContrast)

You'll have to adjust the interface of ThemeMonitorService and implementations/usage accordingly.

@l0drex
Copy link
Contributor Author

l0drex commented Apr 24, 2022

I looked a bit deeper through the code and I found that if isSupported is false, an exception is thrown and isDarkThemeEnabled is never called, so the value of that when not supported doesn't matter I guess.

@l0drex l0drex marked this pull request as ready for review April 24, 2022 10:43
@zliuva
Copy link
Contributor

zliuva commented Apr 28, 2022

I wasn't able to run it yet, it always hangs while processing resources and compiling Kotlin

I ran into a similar issue and the solution for me was to disable parallel builds, in gradle.properties, set org.gradle.parallel = false (from true)

@weisJ
Copy link
Owner

weisJ commented Apr 28, 2022

XdgThemeMonitorService still isn't used at all. You'll have to return it in https://github.com/weisJ/auto-dark-mode/blob/master/linux/src/main/java/com/github/weisj/darkmode/platform/linux/LinuxThemeMonitorService.kt
I would advise to check whether isSupported is true in there. Please don't remove the Gnome implementation, but use the xdg one as the alternative.

@l0drex l0drex changed the title Support for linux Support for open desktops color-scheme preference on Linux May 2, 2022
@l0drex l0drex changed the title Support for open desktops color-scheme preference on Linux Support for color-scheme preference on Linux May 2, 2022
@l0drex
Copy link
Contributor Author

l0drex commented May 12, 2022

There seems to be a deadlock somewhere, when I run the IDE it spins endlessly (at task runIDE) and never opens the window. I have disabled org.gradle.parallel as suggested by @zliuva which fixed the spin with resources, but not this one. I also let IDEA search for cyclic dependencies, but it couldn't find any.
I noticed that it fails to load xapp, canberry and appmenu, but from my googling that doesn't seem to be the problem.

Any suggestions? 😅


Debug Log
...
2022-05-12T18:10:35.399+0200 [DEBUG] [org.jetbrains.intellij.IntelliJPlugin] [gradle-intellij-plugin :auto-dark-mode-pluginauto-dark-mode-plugin:auto-dark-mode-plugin:runIde] Runtime specified with ideDir='/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1', version='11_0_14_1b2043.25' resolved as: /home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java
2022-05-12T18:10:35.399+0200 [INFO] [org.jetbrains.intellij.IntelliJPlugin] [gradle-intellij-plugin :auto-dark-mode-pluginauto-dark-mode-plugin:auto-dark-mode-plugin:runIde] Resolved JVM Runtime directory: /home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java
2022-05-12T18:10:35.399+0200 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'command '/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java''. Working directory: /home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/bin Command: /home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java -Didea.auto.reload.plugins=true -Didea.classpath.index.enabled=false -Didea.config.path=/home/l0drex/Projekte/auto-dark-mode/plugin/build/idea-sandbox/config -Didea.is.internal=true -Didea.platform.prefix=Idea -Didea.plugins.path=/home/l0drex/Projekte/auto-dark-mode/plugin/build/idea-sandbox/plugins -Didea.required.plugins.id=com.github.weisj.darkmode -Didea.system.path=/home/l0drex/Projekte/auto-dark-mode/plugin/build/idea-sandbox/system -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Dsun.awt.disablegrab=true -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=DE -Duser.language=de -Duser.variant -ea -cp /home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/3rd-party-rt.jar:/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/util.jar:/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/util_rt.jar:/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/jna.jar com.intellij.idea.Main
2022-05-12T18:10:35.399+0200 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
2022-05-12T18:10:35.399+0200 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java'.
2022-05-12T18:10:35.400+0200 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
2022-05-12T18:10:35.400+0200 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
2022-05-12T18:10:35.400+0200 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_14_1-linux-x64-b2043.25/extracted/jbr/bin/java''
2022-05-12T18:10:35.520+0200 [ERROR] [system.err] WARNING: An illegal reflective access operation has occurred
An illegal reflective access operation has occurred

2022-05-12T18:10:35.520+0200 [ERROR] [system.err] WARNING: Illegal reflective access by com.intellij.util.lang.UrlClassLoader (file:/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/util.jar) to field java.lang.ClassLoader.classLoaderValueMap
Illegal reflective access by com.intellij.util.lang.UrlClassLoader (file:/home/l0drex/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/lib/util.jar) to field java.lang.ClassLoader.classLoaderValueMap

2022-05-12T18:10:35.520+0200 [ERROR] [system.err] WARNING: Please consider reporting this to the maintainers of com.intellij.util.lang.UrlClassLoader
Please consider reporting this to the maintainers of com.intellij.util.lang.UrlClassLoader

2022-05-12T18:10:35.520+0200 [ERROR] [system.err] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
Use --illegal-access=warn to enable warnings of further illegal reflective access operations

2022-05-12T18:10:35.520+0200 [ERROR] [system.err] WARNING: All illegal access operations will be denied in a future release
All illegal access operations will be denied in a future release

2022-05-12T18:10:35.827+0200 [ERROR] [system.err] Gtk-Message: 18:10:35.828: Failed to load module "xapp-gtk3-module"
2022-05-12T18:10:35.827+0200 [ERROR] [system.err] Gtk-Message: 18:10:35.828: Failed to load module "canberra-gtk-module"
2022-05-12T18:10:35.827+0200 [ERROR] [system.err] Gtk-Message: 18:10:35.828: Failed to load module "appmenu-gtk-module"
2022-05-12T18:10:36.552+0200 [ERROR] [system.err] 2022-05-12 18:10:36,551 [ 876] WARN - #c.i.i.DebugAttachDetector - Unable to start DebugAttachDetector, please add --add-exports java.base/jdk.internal.vm=ALL-UNNAMED to VM options
2022-05-12T18:10:36.852+0200 [ERROR] [system.err] 2022-05-12 18:10:36,852 [ 1177] WARN - #c.i.n.i.NotificationGroupManagerImpl - Notification group CodeWithMe is already registered (group=com.intellij.notification.NotificationGroup@7d6698aa). Plugin descriptor: PluginDescriptor(name=Code With Me, id=com.jetbrains.codeWithMe, descriptorPath=plugin.xml, path=~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.1/c91a19824ffcb28872ecd2761c83b250f703ff21/ideaIC-2022.1/plugins/cwm-plugin, version=221.5080.210, package=null, isBundled=true)
2022-05-12T18:10:38.941+0200 [LIFECYCLE] [org.gradle.cache.internal.DefaultFileLockManager]
...
2022-05-12T18:12:08.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2022-05-12T18:12:08.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(73)-127.0.0.1: accepted socket from [127.0.0.1:60090]
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(73)-127.0.0.1: (port 40771) op = 80
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.loader] RMI TCP Connection(73)-127.0.0.1: name = "[Ljava.rmi.server.ObjID;", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@5623f185
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.loader] RMI TCP Connection(73)-127.0.0.1: name = "java.rmi.dgc.Lease", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@5623f185
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.loader] RMI TCP Connection(73)-127.0.0.1: name = "java.rmi.dgc.VMID", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@5623f185
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.loader] RMI TCP Connection(73)-127.0.0.1: name = "[B", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@5623f185
2022-05-12T18:12:09.486+0200 [DEBUG] [sun.rmi.loader] RMI TCP Connection(73)-127.0.0.1: name = "java.rmi.server.UID", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@5623f185
2022-05-12T18:12:18.941+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
2022-05-12T18:12:18.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2022-05-12T18:12:18.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2022-05-12T18:12:18.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
2022-05-12T18:12:18.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2022-05-12T18:12:18.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2022-05-12T18:12:20.948+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(70)-127.0.0.1: (port 40771) connection closed
2022-05-12T18:12:20.948+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(70)-127.0.0.1: close connection
2022-05-12T18:12:21.047+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(71)-127.0.0.1: (port 40771) connection closed
2022-05-12T18:12:21.048+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(71)-127.0.0.1: close connection
2022-05-12T18:12:21.121+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(72)-127.0.0.1: (port 40771) connection closed
2022-05-12T18:12:21.121+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(72)-127.0.0.1: close connection
2022-05-12T18:12:24.487+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(73)-127.0.0.1: (port 40771) connection closed
2022-05-12T18:12:24.488+0200 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(73)-127.0.0.1: close connection
2022-05-12T18:12:28.941+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
2022-05-12T18:12:28.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2022-05-12T18:12:28.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2022-05-12T18:12:28.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
2022-05-12T18:12:28.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2022-05-12T18:12:28.942+0200 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
...

@weisJ
Copy link
Owner

weisJ commented May 13, 2022

Have you tried commenting out the code which creates the XdgThemeMonitorService?

@l0drex
Copy link
Contributor Author

l0drex commented May 23, 2022

Yes, when I do that it works.
I made some further debugging and this line seems to be the cause:

private val connection = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION)

I don't know why yet, but I did found another plugin that uses the dbus so that in itself shouldn't be a problem.
I tried to move the connection into the functions instead of using it as a class attribute, but that didn't fix it.

Comment on lines 10 to 13
private val freedesktopConnection = FreedesktopConnection()
private val sigHandler = SigHandler()
override val isDarkThemeEnabled: Boolean = freedesktopConnection.theme == ThemeMode.DARK
override val isSupported: Boolean = freedesktopConnection.theme != ThemeMode.ERROR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this. Calling out to system resources during class initialization makes debugging deadlocks rather difficult. This way you'll at least know which call is causing the lock (It might not be the creation of the connection but the theme call instead)

Suggested change
private val freedesktopConnection = FreedesktopConnection()
private val sigHandler = SigHandler()
override val isDarkThemeEnabled: Boolean = freedesktopConnection.theme == ThemeMode.DARK
override val isSupported: Boolean = freedesktopConnection.theme != ThemeMode.ERROR
private val freedesktopConnection by lazy { FreedesktopConnection() }
private val sigHandler = SigHandler()
override val isDarkThemeEnabled: Boolean
get() = freedesktopConnection.theme == ThemeMode.DARK
override val isSupported: Boolean
get() = freedesktopConnection.theme != ThemeMode.ERROR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it's the creation of the connection. When I comment everything out except the creation, the deadlock is still there 😅

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can’t comment out isDarkThemeEnabled and isSupported though as they need to be implemented in order for the class to compile. Did you stub them or what exactly do you mean by commenting out?
Also it would be beneficial to add some unit tests, testing whether it works in isolation outside IntelliJ.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to run IDE and plugin without the sandbox?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can’t comment out isDarkThemeEnabled and isSupported though as they need to be implemented in order for the class to compile. Did you stub them or what exactly do you mean by commenting out?
Also, it would be beneficial to add some unit tests, testing whether it works in isolation outside IntelliJ.

Didn't see that, sorry 😅

I just returned true and commented the rest out. I have unittests that I run regularly, but I didn't commit them as I don't know which theme is actually active

@l0drex
Copy link
Contributor Author

l0drex commented Jun 21, 2022

I have now another weird problem. I wanted to update the dbus-java dependency to the latest version in the libs.versinos.toml file, but there seems to be some sort of artifact of the old version somewhere.

Specifically, I need to change this:

private val connection = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION)

to this:

private val connection = DBusConnectionBuilder.forSessionBus().build()

This works when I test it in a new, empty project, but here it throws an error that DBusConnection.CONNECTIONS is private and can't be accessed. This was in the previous version of the library the case.

I checked the dependency menu in the Gradle toolbar, it only shows the correct version of the library. I deleted all build directories, cache directories, ~/.gradle and ~/.m2 and ran the clean task, but the issue persists.

@weisJ
Copy link
Owner

weisJ commented Jun 22, 2022

Are you sure this is a gradle issue and not something with your IDE? i.e. does running gradlew build work when called from the command line? Otherwise you can try to temporarily remove the dependency alltogether and do a build with the code depending on it commented out. I have never experienced this problem so I'm not quite sure what might be causing it.

@l0drex
Copy link
Contributor Author

l0drex commented Jun 23, 2022

Yes, it also happens when I run the build from the command line. Building with the dependency commented out didn't help, I even ran it on a different machine and have the same issue there.

@l0drex
Copy link
Contributor Author

l0drex commented Jul 1, 2022

To keep you updated, I made a post in the developer forum of JetBrains to see if they can help me with that endless spinning on runIde, but they have no idea either.

gradle/libs.versions.toml Outdated Show resolved Hide resolved
Comment on lines 32 to 68
private val connection: DBusConnection? = try {
// Temporarily replace the current tread's contextClassLoader to work around dbus-java's naive service loading
val ccl = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = javaClass.classLoader
val conn = DBusConnectionBuilder.forSessionBus().build()
Thread.currentThread().contextClassLoader = ccl
conn
} catch (_: DBusException) {
null
}
Copy link
Owner

@weisJ weisJ Jan 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is a similar "hack" used in ServiceUtil.java. This should probably be extracted into a separate helper method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that go into a new class, or is there a utility class where I could add that?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There currently isn't a good place to put it. Feel free to create a separate utility class for it.

@weisJ
Copy link
Owner

weisJ commented Jan 1, 2023

@l0drex
Copy link
Contributor Author

l0drex commented Jan 2, 2023

Also I was wondering whether we could apply this to the coroutines dependency aswell. Is it also already provided by IDEA?

It seems like it is, it looks like its marked as a dependency in intellij-community

@l0drex
Copy link
Contributor Author

l0drex commented Jan 2, 2023

I extracted the theme changer so that it can be used by other tests. I also added a theme changer for kde, however getting the currently used theme is not so straight forward. lookandfeeltool doesn't provide this, and other tools like kreadconfig5 seem to no longer be able to do this.

@weisJ
Copy link
Owner

weisJ commented Jan 2, 2023

I extracted the theme changer so that it can be used by other tests. I also added a theme changer for kde, however getting the currently used theme is not so straight forward. lookandfeeltool doesn't provide this, and other tools like kreadconfig5 seem to no longer be able to do this.

I'm not sure myself how to tackle this currently. I think it's ok to leave this as a FIXME for now, as it doesn't influence the tests that much beside the fact that we have to trust the theme being really changed (and if run locally the theme not being preserved for the developer)

@weisJ
Copy link
Owner

weisJ commented Jan 2, 2023

Tests are currently failing because there is no xserver running causing the test to be executed headless. I had a similar issue in one of my other projects and the following seemed to fix it:
https://github.com/weisJ/darklaf/blob/e2d1e56c24f147737fb9ce173f3362efac429437/.github/workflows/gradle.yml#L65

@weisJ
Copy link
Owner

weisJ commented Mar 25, 2023

Sorry for not getting back any sooner. The test not being able to run is rather unfortunate, but I don't have a solution for that right now. I guess we would have to guarantee that the action runner actuallyhas a working dbus with the correct properties exposed. For now I'll disable the test and provide the patch as an optional preview-version.

@weisJ weisJ marked this pull request as draft March 29, 2023 14:45
@weisJ weisJ marked this pull request as ready for review March 29, 2023 14:45
@weisJ weisJ merged commit 3d87ca0 into weisJ:master Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants