-
Notifications
You must be signed in to change notification settings - Fork 53
/
create-links
executable file
·37 lines (35 loc) · 2.04 KB
/
create-links
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
#!/usr/bin/python3
import os, sys
if __name__ == '__main__':
if len(sys.argv) >= 4:
basedir = os.getcwd()
icontype = sys.argv[1]
iconname = sys.argv[2]
linknames = sys.argv[3:]
colors = ["", "-Aqua", "-Blue", "-Brown", "-Grey", "-Orange", "-Pink", "-Purple", "-Red", "-Sand", "-Teal", "-Yellow"]
extensions = [".png", ".svg"]
for extension in extensions:
iconname = iconname + extension
for color in colors:
for dirname, subdirs, filelist in os.walk("usr/share/icons/Mint-Y%s/%s" % (color, icontype)):
for filename in filelist:
if filename == iconname:
print(filename)
iconpath = os.path.join(dirname, iconname)
if os.path.exists(iconpath):
if os.path.islink(iconpath):
print ("!!! SKIPPED: %s is a link! Please fix this manually (it could lead to a circular link situation)." % iconpath)
else:
print("--> %s:" % dirname)
os.chdir(dirname)
for linkname in linknames:
linkname = linkname + extension
if os.path.exists(linkname):
print(" rm %s" % linkname)
os.system("rm %s" % linkname)
print (" ln -s %s %s" % (iconname, linkname))
os.system("ln -s %s %s" % (iconname, linkname))
os.chdir(basedir)
else:
print("Usage: %s icon-type icon-name link-name [more-link-names]" % sys.argv[0])
print ("Note: if link-name already exists (whether it's a link or a file), it gets deleted first, and then it is created as a new link pointing to icon-name")