Hello, I made some improvements on @tresf code, it now uses screenDevice based on mouse position and always work, no matter what wallpaper is in use.
The trick was compare the top pixel with a pixel inside de apple icon.
public static boolean isDarkTaskbar() {
		try {
				BufferedImage pixel = new Robot(MouseInfo.getPointerInfo().getDevice()).createScreenCapture(new Rectangle(30, 0, 1, 10));
				return getLuminosity(new Color(pixel.getRGB(0, 0))) < getLuminosity(new Color(pixel.getRGB(0, 9)));
		} catch (AWTException e) {
				log.warn("Unable to detect dark taskbar: {}", e.getMessage());
		}
		return false;
}
private static float getLuminosity(Color color) {
		return (color.getRed() * 0.299f) + (color.getGreen() * 0.587f) + (color.getBlue() * 0.114f);
}
But macOs allow users to have diff wallpapers in each screen, so it will blink a lot on this cenario if you change it at runtime many times.
Topic:
App & System Services
SubTopic:
Core OS
Tags: