Request: Redshift / Night Light / Flux-like feature!

I am missing an OS-wide feature that would suppress emission of blue light after sunset. This is a critical feature dearly missing from an operating system whose UX design is one of the main seling points otherwise!
(Not to mention that every competing OS, as well as the desktop ones have had this feature for years.)

If you are not going to implement it yourself please open up what is necessary so that the community can.

21 Likes

https://together.jolla.com/question/30064/appfeature-request-redshift/

https://together.jolla.com/question/221129/id-like-to-build-redshift-for-sailfish-x/

3 Likes

Is this something that could be implemented in the lipstick wayland compositor or has it to be done by poking at a few GPU registers? The only implementation of it I’ve seen the source code of did in in the latter way, but to be fair, that was on a 3DS which doesn’t have a compositor.

EDIT: My proposal in that case would be for lipstick to handle the actual tinting of the screen and have the settings application send the configuration, like KDE’s Kwin does: https://phabricator.kde.org/R108:82d286046907c07050ebb8c8f5c09cb60079c3ae. Sadly, this is licensed under the GPLv2.0 and Lipstick is licensed under the LGPLv2.1, which means that you probably cannot use the code in lipstick without licensing it under the GPLv2 as well.

So many good ideas were brought forward at the start of the system’s launch. Such a shame they don’t have enough resources to implement some of these.

Agreed, a filter was the first thing I looked for (for me, would be on all the time).

Just in case you weren’t aware, a cludge solution (found it via TJC) is using TintOverlay by coderus - if you’re more capable than me this will be a cinch to set up (maybe not in the background, though!) Auto-Start good, Background Launch bad (Tint Overlay)

I’ve done some more research and apparently the way kwin and Redshift work is by using DRM to adjust gamma curves. I’m wondering if DRM is available on Sailfish OS devices using a libhybris-adaptation, and if not, if there’s a way to apply some form of gamma correction on those devices.

A small workaround I can think of is to apply a shader over the entire output to filter out the blue colours. Since the compositor that Sailfish OS uses, lipstick, uses QtQuick for drawing most of these things to a screen, it simply would need to attach a shader to the root element.

The last one could likely also be implemented as a patch using PatchManager, since the desired effect could be reached by simply patching QML files.

1 Like

A small workaround I can think of is to apply a shader over the entire output to filter out the blue colours.

Was this the way Tint Overlay from Openrepos used to work? Sadly it no longer works with the Sailfish 3.4.0.24

I just wanted to say that there is absolutely no scientific evidence that blue light emitted from screens is bad for the eyes . Blue light is even relaxing. Blue light ha the ability to cause apoptosis in retinal pigment epithelial cells, but only in high intensity, like the light a dentist uses to harden composite fillings.
It was rather a PR thing for new features.
f.ex.:

1 Like

Yes the blue light hazard to eyes might be only at higher intensities, otherwise this portion of spectra might be harmless to vision aparatus. This is not the case with the impact of blue light at night to the circadian clock. Even weak intensities of blue light at evening (or worse at night) might disrupt circadian clock if the person had not had enough exposure of blue-rich strong daylight during the day, or if his circadian aparatus is genetically more sensitive. This disruption of circadian clock leads to various health problems over the years.

Sure, we can choose to follow the lighting hygiene and do not use electronic devices with led screens an hour or two before sleep.

2 Likes

Yes, some studies claim that blue light prevents melatonine production at night, some others do not. So if one has insomnia, that as you say can really be a severe health issue, it can help. Personally I do not like the amber modes on phones as they seem brighter, for me. Blue light has a calming effect on me but that is pure psychology.
(faith can move mountains. Yet an A-nuke can, too :smiley: )

I’ve tried creating a patch, but right now it seems to fail :frowning: . It basically consists of applying a shader effect somewhere in the compositor:

layer.enabled: nighlightConfig.enabled
layer.effect: ShaderEffect {
	property real r: nightlightConfig.gammaR
	property real g: nightlightConfig.gammaG
	property real b: nightlightConfig.gammaB
	fragmentShader: "
		varying highp vec2 qt_TexCoord0;
		uniform sampler2D source;
		uniform lowp float qt_Opacity;
		uniform lowp float r;
		uniform lowp float g;
		uniform lowp float b;
		void main() {
			lowp vec4 tex = texture2D(source, qt_TexCoord0);
			gl_FragColor = vec4(vec3(pow(tex.r, 1.0/r), pow(tex.g, 1.0/g), pow(tex.b, 1.0/b)), tex.a) * qt_Opacity;
		}"
}

And a configuration group somewhere:

ConfigurationGroup {
        id: nightlightConfig

        path: "/desktop/lipstick-jolla-home/patches/nightlight"

        property bool enabled: false
        property real gammaR: 1.0
        property real gammaG: 1.0
        property real gammaB: 1.0
    }

I’ve tried applying them on server items, like the Compositor in compositer.qml (file names are relative to /usr/share/lipstick-jolla-home-qt5/, but that doesn’t work since Compositor is a C++ type which doesn’t inherit from QQuickItem. It doesn’t work in the LayersParent (first child of Compositor that inherits Item) either, for a reason unknown to me.

If someone wants to hack further on it, you can grab a copy of what I was working on here


(I don’t want to put this piece of non-working “art” on my public GitHub profile and I don’t want to give people the impression that I’m planning on maintaining it, so please copy it to your own repository and enjoy the beautiful wonders of maintaining a software project yourself :slight_smile: ).

I’ve attached some instructions on how to restore your phone if you break your homescreen. Trust me, you will eventually.

4 Likes

After some more digging, it seems like hybris-egl supports gamma tables!. If this optional extension is supported on the devices, it would most likely work better.

3 Likes

After some busy weeks and some more research (I’m not quite familiar with the graphics subsystem in Linux and all, I can draw a triangle on screen with OpenGL, but that’s about it), it seems like the “wglext.h” file I linked above only contains Windows-specific code, so that likely won’t work either.

For Android-based devices with Android > 8.0.0 (possible lower), there seems to be this HAL-interface available: https://android.googlesource.com/platform/hardware/interfaces/+/refs/tags/android-8.0.0_r51/graphics/composer/2.1/IComposerClient.hal#727. Libhybris contains references to it, but it doesn’t seem to be wrapped in a C interface, which is needed for it to be exported.

1 Like