-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathxresources.ts
70 lines (59 loc) · 2.06 KB
/
xresources.ts
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
import type { Template } from './index.js';
import { brightMix, colorSetToVariants } from '../color-set/index.js';
import { source } from 'common-tags';
import Color from 'color';
function format(hex: string): string {
return `rgb:${Color(hex)
.rgb()
.array()
.map((n) => n.toString(16))
.join('/')}`;
}
const template: Template = {
name: 'Xresources',
render: async function* (colorSet) {
const variants = colorSetToVariants(colorSet);
for (const { title, colors, isDark } of variants) {
yield {
path: `${title.kebab}.Xresources`,
content: source`
! general
*background: ${format(colors.shade0)}
*foreground: ${format(colors.shade6)}
! blacks
*color0: ${format(isDark ? colors.shade2 : colors.shade6)}
*color8: ${format(isDark ? colors.shade3 : colors.shade5)}
! reds
*color1: ${format(colors.accent0)}
*color9: ${format(brightMix(colors, 'accent0', isDark))}
! greens
*color2: ${format(colors.accent3)}
*color10: ${format(brightMix(colors, 'accent3', isDark))}
! yellows
*color3: ${format(colors.accent2)}
*color11: ${format(brightMix(colors, 'accent2', isDark))}
! blues
*color4: ${format(colors.accent5)}
*color12: ${format(brightMix(colors, 'accent5', isDark))}
! magentas
*color5: ${format(colors.accent7)}
*color13: ${format(brightMix(colors, 'accent7', isDark))}
! cyans
*color6: ${format(colors.accent4)}
*color14: ${format(brightMix(colors, 'accent4', isDark))}
! whites
*color7: ${format(isDark ? colors.shade6 : colors.shade2)}
*color15: ${format(isDark ? colors.shade7 : colors.shade1)}
`,
};
}
},
renderInstructions: (paths) => source`
Copy the contents of ${paths
.map((p) => `'${p}'`)
.join(
' or ',
)} into your .Xresources configuration file, or load it with \`xrdb\`.
`,
};
export default template;