diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..c0bf2be --- /dev/null +++ b/meson.build @@ -0,0 +1,2 @@ +subdir('plugins') +subdir('gnome-shell') \ No newline at end of file diff --git a/plugins/firefox_gnome_theme.py b/plugins/firefox_gnome_theme.py new file mode 100644 index 0000000..0347dab --- /dev/null +++ b/plugins/firefox_gnome_theme.py @@ -0,0 +1,149 @@ +from pathlib import Path +from configparser import ConfigParser + +from yapsy.IPlugin import IPlugin + +TEMPLATE = """ +/* + * =========================================================================== * + * This file was overwritten by the firefox_gnome_theme plugin from Gradience * + * * + * Report issue at: https://github.com/GradienceTeam/Plugins/issues/new/choose * + * Join us on matrix: https://matrix.to/#/#Gradience:matrix.org * + * =========================================================================== * + */ + +:root {{ + --gnome-browser-before-load-background: {window_bg_color}; + --gnome-accent-bg: {accent_bg_color}; + --gnome-accent: {accent_color}; + --gnome-toolbar-background: {window_bg_color}; + --gnome-toolbar-color: {window_fg_color}; + --gnome-toolbar-icon-fill: {window_fg_color}; + --gnome-inactive-toolbar-color: {window_bg_color}; + --gnome-inactive-toolbar-border-color: {headerbar_border_color}; + --gnome-inactive-toolbar-icon-fill: {window_fg_color}; + --gnome-menu-background: {dialog_bg_color}; + --gnome-headerbar-background: {headerbar_bg_color}; + --gnome-button-destructive-action-background: {destructive_bg_color}; + --gnome-entry-color: {view_fg_color}; + --gnome-inactive-entry-color: {view_fg_color}; + --gnome-switch-slider-background: {view_bg_color}; + --gnome-switch-active-slider-background: {accent_color}; + --gnome-inactive-tabbar-tab-background: {window_bg_color}; + --gnome-inactive-tabbar-tab-active-background: rgba(255,255,255,0.025); + --gnome-tabbar-tab-background: {window_bg_color}; + --gnome-tabbar-tab-hover-background: rgba(255,255,255,0.025); + --gnome-tabbar-tab-active-background: rgba(255,255,255,0.075); + --gnome-tabbar-tab-active-hover-background: rgba(255,255,255,0.100); + --gnome-tabbar-tab-active-background-contrast: rgba(255,255,255,0.125); +}} + +@-moz-document url-prefix(about:home), url-prefix(about:newtab) {{ + body{{ + --newtab-background-color: #2A2A2E!important; + --newtab-border-primary-color: rgba(249, 249, 250, 0.8)!important; + --newtab-border-secondary-color: rgba(249, 249, 250, 0.1)!important; + --newtab-button-primary-color: #0060DF!important; + --newtab-button-secondary-color: #38383D!important; + --newtab-element-active-color: rgba(249, 249, 250, 0.2)!important; + --newtab-element-hover-color: rgba(249, 249, 250, 0.1)!important; + --newtab-icon-primary-color: rgba(249, 249, 250, 0.8)!important; + --newtab-icon-secondary-color: rgba(249, 249, 250, 0.4)!important; + --newtab-icon-tertiary-color: rgba(249, 249, 250, 0.4)!important; + --newtab-inner-box-shadow-color: rgba(249, 249, 250, 0.2)!important; + --newtab-link-primary-color: var(--gnome-accent)!important; + --newtab-link-secondary-color: #50BCB6!important; + --newtab-text-conditional-color: #F9F9FA!important; + --newtab-text-primary-color: var(--gnome-accent)!important; + --newtab-text-secondary-color: rgba(249, 249, 250, 0.8)!important; + --newtab-textbox-background-color: var(--gnome-toolbar-background)!important; + --newtab-textbox-border: var(--gnome-inactive-toolbar-border-color)!important; + --newtab-textbox-focus-color: #45A1FF!important; + --newtab-textbox-focus-boxshadow: 0 0 0 1px #45A1FF, 0 0 0 4px rgba(69, 161, 255, 0.3)!important; + --newtab-feed-button-background: #38383D!important; + --newtab-feed-button-text: #F9F9FA!important; + --newtab-feed-button-background-faded: rgba(56, 56, 61, 0.6)!important; + --newtab-feed-button-text-faded: rgba(249, 249, 250, 0)!important; + --newtab-feed-button-spinner: #D7D7DB!important; + --newtab-contextmenu-background-color: #4A4A4F!important; + --newtab-contextmenu-button-color: #2A2A2E!important; + --newtab-modal-color: #2A2A2E!important; + --newtab-overlay-color: rgba(12, 12, 13, 0.8)!important; + --newtab-section-header-text-color: rgba(249, 249, 250, 0.8)!important; + --newtab-section-navigation-text-color: rgba(249, 249, 250, 0.8)!important; + --newtab-section-active-contextmenu-color: #FFF!important; + --newtab-search-border-color: rgba(249, 249, 250, 0.2)!important; + --newtab-search-dropdown-color: #38383D!important; + --newtab-search-dropdown-header-color: #4A4A4F!important; + --newtab-search-header-background-color: rgba(42, 42, 46, 0.95)!important; + --newtab-search-icon-color: rgba(249, 249, 250, 0.6)!important; + --newtab-search-wordmark-color: #FFF!important; + --newtab-topsites-background-color: #38383D!important; + --newtab-topsites-icon-shadow: none!important; + --newtab-topsites-label-color: rgba(249, 249, 250, 0.8)!important; + --newtab-card-active-outline-color: var(--gnome-toolbar-icon-fill)!important; + --newtab-card-background-color: var(--gnome-toolbar-background)!important; + --newtab-card-hairline-color: rgba(249, 249, 250, 0.1)!important; + --newtab-card-placeholder-color: #4A4A4F!important; + --newtab-card-shadow: 0 1px 8px 0 rgba(12, 12, 13, 0.2)!important; + --newtab-snippets-background-color: #38383D!important; + --newtab-snippets-hairline-color: rgba(255, 255, 255, 0.1)!important; + --trailhead-header-text-color: rgba(255, 255, 255, 0.6)!important; + --trailhead-cards-background-color: rgba(12, 12, 13, 0.1)!important; + --trailhead-card-button-background-color: rgba(12, 12, 13, 0.3)!important; + --trailhead-card-button-background-hover-color: rgba(12, 12, 13, 0.5)!important; + --trailhead-card-button-background-active-color: rgba(12, 12, 13, 0.7)!important; + }} +}} +""" + + +class FirefoxGnomeTheme2Plugin(IPlugin): + plugin_id = "firefox_gnome_theme" + title = "Firefox GNOME Theme" + author = "Gradience Team" + template = TEMPLATE + + def give_preset_settings(self, preset_settings, custom_settings=None): + self.variables = preset_settings["variables"] + + def validate(self): + return False, None + + def open_settings(self): + return False + + def apply(self, dark_theme=False): + for path in [ + "~/.mozilla/firefox", + "~/.librewolf", + "~/.var/app/org.mozilla.firefox/.mozilla/firefox", + "~/.var/app/io.gitlab.librewolf-community/.librewolf", + ]: + try: + directory = Path(path).expanduser() + cp = ConfigParser() + cp.read(str(directory / "profiles.ini")) + results = [] + for section in cp.sections(): + if not section.startswith("Profile"): + continue + if cp[section]["IsRelative"] == 0: + results.append(Path(cp[section]["Path"])) + else: + results.append(directory / Path(cp[section]["Path"])) + for result in results: + try: + if result.resolve().is_dir(): + with open( + f"{result}/chrome/firefox-gnome-theme/customChrome.css", + "w", + ) as f: + f.write(self.template.format(**self.variables)) + except OSError: + pass + except OSError: + pass + except StopIteration: + pass diff --git a/plugins/firefox_gnome_theme.yapsy-plugin b/plugins/firefox_gnome_theme.yapsy-plugin new file mode 100644 index 0000000..7aab3ac --- /dev/null +++ b/plugins/firefox_gnome_theme.yapsy-plugin @@ -0,0 +1,9 @@ +[Core] +Name = Firefox GNOME Theme +Module = firefox_gnome_theme + +[Documentation] +Description = Firefox GNOME Theme +Author = Gradience Team +Version = 0.1.0 +Website = https://gradienceteam.github.io/plugins/firefox-gnome-theme/ diff --git a/plugins/mailspring.py b/plugins/mailspring.py new file mode 100644 index 0000000..58171a8 --- /dev/null +++ b/plugins/mailspring.py @@ -0,0 +1,214 @@ +from pathlib import Path +from configparser import ConfigParser +import os + +from yapsy.IPlugin import IPlugin + +TEMPLATE = """ +/* + * =================================================================================== * + * This file was overwritten by the mailspring_libadwaita_theme plugin from Gradience * + * * + * Report issue at: https://github.com/GradienceTeam/Plugins/issues/new/choose * + * Join us on matrix: https://matrix.to/#/#Gradience:matrix.org * + * =================================================================================== * + */ + +//------------------------------------------------------------ +// Asset path +//------------------------------------------------------------ + +@asset_path: "Libadwaita"; + +//------------------------------------------------------------ +// Variant colors (light/dark) +//------------------------------------------------------------ + +// Text color +@text_color: {card_fg_color}; + +// Accent colors +@accent_bg_color: {accent_bg_color}; +@accent_fg_color: {accent_fg_color}; +@accent_color: {accent_color}; + +// Success colors +@success_bg_color: {success_bg_color}; +@success_fg_color: {success_fg_color}; +@success_color: {success_color}; + +// Warning colors +@warning_color: {warning_color}; +@warning_bg_color: {warning_bg_color}; +@warning_fg_color: {warning_fg_color}; + +// Error colors +@error_color: {error_color}; +@error_bg_color: {error_bg_color}; +@error_fg_color: {error_fg_color}; + +// Window/header colors +@window_bg_color: {window_bg_color}; +@headerbar_bg_color: {headerbar_bg_color}; + +// Card colors +@card_bg_color: {card_bg_color}; + +// Popover colors +@popover_bg_color: {popover_bg_color}; + +// View colors +@view_bg_color: {view_bg_color}; +@view_fg_color: {view_fg_color}; + +// Scrollbar colors +@scrollbar_outline_color: {scrollbar_outline_color}; + +//------------------------------------------------------------ +// User variables +//------------------------------------------------------------ + +// Text size +@text_size: 15px; + +// Control height (button/input/select) +@button_height: 34px; + +// Popover item height +@popover_item_height: 32px; + +//------------------------------------------------------------ +// Palette colors (fixed) +//------------------------------------------------------------ +@yellow_4: #f5c211; + +//------------------------------------------------------------ +// Calculated + fixed colors (do not modify) +//------------------------------------------------------------ + +// Dim text color +@text_color_dim: fade(@text_color, alpha(@text_color)*100*0.55); + +// Border color +@borders_color: fade(@text_color, alpha(@text_color)*100*0.15); + +// Focus border color +@focus_border_color: fade(@accent_color, 50%); + +// View colors +@view_hover_color: fade(@text_color, alpha(@text_color)*100*0.07); +@view_active_color: fade(@text_color, alpha(@text_color)*100*0.16); +@view_selected_color: fade(@text_color, alpha(@text_color)*100*0.1); +@view_selected_hover_color: fade(@text_color, alpha(@text_color)*100*0.13); +@view_selected_active_color: fade(@text_color, alpha(@text_color)*100*0.19); + +// Button colors +@button_color: fade(@text_color, alpha(@text_color)*100*0.1); +@button_hover_color: fade(@text_color, alpha(@text_color)*100*0.15); +@button_active_color: fade(@text_color, alpha(@text_color)*100*0.3); +@button_checked_color: fade(@text_color, alpha(@text_color)*100*0.3); +@button_checked_hover_color: fade(@text_color, alpha(@text_color)*100*0.35); + +// Default button colors +@button_default_hover_color: linear-gradient(fade(@text_color, alpha(@text_color)*100*0.1), fade(@text_color, alpha(@text_color)*100*0.1)); +@button_default_active_color: linear-gradient(fade(black, 20%), fade(black, 20%)); + +// Trough colors (used for checkboxes and radio buttons) +@trough_color: fade(@text_color, alpha(@text_color)*100*0.15); +@trough_hover_color: fade(@text_color, alpha(@text_color)*100*0.2); +@trough_active_color: fade(@text_color, alpha(@text_color)*100*0.25); + +// Checkbox/radio button colors +@check_shadow: inset 0 0 0 2px @trough_color; +@check_hover_shadow: inset 0 0 0 2px @trough_hover_color; +@check_active_color: @trough_active_color; +@check_selected_hover_color: linear-gradient(fade(@accent_fg_color, 10%), fade(@accent_fg_color, 10%)); +@check_selected_active_color: linear-gradient(fade(black, 20%), fade(black, 20%)); + +// Card colors +@card_shadow: 0 0 0 1px fade(black, 3%), 0 1px 3px 1px fade(black, 7%), 0 2px 6px 2px fade(black, 3%); + +// Popover colors +@popover_border_color: fade(black, 14%); +@popover_shadow: 0 1px 5px 1px fade(black, 9%), 0 2px 14px 3px fade(black, 5%); + +// OSD colors +@osd_bg_color: fade(black, 70%); +@osd_fg_color: fade(white, 90%); +@osd_button_color: fade(white, 9%); +@osd_button_hover_color: fade(white, 13.5%); + +// Link colors +@link_color: @accent_color; +@link_hover_color: mix(@accent_color, @view_fg_color, 80%); + +// Scale slider colors +@slider_color: mix(white, @view_bg_color, 80%); +@slider_shadow: 0 2px 4px fade(black, 20%); +@slider_outline: 1px solid fade(black, 10%); +@slider_hover_color: white; + +// Tooltip colors +@tooltip_bg_color: fade(black, 80%); +@tooltip_fg_color: white; +@tooltip_border_color: fade(white, 10%); + +// Scrollbar colors +@scrollbar_track_color: fade(@text_color, alpha(@text_color)*100*0.1); +@scrollbar_slider_color: fade(@text_color, alpha(@text_color)*100*0.2); +@scrollbar_slider_hover_color: fade(@text_color, alpha(@text_color)*100*0.4); +@scrollbar_slider_dragging_color: fade(@text_color, alpha(@text_color)*100*0.6); + +//------------------------------------------------------------ +// Other fixed variables +//------------------------------------------------------------ + +// Disabled opacity +@disabled_opacity: 0.5; + +// Button radius +@button_radius: 6px; + +// Card radius +@card_radius: 12px; + +// Popover radius +@popover_radius: 12px; + +""" + + +class MailspringPlugin(IPlugin): + plugin_id = "mailspring_libadwaita_theme" + title = "Mailspring Libadwaita Theme" + author = "Spaziale" + template = TEMPLATE + + def give_preset_settings(self, preset_settings, custom_settings=None): + self.variables = preset_settings["variables"] + + def validate(self): + return False, None + + def open_settings(self): + return False + + def apply(self, dark_theme=False): + for path in [ + "~/.config/Mailspring/packages/Libadwaita/styles", + "~/.var/app/com.getmailspring.Mailspring/config/Mailspring/packages/Libadwaita/styles" + ]: + directory = os.path.expanduser(path) + if not os.path.exists(directory): + os.makedirs(directory) + + try: + with open( + f"{directory}/main.less", + "w", + ) as f: + f.write(self.template.format(**self.variables)) + except OSError: + pass + except StopIteration: + pass diff --git a/plugins/mailspring.yapsy-plugin b/plugins/mailspring.yapsy-plugin new file mode 100644 index 0000000..8fa9ef3 --- /dev/null +++ b/plugins/mailspring.yapsy-plugin @@ -0,0 +1,8 @@ +[Core] +Name = Mailspring +Module = mailspring + +[Documentation] +Description = Mailspring Libadwaita Theme +Author = Spaziale +Version = 0.1.0 diff --git a/plugins/meson.build b/plugins/meson.build new file mode 100644 index 0000000..3844460 --- /dev/null +++ b/plugins/meson.build @@ -0,0 +1,13 @@ +builtin_plugins_list = files([ + 'firefox_gnome_theme.py', + 'firefox_gnome_theme.yapsy-plugin', + 'mailspring.py', + 'mailspring.yapsy-plugin', + 'qt5ct.py', + 'qt5ct.yapsy-plugin', +]) + +install_data( + builtin_plugins_list, + install_dir: join_paths(get_option('datadir'), 'gradience', 'plugins') +) diff --git a/plugins/qt5ct.py b/plugins/qt5ct.py new file mode 100644 index 0000000..a42665d --- /dev/null +++ b/plugins/qt5ct.py @@ -0,0 +1,132 @@ +from pathlib import Path + +import os + +from yapsy.IPlugin import IPlugin + +class Qt5ctColorScheme2Plugin(IPlugin): + plugin_id = "qt5ct_color_scheme" + title = "Qt5ct Color Scheme" + author = "Gradience Team" + + def give_preset_settings(self, preset_settings, custom_settings=None): + self.variables = preset_settings["variables"] + + def validate(self): + return False, None + + def open_settings(self): + return False + + def apply(self, dark_theme=False): + def transform_color(string): + if (string.startswith("#")): + return '#' + 'ff' + string[1:8] + elif (string.startswith("rgba")): + rgba_strings = string.strip("rgba()").split(", ") + r, g, b = [int(x) for x in rgba_strings[0:3]] + alpha = int(float(rgba_strings[3]) * 255) + return '#{:02x}{:02x}{:02x}{:02x}'.format(alpha, r, g, b) + else: print("ERROR " + string) + qt_pos = { + "window_text": 0, + "button_background": 1, + "bright": 2, + "less_bright": 3, + "dark": 4, + "less_dark": 5, + "normal_text": 6, + "bright_text": 7, + "button_text": 8, + "normal_background": 9, + "window": 10, + "shadow": 11, + "highlight": 12, + "highlighted_text": 13, + "link": 14, + "visited_link": 15, + "alternate_background": 16, + "default": 17, + "tooltip_background": 18, + "tooltip_text": 19, + "placeholder_text": 20 + } + qt_active = ["#ff000000", "#ffefefef", "#ffffffff", "#ffcacaca", + "#ff9f9f9f", "#ffb8b8b8", "#ff000000", "#ffffffff", + "#ff000000", "#ffffffff", "#ffefefef", "#ff767676", + "#ff308cc6", "#ffffffff", "#ff0000ff", "#ffff00ff", + "#fff7f7f7", "#ff000000", "#ffffffdc", "#ff000000", + "#80000000"] + qt_disabled = ["#ffbebebe", "#ffefefef", "#ffffffff", "#ffcacaca", + "#ffbebebe", "#ffb8b8b8", "#ffbebebe", "#ffffffff", + "#ffbebebe", "#ffefefef", "#ffefefef", "#ffb1b1b1", + "#ff919191", "#ffffffff", "#ff0000ff", "#ffff00ff", + "#fff7f7f7", "#ff000000", "#ffffffdc", "#ff000000", + "#80000000"] + qt_inactive = ["#ff000000", "#ffefefef", "#ffffffff", "#ffcacaca", + "#ff9f9f9f", "#ffb8b8b8", "#ff000000", "#ffffffff", + "#ff000000", "#ffffffff", "#ffefefef", "#ff767676", + "#ff308cc6", "#ffffffff", "#ff0000ff", "#ffff00ff", + "#fff7f7f7", "#ff000000", "#ffffffdc", "#ff000000", + "#80000000"] + qt_to_gn_active = { + "window_text": "window_fg_color", + "button_background": "view_bg_color", + #"bright": "view_bg_color", + #"less_bright": "window_bg_color", + #"bright_text": "view_fg_color", + "normal_text": "popover_fg_color", + "button_text": "window_fg_color", + "normal_background": "popover_bg_color", + "window": "headerbar_bg_color", + "highlight": "accent_bg_color", + "highlighted_text": "accent_fg_color" + } + qt_to_gn_inactive = { + "window_text": "window_fg_color", + "button_background": "view_bg_color", + "normal_text": "popover_fg_color", + "button_text": "window_fg_color", + "normal_background": "popover_bg_color", + "window": "headerbar_bg_color" + } + qt_to_gn_disabled = { + "button_background": "view_bg_color", + "window": "window_bg_color" + } + qt_palettes = { + "active_colors": qt_active, + "disabled_colors": qt_disabled, + "inactive_colors": qt_inactive + } + for gn_name, color in self.variables.items(): + matches = [k for k, v in qt_to_gn_active.items() if v == gn_name] + if matches: + tran = transform_color(color) + for match in matches: + qt_active[qt_pos.get(match)] = tran + matches = [k for k, v in qt_to_gn_inactive.items() if v == gn_name] + if matches: + tran = transform_color(color) + for match in matches: + qt_inactive[qt_pos.get(match)] = tran + matches = [k for k, v in qt_to_gn_disabled.items() if v == gn_name] + if matches: + tran = transform_color(color) + for match in matches: + qt_disabled[qt_pos.get(match)] = tran + try: + path = os.path.expanduser("~/.config/qt5ct/colors") + if not os.path.exists(path): + os.makedirs(path) + path = os.path.join(path, "Gradience.conf") + print(path) + direc = Path(path).expanduser() + with open(direc, "w") as f: + f.write("[ColorScheme]\n") + for name, palette in qt_palettes.items(): + f.write(name + "=" + ", ".join(palette) + "\n") + except OSError: + pass + except StopIteration: + pass diff --git a/plugins/qt5ct.yapsy-plugin b/plugins/qt5ct.yapsy-plugin new file mode 100644 index 0000000..a876e16 --- /dev/null +++ b/plugins/qt5ct.yapsy-plugin @@ -0,0 +1,9 @@ +[Core] +Name = Qt5ct +Module = qt5ct + +[Documentation] +Description = Creates a qt5ct color scheme file in the appropriate folder with the same name as the preset +Author = bertini97 +Version = 0.1.0 +Website = https://GradienceTeam.github.io/Plugins/qt5ct/