forked from monday15/lounge-gtk-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
573 lines (475 loc) · 22.3 KB
/
meson.build
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
project('lounge-gtk-theme',
version: '1.24',
meson_version: '>= 0.45',
license : ['GPL3+'],
default_options: ['prefix=/usr'])
# Dependencies
sassc = find_program('sassc')
gnomeshell = find_program('gnome-shell', required: false)
# gtk3 is also a dependency, located below, becuase it is not required for fltapak build
# Variable, used several times in install scripts
mid = '$MESON_INSTALL_DESTDIR_PREFIX/'
##### REGULAR BUILD
if get_option('flatpak') == false
theme_tone = get_option('tone')
theme_style = get_option('style')
theme_scale_style = get_option('scale_style')
theme_scrollbar_handles = get_option('scrollbar_handles')
theme_button_outlines = get_option('button_outlines')
# CHECK GNOME VERSION
if get_option('gnome_version') != ''
gnome_version = get_option('gnome_version')
else
if gnomeshell.found()
gnome_version_array = run_command([gnomeshell, '--version']).stdout().split('\n')[0].split(' ')[-1].strip().split('.')
if gnome_version_array[1].to_int().is_even()
gnome_version = '.'.join([ gnome_version_array[0], gnome_version_array[1] ])
else
gnome_version = '.'.join([ gnome_version_array[0], (gnome_version_array[1].to_int() + 1).to_string() ])
endif
else
message('Gnome-shell not found, using styles for last gnome version availible')
gnome_version = '3.34'
endif
endif
message('Gnome ' + gnome_version)
# CHECK GTK3 VERSION
if get_option('gtk3_version') != ''
gtk3_version = get_option('gtk3_version')
else
gtk3_version_check = find_program('gtk-launch')
gtk3_version_array = run_command([gtk3_version_check, '--version']).stdout().split('\n')[0].split(' ')[-1].strip().split('.')
gtk3_version = '.'.join([ gtk3_version_array[0], gtk3_version_array[1] ])
endif
message ('Gtk3 ' + gtk3_version)
# INSTALLATION DIRECTORIES
themes_array = [
['Lounge', '' ],
['Lounge-night', 'dark_' ],
['Lounge-compact', 'compact_' ],
['Lounge-night-compact', 'compact_dark_']
]
dirs_array = [
['gtk-2.0', 'gtk2_dir' ],
['gtk-3.0', 'gtk3_dir' ],
['gnome-shell', 'shell_dir'],
['xfwm4', 'xfwm4_dir'],
['metacity-1', 'metacity_dir']
]
# Create variables for theme directories
foreach theme : themes_array
set_variable(theme[1] + 'theme_dir', join_paths(get_option('datadir'), 'themes', theme[0]))
foreach dir : dirs_array
set_variable(theme[1] + dir[1], join_paths(get_option('datadir'), 'themes', theme[0], dir[0]))
endforeach
endforeach
# INDEX FILES
# Copy is used for copying input to builddir,
# copy.set doesn't change anything, but prevents meson warnings
copy = configuration_data()
copy.set('something', 'something')
# Create index files for themes, output files has to have different names,
# install_script will rename them later
foreach theme : themes_array
conf_index = configuration_data()
conf_index.set('theme_name', theme[0])
configure_file(input : 'src/index.theme.in',
output : 'index.theme.' + theme[0],
configuration: conf_index,
install_dir: get_variable(theme[1] + 'theme_dir'))
meson.add_install_script('sh', '-c', 'mv ' + mid + get_variable(theme[1] + 'theme_dir') + '/index.theme.' + theme[0] +
' ' + mid + get_variable(theme[1] + 'theme_dir') + '/index.theme')
endforeach
# GNOME-SHELL THEME
shell_noconf_sources = [
'shell-colors.scss',
'shell-drawing.scss',
'shell-extensions.scss'
]
# Copy sources that doesnt require configuration to builddir
foreach file : shell_noconf_sources
configure_file(input : 'src/gnome-shell/' + file,
output : file,
configuration : copy)
endforeach
# Set font
configure_file(input : join_paths('src/gnome-shell/shell-common.scss'),
output : 'shell-common.scss',
capture : true,
command: ['sed', 's#Roboto#' + get_option('shell_font') + '#g', '@INPUT@'])
# Configure main scss file
shell_conf = configuration_data()
shell_conf.set('gnome_version', gnome_version)
shell_conf.set('tone', theme_tone)
shell_conf.set('scale_style', theme_scale_style)
shell_scss = configure_file(input : 'src/gnome-shell/gnome-shell.scss',
output : 'gnome-shell.scss',
configuration : shell_conf)
# Generate and install theme css file
custom_target('Generate shell theme',
input: shell_scss,
output: 'gnome-shell.css',
command: [ sassc, '-a', '@INPUT@', '@OUTPUT@'],
install: true,
install_dir: shell_dir)
# Install assets
shell_unused_assets_tone = run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', 'gnome-shell', 'assets') +
' | grep "tango\|salsa\|rumba\|jive" | grep -v ' + theme_tone).stdout()
shell_unused_assets_332_and_later = run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', 'gnome-shell', 'assets') +
' | grep "close\-window\|calendar\-arrow"').stdout()
if gnome_version.version_compare('<=3.30')
install_subdir('src/gnome-shell/assets',
install_dir: shell_dir,
exclude_files: [ shell_unused_assets_tone.split('\n') ])
else
install_subdir('src/gnome-shell/assets',
install_dir: shell_dir,
exclude_files: [ shell_unused_assets_tone.split('\n'),
shell_unused_assets_332_and_later.split('\n') ])
endif
# GTK3 THEME
gtk3_noconf_sources = [
'gtk3-colors.scss',
'gtk3-colors-public.scss',
'gtk3-variables.scss',
'gtk3-drawing.scss',
'gtk3-common.scss',
'gtk3-apps.scss',
'gtk3-xfce.scss',
'gtk3-libhandy.scss',
'gtk3-mate.css'
]
# Copy sources that doesnt require configuration to builddir
foreach file : gtk3_noconf_sources
configure_file(input : join_paths('src/gtk3/' + file),
output : file,
configuration : copy)
endforeach
gtk3_array = [
['', 'light', 'regular'],
['dark_', 'dark' , 'regular'],
['compact_', 'light', 'compact'],
['compact_dark_', 'dark' , 'compact']
]
foreach theme : gtk3_array
gtk3_conf = configuration_data()
gtk3_conf.set('gtk_variant', theme[1])
gtk3_conf.set('gtk_size', theme[2])
gtk3_conf.set('tone', theme_tone)
gtk3_conf.set('style', theme_style)
gtk3_conf.set('scale_style', theme_scale_style)
gtk3_conf.set('scrollbar_handles', theme_scrollbar_handles)
gtk3_conf.set('button_outlines', theme_button_outlines)
gtk3_conf.set('gtk_version', gtk3_version)
gtk3_conf.set('gnome_version', gnome_version)
# Configure main scss file
gtk3_scss = configure_file(input : 'src/gtk3/gtk3.scss',
output : 'gtk3' + theme[0] + '.scss',
configuration : gtk3_conf)
# Generate and install css files
custom_target('Generate gtk3 theme ' + theme[0],
input: gtk3_scss,
output: 'gtk' + theme[0] + '.css',
command: [ sassc, '-M', '-t', 'compact', '@INPUT@', '@OUTPUT@' ],
install: true,
install_dir: get_variable(theme[0] + 'gtk3_dir'))
# Rename generated files (output files has to have different names at configuration),
# ignore regular light theme, mv fails if source and destination are the same file
if theme[0] != ''
meson.add_install_script('sh', '-c', 'mv ' + mid + get_variable(theme[0] + 'gtk3_dir') + '/gtk' + theme[0] + '.css ' +
mid + get_variable(theme[0] + 'gtk3_dir') + '/gtk.css')
endif
endforeach
# Copy dark theme css files to light themes
meson.add_install_script('sh', '-c', 'cp ' + mid + compact_dark_gtk3_dir + '/gtk.css ' +
mid + compact_gtk3_dir + '/gtk-dark.css')
meson.add_install_script('sh', '-c', 'cp ' + mid + dark_gtk3_dir +'/gtk.css ' +
mid + gtk3_dir + '/gtk-dark.css')
# GTK2 THEME
gtk2_sources = [
'gtkrc',
'main.rc',
'apps.rc',
'hacks.rc',
'xfce.rc'
]
gtk2_array = [
['', '$regular ', '$light '],
['dark_', '$regular ', '$dark ' ],
['compact_', '$compact ', '$light '],
['compact_dark_', '$compact ', '$dark ' ]]
# Solid menu option for xfce/sway and other environments without compositor,
# uses png asset to draw menu's border
if get_option('gtk2_solid_menu')
gtk2_menu_border = 's/$solid_menu //g'
else
gtk2_menu_border = 's/$normal_menu //g'
endif
# Create gtk2 themes from templates
foreach theme : gtk2_array
foreach file : gtk2_sources
# Add suffix for assets urls used in compact themes
if theme[1] == '$compact '
set_assets_size = 's/\-$size/\-compact/g'
else
set_assets_size = 's/\-$size//g'
endif
# Scales style suffix
if theme_scale_style == 'fancy'
set_scale_style = 's/\-$scale_style\-$tone/\-fancy-' + theme_tone + '/g'
else
set_scale_style = 's/\-$scale_style\-$tone//g'
endif
# Set tone suffix
set_tone = 's/\-$tone/\-' + theme_tone +'/g'
# Style suffix
if theme_style == 'flat'
set_style = 's/\-$style/\-flat/g'
else
set_style = 's/\-$style//g'
endif
# Add suffix for assets urls used in dark themes
if theme[2] == '$dark '
set_color_variant = 's/.png\"/\-dark.png\"/g'
else
set_color_variant = 's///'
endif
# Create data files: templates has lines, that starts with $ (whole line is a variable),
# sed enables needed variables - removes variable, so the line became a regular one,
# lines with unused variables are removed on the fourth step
configure_file(input : 'src/gtk2/' + file + '.in',
output : file + theme[0],
capture : true,
command: ['sed', '-e', 's/' + theme[1] + '//g',
'-e', 's/' + theme[2] + '//g',
'-e', 's/^\$' + theme_scale_style + '\ //g',
'-e', 's/^\$' + theme_tone + '\ //g',
'-e', 's/^\$' + theme_style + '\ //g',
'-e', 's/^\$' + theme_scrollbar_handles + '\ //g',
'-e', gtk2_menu_border,
'-e', '/^\$/ d',
'-e', set_assets_size,
'-e', set_scale_style,
'-e', set_tone,
'-e', set_style,
'-e', set_color_variant,
'@INPUT@'],
install_dir: get_variable(theme[0] + 'gtk2_dir'))
# Rename generated files (output files has to have different names at configuration),
# ignore regular light theme, mv fails if source and destination are the same file
if theme[0] != ''
meson.add_install_script('sh', '-c', 'mv ' + mid + get_variable(theme[0] + 'gtk2_dir') + '/' + file + theme[0] +
' ' + mid + get_variable(theme[0] + 'gtk2_dir') + '/' + file)
endif
endforeach
endforeach
# XFWM THEME
# Use array from gtk2 theme, variables are the same
foreach theme : gtk2_array
# Generate and install themerc files
configure_file(input : 'src/xfwm4/themerc.in',
output : 'themerc' + theme[0],
capture : true,
command: ['sed', '-e', 's/' + theme[1] + '//g',
'-e', 's/' + theme[2] + '//g',
'-e', '/^\$/ d',
'@INPUT@'],
install_dir: get_variable(theme[0] + 'xfwm4_dir'))
# Rename generated files (output files has to have different names at configuration),
# ignore regular light theme, mv fails if source and destination are the same file
if theme[0] != ''
meson.add_install_script('sh', '-c', 'mv ' + mid + get_variable(theme[0] + 'xfwm4_dir') + '/' + 'themerc' + theme[0] +
' ' + mid + get_variable(theme[0] + 'xfwm4_dir') + '/' + 'themerc')
endif
endforeach
# ASSETS
assets_themes = [
'gtk2',
'gtk3',
'xfwm4'
]
# Specifies excluded assets for each theme
# theme | gtk3/gtk2/xfwm | gtk3 | gtk2/xfwm
assets_array = [
['' , '_compact', '_none', '_dark' ],
['dark_' , '_compact', '_light', '_light'],
['compact_' , '_regular', '_none', '_dark' ],
['compact_dark_', '_regular', '_light', '_light']
]
foreach theme : assets_themes
# Helpers for excluding assets from different size/color variants
set_variable(theme + '_assets_none', '')
set_variable(theme + '_assets_light',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep dark | sed s/-dark//').stdout())
set_variable(theme + '_assets_dark',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep dark').stdout())
set_variable(theme + '_assets_regular',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep compact | sed s/-compact//').stdout())
set_variable(theme + '_assets_compact',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep compact').stdout())
set_variable(theme + '_assets_excluded_from_flat',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep flat | sed s/-flat//').stdout())
set_variable(theme + '_assets_excluded_from_prime',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep flat').stdout())
set_variable(theme + '_assets_tone',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep "tango\|salsa\|rumba\|jive" | grep -v ' + theme_tone).stdout())
set_variable(theme + '_assets_excluded_from_casual',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep fancy | grep ' + theme_tone).stdout())
set_variable(theme + '_assets_excluded_from_fancy',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep fancy | grep ' + theme_tone + ' | sed s/-fancy-' + theme_tone + '//').stdout())
set_variable(theme + '_assets_excluded_from_no_handles',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep scrollbar\-handle').stdout())
set_variable(theme + '_assets_excluded_from_with_handles', '')
foreach assets : assets_array
# Exclude different types of assets from gtk3 theme
# (light gtk3 theme needs dark assets for dark variant)
if theme == 'gtk3'
exclude_color_variants = assets[2]
else
exclude_color_variants = assets[3]
endif
# Assets for xfwm theme should be in main 'xfwm4' folder (other themes has 'assets' subfolder)
if theme == 'xfwm4'
assets_install_dir = join_paths(get_variable(assets[0] + theme +'_dir'))
else
assets_install_dir = join_paths(get_variable(assets[0] + theme +'_dir'), 'assets')
endif
install_subdir('src/' + theme +'/assets',
install_dir: assets_install_dir,
exclude_files : [get_variable(theme + '_assets' + assets[1]).split('\n'),
get_variable(theme + '_assets' + exclude_color_variants).split('\n'),
get_variable(theme + '_assets_excluded_from_' + theme_style).split('\n'),
get_variable(theme + '_assets_tone').split('\n'),
get_variable(theme + '_assets_excluded_from_' + theme_scale_style).split('\n'),
get_variable(theme + '_assets_excluded_from_' + theme_scrollbar_handles).split('\n')],
strip_directory: true)
if theme == 'xfwm4'
# Remove color/size suffixes from xfwm assets
meson.add_install_script('sh', '-c', 'for i in $(ls ' + mid + get_variable(assets[0] + 'xfwm4_dir') + ' | grep "compact\|dark\|flat"); do mv ' + mid + get_variable(assets[0] + 'xfwm4_dir') + '/$i ' + mid + get_variable(assets[0] + 'xfwm4_dir') + '/$(echo $i | sed s/\-compact// | sed s/\-dark// | sed s/\-flat//); done')
endif
endforeach
endforeach
# AUXILIARY ICON THEME
if get_option('icons')
subdir('src/aux-icons')
endif
# METACITY THEME
subdir('src/metacity-1')
# Regular build end
endif
##### Flatpak build
if get_option('flatpak')
if get_option('flatpak-variant') == 'light'
if get_option('flatpak-size') == 'regular'
theme_dir = join_paths(get_option('datadir'), 'themes', 'Lounge')
gtk3_variants = [['light', '', 'regular'],
['dark', '-dark', 'regular']]
exclude_assets = ['_none', '_compact']
else
theme_dir = join_paths(get_option('datadir'), 'themes', 'Lounge-compact')
gtk3_variants = [['light', '', 'compact'],
['dark', '-dark', 'compact']]
exclude_assets = ['_none', '_regular']
endif
else
if get_option('flatpak-size') == 'regular'
theme_dir = join_paths(get_option('datadir'), 'themes', 'Lounge-night')
gtk3_variants = [['dark', '', 'regular']]
exclude_assets = ['_light', '_compact']
else
theme_dir = join_paths(get_option('datadir'), 'themes', 'Lounge-night-compact')
gtk3_variants = [['dark', '', 'compact']]
exclude_assets = ['_light', '_regular']
endif
endif
gtk3_dir = join_paths(theme_dir, 'gtk-3.0')
gtk3_noconf_sources = [
'gtk3-colors.scss',
'gtk3-colors-public.scss',
'gtk3-variables.scss',
'gtk3-drawing.scss',
'gtk3-common.scss',
'gtk3-apps.scss',
'gtk3-xfce.scss',
'gtk3-mate.css'
]
gtk3_version = '3.24'
gnome_version = '3.32'
copy = configuration_data()
copy.set('something', 'something')
foreach file : gtk3_noconf_sources
configure_file(input : join_paths('src/gtk3/' + file),
output : file,
configuration : copy)
endforeach
theme_tone = get_option('tone')
theme_style = get_option('style')
theme_scale_style = get_option('scale_style')
theme_scrollbar_handles = get_option('scrollbar_handles')
theme_button_outlines = get_option('button_outlines')
foreach variant : gtk3_variants
gtk3_conf = configuration_data()
gtk3_conf.set('gtk_variant', variant[0])
gtk3_conf.set('gtk_size', variant[2])
gtk3_conf.set('tone', theme_tone)
gtk3_conf.set('style', theme_style)
gtk3_conf.set('scale_style', theme_scale_style)
gtk3_conf.set('scrollbar_handles', theme_scrollbar_handles)
gtk3_conf.set('button_outlines', theme_button_outlines)
gtk3_conf.set('gtk_version', gtk3_version)
gtk3_conf.set('gnome_version', gnome_version)
gtk3_scss = configure_file(input : 'src/gtk3/gtk3.scss',
output : 'gtk3' + variant[1] + '.scss',
configuration : gtk3_conf)
custom_target('generate css for ' + variant[0] + ' theme',
input: gtk3_scss,
output: 'gtk' + variant[1] + '.css',
command: [ sassc, '-M', '-t', 'compact', '@INPUT@', '@OUTPUT@' ],
install: true,
install_dir: gtk3_dir)
endforeach
theme = 'gtk3'
set_variable(theme + '_assets_none', '')
set_variable(theme + '_assets_light',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep dark | sed s/-dark//').stdout())
set_variable(theme + '_assets_dark',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep dark').stdout())
set_variable(theme + '_assets_regular',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep compact | sed s/-compact//').stdout())
set_variable(theme + '_assets_compact',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep compact').stdout())
set_variable(theme + '_assets_excluded_from_prime',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep flat').stdout())
set_variable(theme + '_assets_tone',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep "tango\|salsa\|rumba\|jive" | grep -v tango').stdout())
set_variable(theme + '_assets_excluded_from_casual',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep fancy | grep ' + theme_tone).stdout())
set_variable(theme + '_assets_excluded_from_no_handles',
run_command('sh', '-c', 'ls ' + join_paths(meson.source_root(), 'src', theme, 'assets') +
' | grep scrollbar\-handle').stdout())
install_subdir('src/' + theme +'/assets',
install_dir: gtk3_dir,
exclude_files : [get_variable(theme + '_assets' + exclude_assets[0]).split('\n'),
get_variable(theme + '_assets' + exclude_assets[1]).split('\n'),
get_variable(theme + '_assets_excluded_from_prime').split('\n'),
get_variable(theme + '_assets_tone').split('\n'),
get_variable(theme + '_assets_excluded_from_casual').split('\n'),
get_variable(theme + '_assets_excluded_from_no_handles').split('\n')])
endif