Unverified Commit cc8d0352 authored by Erik Reider's avatar Erik Reider Committed by GitHub

Add `ignore-gtk-theme` config option + default to user CSS priority (#587)

* Always use the default GTK theme to allow for a more consistent theming experience * Default to USER CSS priority
parent a63e0fa5
...@@ -9,6 +9,12 @@ swaync - Configuration file ...@@ -9,6 +9,12 @@ swaync - Configuration file
Using a text editor with a JSON language server is recommended when editing the Using a text editor with a JSON language server is recommended when editing the
config file to be able to detect config errors config file to be able to detect config errors
*ignore-gtk-theme* ++
type: bool ++
default: true ++
description: Unsets the GTK_THEME environment variable, fixing a lot of ++
issues with GTK themes ruining the users custom CSS themes.
*positionX* ++ *positionX* ++
type: string ++ type: string ++
default: right ++ default: right ++
......
{ {
"$schema": @JSONPATH@, "$schema": @JSONPATH@,
"ignore-gtk-theme": true,
"positionX": "right", "positionX": "right",
"positionY": "top", "positionY": "top",
"layer": "overlay", "layer": "overlay",
"control-center-layer": "top", "control-center-layer": "top",
"layer-shell": true, "layer-shell": true,
"layer-shell-cover-screen": true, "layer-shell-cover-screen": true,
"cssPriority": "application", "cssPriority": "highest",
"control-center-margin-top": 0, "control-center-margin-top": 0,
"control-center-margin-bottom": 0, "control-center-margin-bottom": 0,
"control-center-margin-right": 0, "control-center-margin-right": 0,
......
...@@ -60,8 +60,8 @@ namespace SwayNotificationCenter { ...@@ -60,8 +60,8 @@ namespace SwayNotificationCenter {
public int get_priority () { public int get_priority () {
switch (this) { switch (this) {
case APPLICATION: case APPLICATION:
default:
return Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION; return Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION;
default:
case USER: case USER:
return Gtk.STYLE_PROVIDER_PRIORITY_USER; return Gtk.STYLE_PROVIDER_PRIORITY_USER;
} }
...@@ -316,7 +316,7 @@ namespace SwayNotificationCenter { ...@@ -316,7 +316,7 @@ namespace SwayNotificationCenter {
/** Get the static singleton and reload the config */ /** Get the static singleton and reload the config */
public static unowned ConfigModel init (string ? path) { public static unowned ConfigModel init (string ? path) {
_path = Functions.get_config_path (path); _path = path;
reload_config (); reload_config ();
return _instance; return _instance;
} }
...@@ -358,11 +358,16 @@ namespace SwayNotificationCenter { ...@@ -358,11 +358,16 @@ namespace SwayNotificationCenter {
_path = path; _path = path;
debug (_instance.to_string ()); debug (_instance.to_string ());
app.config_reload (previous_config, m); if (app != null) {
app.config_reload (previous_config, m);
}
} }
/* Properties */ /* Properties */
/** Unsets the GTK_THEME env variable when true */
public bool ignore_gtk_theme { get; set; default = true; }
/** The notifications and controlcenters horizontal alignment */ /** The notifications and controlcenters horizontal alignment */
public PositionX positionX { // vala-lint=naming-convention public PositionX positionX { // vala-lint=naming-convention
get; set; default = PositionX.RIGHT; get; set; default = PositionX.RIGHT;
...@@ -390,7 +395,7 @@ namespace SwayNotificationCenter { ...@@ -390,7 +395,7 @@ namespace SwayNotificationCenter {
/** The CSS loading priority */ /** The CSS loading priority */
public CssPriority cssPriority { // vala-lint=naming-convention public CssPriority cssPriority { // vala-lint=naming-convention
get; set; default = CssPriority.APPLICATION; get; set; default = CssPriority.USER;
} }
/** The timeout for notifications with NORMAL priority */ /** The timeout for notifications with NORMAL priority */
......
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
"type": "string", "type": "string",
"description": "Pointer to the schema against which this document should be validated." "description": "Pointer to the schema against which this document should be validated."
}, },
"ignore-gtk-theme": {
"type": "boolean",
"description": "Unsets the GTK_THEME environment variable, fixing a lot of issues with GTK themes ruining the users custom CSS themes.",
"default": true
},
"positionX": { "positionX": {
"type": "string", "type": "string",
"description": "Horizontal position of control center and notification window", "description": "Horizontal position of control center and notification window",
...@@ -32,8 +37,8 @@ ...@@ -32,8 +37,8 @@
}, },
"cssPriority": { "cssPriority": {
"type": "string", "type": "string",
"description": "Which GTK priority to use when loading the default and user CSS files. Pick \"user\" to override XDG_CONFIG_HOME/gtk-3.0/gtk.css", "description": "Which GTK priority to use when loading the default and user CSS files. Pick \"user\" to override XDG_CONFIG_HOME/gtk-4.0/gtk.css",
"default": "application", "default": "highest",
"enum": ["application", "user"] "enum": ["application", "user"]
}, },
"positionY": { "positionY": {
......
...@@ -39,7 +39,6 @@ namespace SwayNotificationCenter { ...@@ -39,7 +39,6 @@ namespace SwayNotificationCenter {
return; return;
} }
activated = true; activated = true;
ConfigModel.init (config_path);
Functions.load_css (style_path); Functions.load_css (style_path);
hold (); hold ();
...@@ -74,9 +73,6 @@ namespace SwayNotificationCenter { ...@@ -74,9 +73,6 @@ namespace SwayNotificationCenter {
} }
public static int main (string[] args) { public static int main (string[] args) {
Gtk.init ();
Adw.init ();
if (args.length > 0) { if (args.length > 0) {
for (uint i = 1; i < args.length; i++) { for (uint i = 1; i < args.length; i++) {
string arg = args[i]; string arg = args[i];
...@@ -107,6 +103,16 @@ namespace SwayNotificationCenter { ...@@ -107,6 +103,16 @@ namespace SwayNotificationCenter {
} }
} }
ConfigModel.init (config_path);
// Fixes custom themes messing with the default/custom CSS styling
if (ConfigModel.instance.ignore_gtk_theme) {
Environment.unset_variable ("GTK_THEME");
}
Gtk.init ();
Adw.init ();
Functions.init (); Functions.init ();
self_settings = new Settings ("org.erikreider.swaync"); self_settings = new Settings ("org.erikreider.swaync");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment