Bug 439891 - [Feature Request] Allow websites to detect dark or light theme in use
Summary: [Feature Request] Allow websites to detect dark or light theme in use
Status: RESOLVED FIXED
Alias: None
Product: Falkon
Classification: Applications
Component: general (show other bugs)
Version: 3.1.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-15 16:28 UTC by Sughosha
Modified: 2024-12-20 22:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
left: falkon, right: firefox (148.13 KB, image/png)
2022-02-14 03:53 UTC, Hervy Qurrotul Ainur Rozi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sughosha 2021-07-15 16:28:16 UTC
SUMMARY
There are some websites, like https://duckduckgo.com, which are able to detect whether the user is using dark theme or not in the system and set themselves to light or dark mode automatically. Even if I have a dark Plasma's global theme, Falkon doesn't let those websites know it.

STEPS TO REPRODUCE
1. Set Plasma's global theme to a dark theme.
2. Go to https://duckduckgo.com
3. It can't know that you are using dark theme.

OBSERVED RESULT
Exporting "QTWEBENGINE_CHROMIUM_FLAGS=--force-dark-mode" manually allows the supported websites to use dark mode.

EXPECTED RESULT
This should be applied automatically, if a dark theme is being used, without the need of user exporting the variable manually. If Plasma Settings' "Colors" has a light theme selected, dark mode in websites should be denied, and if it has a dark theme selected, dark mode should be allowed.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.22.3
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Firefox is able to detect the system's GNOME/GTK theme and allow the websites to set themselves accordingly to dark or light mode. The same kind of result is expected in Falkon.
Comment 1 Hervy Qurrotul Ainur Rozi 2022-02-14 03:53:23 UTC
Created attachment 146694 [details]
left: falkon, right: firefox
Comment 2 Hervy Qurrotul Ainur Rozi 2022-02-14 03:55:03 UTC
I see several websites using CSS Media Feature "prefers-color-scheme" like apps.kde.org. But it doesn't work properly.
Comment 3 Hervy Qurrotul Ainur Rozi 2022-05-06 00:22:49 UTC
And falkon:start homepage also needs to support system themes (especially dark theme).
Comment 4 thomholwerda@osnews.com 2024-12-01 20:30:22 UTC
This should definitely be an option. Do note that the existing Falkon setting "Force dark mode", listed under Preferences > Browsing, is not the same. This setting, when enabled, will even try to apply custom dark modes to websites that don't have one, which can yield... Problematic results, and is a bit of a brute-force approach when more elegant solutions exist (as mentioned by the OP).

Other browsers already do this - Firefox, Chrome, etc. - so I think it's safe to say users expect this.
Comment 5 Bug Janitor Service 2024-12-17 22:47:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/falkon/-/merge_requests/103
Comment 6 Juraj 2024-12-20 22:22:15 UTC
Git commit 4a8236a3ee67a9a88dc8e95baef93eb959df4df5 by Juraj Oravec.
Committed on 20/12/2024 at 22:16.
Pushed by jurajo into branch 'master'.

Add "Preffer color scheme" option
Related: bug 497331

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>

M  +37   -13   src/lib/app/mainapplication.cpp
M  +2    -0    src/lib/app/mainapplication.h
M  +6    -0    src/lib/app/qzcommon.h
M  +15   -0    src/lib/preferences/preferences.cpp
M  +28   -1    src/lib/preferences/preferences.ui

https://invent.kde.org/network/falkon/-/commit/4a8236a3ee67a9a88dc8e95baef93eb959df4df5