-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme-changer.nix
126 lines (109 loc) · 3.4 KB
/
theme-changer.nix
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
{
pkgs,
extraThemes ? {},
extraScripts ? {},
}:
with builtins;
let
enabled_modules = [
# "alacritty"
# "doom-emacs"
"vscodium"
"vscode"
"gtk3"
# "sway"
"lookandfeeltool"
];
themes = {
dark = rec {
alacritty = ./alacritty/monokai.toml;
spacemacs = "spacemacs-dark";
doom-emacs = "doom-monokai-classic";
vscodium = "Monokai";
vscode = vscodium;
gtk3 = "Adwaita-dark";
sway = "";
lookandfeeltool = "org.kde.breezedark.desktop";
};
light = rec {
alacritty = ./alacritty/gruvbox-light.toml;
spacemacs = "spacemacs-light";
doom-emacs = "doom-gruvbox-light";
vscodium = "Default Light+";
vscode = vscodium;
gtk3 = "Adwaita";
sway = "";
lookandfeeltool = "org.kde.breeze.desktop";
};
sailor = rec {
alacritty = ./alacritty/fairyfloss.toml;
spacemacs = "spacemacs-light";
doom-emacs = "doom-fairy-floss";
vscodium = "fairyfloss";
vscode = vscodium;
lookandfeeltool = "kde.breeze.desktop";
gtk3 = "Adwaita-dark";
sway = ''
sway font pango:FiraSansCondensed 8
sway bar bar-0 colors background 5a5475
sway bar bar-0 colors statusline f8f8f0
sway bar bar-0 colors focused_workspace 554357 554357 f8f8f0
sway bar bar-0 colors inactive_workspace 343145 343145 f8f8f033
sway client.unfocused 5a5475aa 5a5475 f8f8f2 5a5475 5a5475
sway client.focused 5a5475 5a5475 f8f8f2 2e9ef4 28aa77
sway bar bar-0 font pango:FiraSansCondensed 8
'';
};
};
inlineJq = fname: query: (''
tmp_settings=$(mktemp)
cp ${fname} ${fname}.bkp
${pkgs.jq}/bin/jq '${query}' ${fname} > $tmp_settings
mv $tmp_settings ${fname}
'');
scripts = {
# alacritty doesn't create it's config folder by default, so yeah.
alacritty = (t: ''mkdir -p ~/.config/alacritty; chmod +w ~/.config/alacritty/alacritty.toml; { cat ${t} ${./alacritty/common.toml}; } > ~/.config/alacritty/alacritty.toml'');
spacemacs = (t: ''emacsclient -e "(spacemacs/load-theme '${t})"'');
doom-emacs = (t: ''emacsclient -e "(load-theme '${t} t)"'');
vscodium = t: inlineJq "~/.config/VSCodium/User/settings.json" ''.["workbench.colorTheme"]=${builtins.toJSON t}'';
vscode = t: inlineJq "~/.config/Code/User/settings.json" ''.["workbench.colorTheme"]=${builtins.toJSON t}'';
gtk3 = t: ''${pkgs.dconf}/bin/dconf write /org/gnome/desktop/interface/gtk-theme \"${t}\"'';
lookandfeeltool = t: ''${pkgs.libsForQt5.plasma-workspace}/bin/lookandfeeltool -a ${t}'';
sway = t: t;
};
genSwitcher =
theme-name: theme:
''
# #######
## ${theme-name}
### #######
fail() { echo failed at setting $prog; }
setup() { prog=$1; set -e; trap fail EXIT; }
success() { trap - EXIT; }
'' +
concatStringsSep "" (
attrValues (
mapAttrs
(program: theme-fn:
if !(elem program enabled_modules)
then ""
else ''
{ # ${program}
setup ${program}
${theme-fn theme.${program}}
success
} &
'')
scripts
)
);
in pkgs.symlinkJoin {
name = "theme-switchers";
paths = attrValues (mapAttrs (
theme-name: theme:
pkgs.writeShellScriptBin
"${theme-name}-theme"
(genSwitcher theme-name theme)
) themes);
}