]>
code.delx.au - monosys/blob - set-font-xfce4-terminal
9 action
= parse_action()
12 update_font_size(get_size_increment
)
14 update_font_size(get_size_decrement
)
16 update_font_size(lambda _
: action
)
19 if len(sys
.argv
) != 2:
23 if action
!= "+" and action
!= "-" and not action
.isdigit():
33 def print_help_exit():
34 print("Usage: %s [+|-|22]", file=sys
.stderr
)
37 def get_size_increment(size
):
39 return math
.floor(size
/ 8) * 8 + 8
41 return math
.floor(size
/ 4) * 4 + 4
43 return math
.floor(size
/ 2) * 2 + 2
46 def get_size_decrement(size
):
48 return math
.ceil(size
/ 8) * 8 - 8
50 return math
.ceil(size
/ 4) * 4 - 4
52 return math
.ceil(size
/ 2) * 2 - 2
55 def update_font_size(fn
):
56 filename
= get_config_filename()
57 config
= configparser
.RawConfigParser()
58 config
.optionxform
= lambda key
: key
61 font_name
, old_size
= config
["Configuration"]["FontName"].rsplit(" ", 1)
62 new_size
= fn(int(old_size
))
63 config
["Configuration"]["FontName"] = "%s %s" % (font_name
, new_size
)
65 print("Updating font size:", old_size
, "->", new_size
)
67 with
open(filename
+".new", "w") as f
:
69 os
.rename(filename
+".new", filename
)
71 def get_config_filename():
72 xdg_config_dir
= os
.environ
.get("XDG_CONFIG_HOME", None)
73 if not xdg_config_dir
:
74 xdg_config_dir
= os
.path
.expanduser("~/.config")
75 return os
.path
.join(xdg_config_dir
, "xfce4", "terminal", "terminalrc")
78 if __name__
== "__main__":