-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·141 lines (118 loc) · 4.86 KB
/
setup.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python3
# Imports
import os
import sys
import shutil
import classes
# global declares
HOME = "/home/pheonix/" # Path must end with / (change to your home directory
SCRIPT_DIR = os.path.realpath(__file__) # get the script path **(do not change)**
DEBUG = False # enable / disable debuging (if enabled the script will NOT copy the files)
def Setup(argv):
print("================================================")
print("= i3wm Setup script =")
print("================================================")
if not len(sys.argv) > 1:
showhelp(False)
else:
for arg in argv:
if not arg == os.path.basename(SCRIPT_DIR) and not arg == "./setup.py":
if arg == "--all":
copy_i3_config()
copy_i3lock()
copy_configs()
print("======================")
print("DONE!")
elif arg == "--i3":
copy_i3_config()
print("======================")
print("DONE!")
elif arg == "--config":
copy_configs()
print("======================")
print("DONE!")
elif arg == "--i3lock":
copy_i3lock()
print("======================")
print("DONE!")
elif arg == "-h":
showhelp(True)
else:
showhelp(False)
# help commands
def showhelp(bools):
if not bools:
print("usage: setup.py [--options]")
else:
print("example: \n"
"1)./setup.py --all\n"
"2) python setup.py --all")
print("---------------------------------")
print("--all install all configuration files")
print("--i3 install only the .i3 config and ~/ configuration files")
print("--i3lock install only the i3lock files ~/.config/i3")
print("--config install only the .config files ~/.config/*")
print("")
print("Use -h to see commands again")
# copy the i3 configuration files
def copy_i3_config():
if not os.path.exists(HOME + ".i3"):
os.makedirs(HOME + ".i3")
for fl in os.listdir("i3/"):
if os.path.isfile("i3/" + fl):
if not DEBUG:
shutil.copy("i3/" + fl, HOME + ".i3/" + fl)
print("Copying i3/" + fl + " to " + HOME + ".i3/" + fl)
for fl in os.listdir("home/"):
if os.path.isfile("home/" + fl):
if not DEBUG:
shutil.copy("home/" + fl, HOME + fl)
print("Copying home/" + fl + " to " + HOME + fl)
# copy the i3lock files
def copy_i3lock():
if not os.path.exists(HOME + ".config/i3"):
os.makedirs(HOME + ".config/i3")
for fl in os.listdir("config/i3"):
if not DEBUG:
shutil.copy("config/i3/" + fl, HOME + ".config/i3/" + fl)
print("Copying config/i3/" + fl + " to " + HOME + ".config/i3/" + fl)
# copy the /home configuration files
def copy_configs():
if not os.path.exists(HOME + ".config/neofetch"):
os.makedirs(HOME + ".config/neofetch")
if not os.path.exists(HOME + ".config/cava"):
os.makedirs(HOME + ".config/cava")
if not os.path.exists(HOME + ".config/ranger"):
os.makedirs(HOME + ".config/ranger")
for fl in os.listdir("config/neofetch"):
if os.path.isfile("config/neofetch/" + fl):
if not DEBUG:
shutil.copy("config/neofetch/" + fl, HOME + ".config/neofetch" + fl)
print("Copying config/neofetch/" + fl + " to " + HOME + ".config/neofetch/" + fl)
for fl in os.listdir("config/ranger"):
if os.path.isfile("config/ranger/" + fl):
if not DEBUG:
shutil.copy("config/ranger/" + fl, HOME + ".config/ranger" + fl)
print("Copying config/ranger/" + fl + " to " + HOME + ".config/ranger/" + fl)
for fl in os.listdir("config/cava"):
if os.path.isfile("config/cava/" + fl):
if not DEBUG:
shutil.copy("config/cava/" + fl, HOME + ".config/cava" + fl)
print("Copying config/cava/" + fl + " to " + HOME + ".config/cava/" + fl)
# run the script
if __name__ == '__main__':
nothelp = True
if len(sys.argv) > 1:
for arg in sys.argv:
if arg == "-h":
nothelp = False
if nothelp:
files = classes.CheckFiles()
if files.check_configs() and files.check_i3() and files.check_lock() \
and files.check_home():
print("---------------------------------")
print("Check Success ........")
print("---------------------------------")
else:
print("some config files not found")
Setup(sys.argv)