Last active
January 19, 2022 00:07
-
-
Save quienn/244db25dbccd5999ea4ec85655574782 to your computer and use it in GitHub Desktop.
elementary OS Flatpak Theme Changer
This file contains 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 characters
--- Run this script using a cronjob. I'm running this according to my elementary OS settings: | |
--- From 06:00 AM (light theme) to 09:00 PM (dark theme) Mexico City Timezone | |
exec = (command, ...) -> | |
io.popen "#{command} #{table.concat (table.pack ...), ' '}" | |
FLATHUB_APPS = {} | |
local COLOR_SCHEME | |
local THEME | |
do | |
with exec "gsettings get org.freedesktop prefers-color-scheme" | |
COLOR_SCHEME = ((\read "*a")\gsub "'(.-)'", "%1")\gsub "%s", "" | |
\close! | |
with exec "gsettings get org.gnome.desktop.interface gtk-theme" | |
THEME = ((\read "*a")\gsub "'(.-)'", "%1")\gsub "%s", "" | |
\close! | |
with exec "flatpak list --app --columns=application,origin" | |
for line in \lines! | |
application, origin = line\match "^([%w._-]+)%s*(%w+)%s*$" | |
if origin != "appcenter" | |
table.insert FLATHUB_APPS, application | |
\close! | |
SYSTEM_THEME = if COLOR_SCHEME == "dark" then "#{THEME}-dark" else THEME | |
--- Do the actual thing | |
for app_id in *FLATHUB_APPS | |
with exec "flatpak override --user --env=GTK_THEME=#{SYSTEM_THEME} #{app_id}" | |
\close! |
Update: No need for this as elementary joined forces with major DEs out there (KDE, GNOME) to make the Freedesktop Color Scheme preference a thing! Firefox 98 will surely support it, as well as most GNOME apps using libadwaita.
https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/
https://bugzilla.mozilla.org/show_bug.cgi?id=1734934
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to https://gist.github.com/ImranR98/8d6423fdc11022162cf416cc6de0d9af/ for the idea.