-
Notifications
You must be signed in to change notification settings - Fork 2
/
themer.py
72 lines (61 loc) · 2.1 KB
/
themer.py
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
import json
import pprint
import os
pp = pprint.PrettyPrinter(4)
# profiles.json path
l = os.getenv('localappdata')
a = '\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json'
pathProfile = l+a
fileJson = open(pathProfile, 'r')
profiles = json.load(fileJson)
fileJson.close()
# Defaults
defaultFallback = {
'acrylicOpacity': 0.65,
'background': '#024557',
'closeOnExit': True,
'colorScheme': 'Campbell',
'commandline': 'powershell.exe',
'cursorColor': '#FFFFFF',
'cursorShape': 'vintage',
'fontFace': 'Consolas',
'fontSize': 11,
'guid': '{61c54bbd-c2c6-5271-96e7-009a87ff44bf}',
'historySize': 9001,
'icon': 'ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png',
'name': 'Windows PowerShell',
'padding': '0, 0, 0, 0',
'snapOnInput': True,
'startingDirectory': '%USERPROFILE%',
'useAcrylic': True}
# currentProfName = "WLinux"
def getProfname():
return input('Enter the name of terminal who\'s profile you want to change: ') or 'Windows PowerShell'
allProfs = []
def displayAvailableProfiles():
# print(profiles['profiles']['list'])
for prof in profiles['profiles']['list']:
allProfs.append(prof['name'])
# print(prof['name'])
def findProfile():
for x in profiles['profiles']['list']:
if x['name'] == currentProfName:
return x
def writeProfile(currentProf):
with open(pathProfile, 'r+') as f:
data = json.load(f)
# print(data)
for p in range(len(data['profiles']['list'])):
if data['profiles']['list'][p]['name'] == currentProfName:
data['profiles']['list'][p] = currentProf
# seek to the begining, write and remove everything else
f.seek(0)
json.dump(data, f, indent=4)
f.truncate()
# print('Available Windows Terminal Profiles:')
displayAvailableProfiles()
# currentProfName = getProfname()
currentProfName = allProfs[0]
currentProf = findProfile()
# print('Current Profile:')
# pp.pprint(currentProf)