This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmailspring.py
214 lines (165 loc) · 6.79 KB
/
mailspring.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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