-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
78 lines (75 loc) · 2.43 KB
/
index.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
const fs = require('fs');
const color_indexes = {
0: 'black',
1: 'red',
2: 'green',
3: 'yellow',
4: 'blue',
5: 'magenta',
6: 'cyan',
7: 'white',
8: 'lightBlack',
9: 'lightRed',
10: 'lightGreen',
11: 'lightYellow',
12: 'lightBlue',
13: 'lightMagenta',
14: 'lightCyan',
15: 'lightWhite'
};
const setColor = function(data, count, colors) {
colors[color_indexes[count]] = data;
};
const getWalColorConfig = function(input, setColor, config) {
var lines = input.toString().split('\n'),
colors = config.colors;
for (var i = 0; i < lines.length; i++) {
setColor(lines[i], i, colors);
}
var backgroundColor = colors.black,
foregroundColor = colors.lightWhite,
cursorColor = foregroundColor,
borderColor = backgroundColor;
return Object.assign({}, config, {
foregroundColor, // foreground color
backgroundColor, // background color
borderColor, // border color
cursorColor, // cursor color
colors,
css: `
${config.css || ''}
body, .shape_1oxq, .tab_1nfg, .active_fqd {
color: ${foregroundColor};
}
.closeWindow_ohv:hover {
color: ${colors.red};
}
.tabs_list {
background-color: rgba(0, 0, 0, 0.1)!important;
}
.tab_tab {
border-left: 1px solid rgba(0, 0, 0, 0.1)!important;
border-top: 1px solid rgba(0, 0, 0, 0.1)!important;
border-right: 1px solid rgba(255, 255, 255, 0.1)!important;
border-bottom: 1px solid rgba(255, 255, 255, 0.1)!important;
}
.tab_tab.tab_active {
background-color: rgba(255, 255, 255, 0.1)!important;
border-left: 1px solid rgba(255, 255, 255, 0.1)!important;
border-top: 1px solid rgba(255, 255, 255, 0.1)!important;
border-right: 1px solid rgba(0, 0, 0, 0.1)!important;
border-bottom: 1px solid rgba(0, 0, 0, 0.1)!important;
}
`
})
};
const file_path = require('os').homedir() + '/.cache/wal/colors';
const input = fs.existsSync(file_path) ? fs.readFileSync(file_path) : null;
exports.decorateConfig = config => {
if (input) {
return getWalColorConfig(input, setColor, config);
} else {
console.log('Couldn\'t find wal cached colors. Run wal first.');
return Object.assign({}, config, {});
}
};