-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-0.48.2.py
executable file
·65 lines (58 loc) · 1.66 KB
/
patch-0.48.2.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
#! /usr/bin/python -u
import os, subprocess, sys
# Thanks to http://cheer-ful.seesaa.net/article/150789261.html
xmodmap_content = """keycode 66 = Meta_L
keycode 69=Meta_R
keycode 67 = Meta_L
keycode 63 = Control_L
keycode 71 = Control_R
clear mod2
clear control
add mod2 = Meta_L
add control = Control_L Control_R
"""
xmodmap_file = os.environ["HOME"]+"/.xmodmap"
# Thanks to http://blog.livedoor.jp/unahide/archives/52785330.html
inkscape_file = "/Applications/Inkscape.app/Contents/Resources/bin/inkscape"
def move_to_bak(f):
bak = f+".bak"
if not os.path.isfile(f) or os.path.isfile(bak):
return bak
os.rename(f,bak)
return bak
def main(argv):
if len(argv) > 1:
lang = argv[1]
else: lang = "ja_JP.UTF8"
move_to_bak(xmodmap_file)
fw = open(xmodmap_file,"w")
fw.write(xmodmap_content)
fw.close()
print "Created '%s'." % (xmodmap_file)
print "It enables Inkscape to Alt key."
print ""
tmp = "/tmp/inkscape"
bak = move_to_bak(inkscape_file)
fw = open(tmp,"w")
fr = open(bak,"r")
following = 0
for line in fr:
if line.startswith("export LANG="):
fw.write("#"+line)
following = 1
elif following > 0:
following -= 1
fw.write("#"+line)
fw.write("export LANG=%s\n" % (lang))
else:
fw.write(line)
fr.close()
fw.close()
subprocess.call(["mv",tmp,inkscape_file])
subprocess.call(["chmod","+x",inkscape_file])
print "Modified '%s'." % (inkscape_file)
print "It changes Inkscape default language to Japanese."
print ""
if __name__ == "__main__":
# inkscape.py lang
main(sys.argv)