-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlife_save.py
More file actions
51 lines (24 loc) · 1.08 KB
/
Copy pathlife_save.py
File metadata and controls
51 lines (24 loc) · 1.08 KB
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
from getpass import getuser
from os import walk
import json
def return_list_folders(your_path:str) -> list:
# returns a list of folders in given path.
# may act weird if you're not the root trying to access root-only folders
return next(walk(your_path))[1] #[1] = only folders
if __name__ == "__main__":
user = getuser()
path = f'/home/{user}/.config'
ggl = [x for x in return_list_folders(path) if x.__contains__("chrome")]
if not ggl:
raise ValueError(f"Chrome has no data stored in /home/{user}/.config")
else:
path = path+"/"+ggl[0]
prfls = [x for x in return_list_folders(path) if x.__contains__("Profile ")]
profile_dict={}
for prfl in prfls:
with open(f'{path}/{prfl}/Preferences') as json_file:
pref_json = json.load(json_file)
profile_dict[prfl] = pref_json['profile']['name']
print(profile_dict)
print(f"{len(profile_dict)} profiles identified. You want to rename any of them? \nProfile",end=' ')
#google-chrome-stable --profile-directory="Profile n"