-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
453 lines (342 loc) · 10.5 KB
/
gulpfile.js
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
/**
* Plane theme
* Copyright (C) 2017 wfpaisa
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
*
* @author @wfpaisa
* @copyright 2017 Plane theme
*/
"use strict";
const version = '4.0';
/* Dependencies */
var fs = require('fs'),
path = require('path'),
gulp = require('gulp'),
del = require('del'),
exec = require('child_process').exec,
watch = require('gulp-watch'),
sass = require('gulp-sass'),
rename = require("gulp-rename"),
os = require('os'),
zip = require("gulp-zip");
/* Global variables */
var dirLight = 'Plane';
var dirDark = 'Plane-dark';
/*========================================
= Global functions =
========================================*/
/**
* Time Log + Message
*
* @param {string} m message
*/
function timeLog(m) {
var d = new Date();
var n = d.toTimeString().split(' ')[0];
console.log(`[${n}] ${m}`);
}
/**
* GTK Auto reload
*/
function autoreload() {
var theme = dirLight;
/* Active dark theme */
if (process.argv[process.argv.length - 1]) {
let argv = process.argv[process.argv.length - 1];
if (argv == '-D') theme = dirDark;
/* First change default theme and late change to our theme */
exec(`gsettings set org.gnome.desktop.interface gtk-theme Adwaita && gsettings set org.gnome.shell.extensions.user-theme name "Deault"`, () => {
setTimeout(function () {
exec(`gsettings set org.gnome.desktop.interface gtk-theme ${theme} && gsettings set org.gnome.shell.extensions.user-theme name ${theme}`, () => {
timeLog(`Reload ${theme} theme`);
return;
})
}, 500);
})
}
}
/**
*
* Copy all files in user folder
*
*/
gulp.task('copy-user-theme-folder', function () {
return gulp.src('./build/**/*')
.pipe(gulp.dest(os.homedir() + '/.local/share/themes/'))
})
/*===== End of Global functions ======*/
/*====================================
= Common tasks =
====================================*/
/*---------- Gnome-shell ----------*/
gulp.task('gnome-shell-light', function (cb) {
return gulp.src(`./src/gnome-shell/gnome-shell.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`./build/${dirLight}/gnome-shell/`))
});
gulp.task('gnome-shell-light-assets', function () {
return gulp.src([
"./src/gnome-shell/common-assets/*.*",
"./src/gnome-shell/light-assets/*.*",
])
.pipe(gulp.dest(`./build/${dirLight}/gnome-shell/`));
})
gulp.task('gnome-shell-dark', function (cb) {
return gulp.src(`./src/gnome-shell/gnome-shell-dark.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(rename('gnome-shell.css'))
.pipe(gulp.dest(`./build/${dirDark}/gnome-shell/`))
});
gulp.task('gnome-shell-dark-assets', function () {
return gulp.src([
"./src/gnome-shell/common-assets/*.*",
"./src/gnome-shell/dark-assets/*.*",
])
.pipe(gulp.dest(`./build/${dirDark}/gnome-shell/`));
})
gulp.task('gnome-shell-high', function (cb) {
return gulp.src(`./src/gnome-shell/gnome-shell-high-contrast.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`./build/${dirDark}/gnome-shell/`))
.pipe(gulp.dest(`./build/${dirLight}/gnome-shell/`))
});
/*---------- gtk-4.0 ----------*/
gulp.task('gtk4-light', function (cb) {
return gulp.src(`./src/gtk-4.0/**/*.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`./build/${dirLight}/gtk-4.0`))
});
gulp.task('gtk4-dark', function (cb) {
return gulp.src(`./src/gtk-4.0/gtk-contained-dark.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(rename('gtk.css'))
.pipe(gulp.dest(`./build/${dirDark}/gtk-4.0/`));
});
gulp.task('gtk4-assets', function () {
return gulp.src("./src/gtk-4.0/assets/*")
.pipe(gulp.dest(`./build/${dirLight}/gtk-4.0/assets`))
.pipe(gulp.dest(`./build/${dirDark}/gtk-4.0/assets`));
})
/*---------- gtk-3.0 ----------*/
gulp.task('gtk3-light', function (cb) {
return gulp.src(`./src/gtk-3.0/**/*.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`./build/${dirLight}/gtk-3.0`))
});
gulp.task('gtk3-dark', function (cb) {
return gulp.src(`./src/gtk-3.0/gtk-contained-dark.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(rename('gtk.css'))
.pipe(gulp.dest(`./build/${dirDark}/gtk-3.0/`));
});
gulp.task('gtk3-assets', function () {
return gulp.src("./src/gtk-3.0/assets/*")
.pipe(gulp.dest(`./build/${dirLight}/gtk-3.0/assets`))
.pipe(gulp.dest(`./build/${dirDark}/gtk-3.0/assets`));
})
/*---------- gtk-2.0 ----------*/
// Light
gulp.task('gtk2-light', ['gtk2-light-assets', 'gtk2-light-menubar', 'gtk2-light-files']);
gulp.task('gtk2-light-assets', function (cb) {
return gulp.src('./src/gtk-2.0/assets/*')
.pipe(gulp.dest(`./build/${dirLight}/gtk-2.0/assets`))
});
gulp.task('gtk2-light-menubar', function (cb) {
return gulp.src([
"./src/gtk-2.0/menubar-toolbar/*",
"!./src/gtk-2.0/menubar-toolbar/menubar-toolbar-dark.rc",
])
.pipe(gulp.dest(`./build/${dirLight}/gtk-2.0/menubar-toolbar`))
});
gulp.task('gtk2-light-files', function () {
return gulp.src([
"./src/gtk-2.0/apps.rc",
"./src/gtk-2.0/gtkrc",
"./src/gtk-2.0/main.rc",
"./src/gtk-2.0/panel.rc",
"./src/gtk-2.0/xfce-notify.rc",
])
.pipe(gulp.dest(`./build/${dirLight}/gtk-2.0`));
})
// Dark
gulp.task('gtk2-dark', ['gtk2-dark-assets', 'gtk2-dark-menubar', 'gtk2-dark-files', 'gtk2-gtkrc-dark']);
gulp.task('gtk2-dark-assets', function (cb) {
return gulp.src('./src/gtk-2.0/assets-dark/*')
.pipe(gulp.dest(`./build/${dirDark}/gtk-2.0/assets`))
});
gulp.task('gtk2-dark-menubar', function (cb) {
return gulp.src([
"./src/gtk-2.0/menubar-toolbar/*",
"!./src/gtk-2.0/menubar-toolbar/menubar-toolbar.rc",
])
.pipe(gulp.dest(`./build/${dirDark}/gtk-2.0/menubar-toolbar`))
});
gulp.task('gtk2-dark-files', function () {
return gulp.src([
"./src/gtk-2.0/apps.rc",
"./src/gtk-2.0/main.rc",
"./src/gtk-2.0/panel.rc",
"./src/gtk-2.0/xfce-notify.rc",
])
.pipe(gulp.dest(`./build/${dirDark}/gtk-2.0`));
})
gulp.task('gtk2-gtkrc-dark', function (cb) {
return gulp.src('./src/gtk-2.0/gtkrc-dark')
.pipe(rename('gtkrc'))
.pipe(gulp.dest(`./build/${dirDark}/gtk-2.0`))
});
// gulp.task('gtk2-light', function(){
// return gulp.src([
// "./src/gtk-2.0/*",
// "./src/gtk-2.0/*/*",
// "!./src/gtk-2.0/*-dark",
// "!./src/gtk-2.0/*-dark/*",
// ])
// .pipe(gulp.dest(`./build/${dirLight}/gtk-2.0/`));
// })
// gulp.task('gtk2-dark', function(){
// return gulp.src([
// "./src/gtk-2.0/*",
// "./src/gtk-2.0/*/*",
// "!./src/gtk-2.0/assets/*",
// ])
// .pipe(rename(function (path) {
// // Send dark files to dark directory
// if(path.basename.indexOf('-dark') > -1 || path.dirname.indexOf('-dark') > -1 ){
// path.basename = path.basename.replace('-dark','');
// path.dirname = path.dirname.replace('-dark','');
// }
// }))
// .pipe(gulp.dest(`./build/${dirDark}/gtk-2.0/`));
// })
/*---------- Theme File ----------*/
gulp.task('theme-light', function () {
return gulp.src('./src/index.theme')
.pipe(gulp.dest(`./build/${dirLight}`))
})
gulp.task('theme-dark', function () {
return gulp.src('./src/index-dark.theme')
.pipe(rename('index.theme'))
.pipe(gulp.dest(`./build/${dirDark}`))
})
/*---------- xfwm4 ----------*/
gulp.task('xfwm4-light', function (cb) {
return gulp.src([
'./src/xfwm4/assets/*.png',
'./src/xfwm4/themerc'
])
.pipe(gulp.dest(`./build/${dirLight}/xfwm4`))
});
gulp.task('xfwm4-dark', ['xfwm4-dark-assets', 'xfwm4-dark-themerc']);
gulp.task('xfwm4-dark-assets', function (cb) {
return gulp.src('./src/xfwm4/assets-dark/*.png')
.pipe(gulp.dest(`./build/${dirDark}/xfwm4`))
});
gulp.task('xfwm4-dark-themerc', function (cb) {
return gulp.src('./src/xfwm4/themerc-dark')
.pipe(rename('themerc'))
.pipe(gulp.dest(`./build/${dirDark}/xfwm4`))
});
/*===== End of Common tasks ======*/
/*=============================
= Watch =
=============================*/
gulp.task('watch', function () {
// Gtk4
gulp.watch('./src/gtk-4.0/**/*.scss', function (cb) {
gulp.start(['gtk4-light', 'gtk4-dark'], function () {
gulp.start('copy-user-theme-folder', function () {
autoreload();
})
})
});
gulp.watch('./src/gtk-4.0/assets/*', function (file) {
gulp.src(file.path)
.pipe(gulp.dest(`./build/${dirLight}/gtk-4.0/assets`))
.pipe(gulp.dest(`./build/${dirDark}/gtk-4.0/assets`))
.on('end', (cb) => {
timeLog(`gtk-4.0 Assets`);
})
});
// Gtk3
gulp.watch('./src/gtk-3.0/**/*.scss', function (cb) {
gulp.start(['gtk3-light', 'gtk3-dark'], function () {
gulp.start('copy-user-theme-folder', function () {
autoreload();
})
})
});
gulp.watch('./src/gtk-3.0/assets/*', function (file) {
gulp.src(file.path)
.pipe(gulp.dest(`./build/${dirLight}/gtk-3.0/assets`))
.pipe(gulp.dest(`./build/${dirDark}/gtk-3.0/assets`))
.on('end', (cb) => {
timeLog(`gtk-3.0 Assets`);
})
});
// Gnome-shell
gulp.watch('./src/gnome-shell/**/*.scss', function (cb) {
gulp.start([
'gnome-shell-light',
'gnome-shell-light-assets',
'gnome-shell-dark',
'gnome-shell-dark-assets',
'gnome-shell-high'
], function () {
gulp.start('copy-user-theme-folder', function () {
autoreload();
})
})
});
});
/*===== End of Watch ======*/
gulp.task('zip-light', function () {
return gulp.src(`./build/${dirLight}/**/*`)
.pipe(zip(`${dirLight}-${version}.zip`))
.pipe(gulp.dest('./build/'))
})
gulp.task('zip-dark', function () {
return gulp.src(`./build/${dirDark}/**/*`)
.pipe(zip(`${dirDark}-${version}.zip`))
.pipe(gulp.dest('./build/'))
})
/**
*
* Generate Plane and Plane-dark theme
*
*/
gulp.task('default', [
'theme-light',
'theme-dark',
'gtk4-light',
'gtk4-dark',
'gtk4-assets',
'gtk3-light',
'gtk3-dark',
'gtk3-assets',
'gtk2-light',
'gtk2-dark',
'gnome-shell-light',
'gnome-shell-light-assets',
'gnome-shell-dark',
'gnome-shell-dark-assets',
'gnome-shell-high',
'xfwm4-light',
'xfwm4-dark'
], (cb) => {
gulp.start(['zip-light', 'zip-dark'], function () {
cb;
})
});