Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
noah committed May 30, 2013
0 parents commit 1aecae5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
`xfce4-terminal` doesn't provide a facility for {in,de}creasing font
size in a running terminal. However, `xfce4-terminal` *does* watch the
file `$XDG_CONFIG_PATH/xfce4/terminal/terminalrc` for changes to the
`FontName` directive (which includes size).

Therefore, this script can be bound to a via a keyboard shortcut that
will change the font size, albeit after a short delay.

No thanks to `urxvt-unicode` for not supporting fontconfig, which is
necessary to run an unpatched Monaco font in Powerline, which I *must*
have, all of which prompted my switch to xfce4-terminal which *does*
support fontconfig and ... oh, nevermind.
37 changes: 37 additions & 0 deletions xfce4-terminal-font
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# xfce4-terminal-font.py -- programmatically change the font size of an
# xfce4-terminal.
#
# Copyright © 2013 Noah K. Tilton <[email protected]>
#
# License: GPLv2 or later.

# working with xfce4-terminal-0.6.2-1

if __name__ == "__main__":

import sys

PM = ["+", "-"]
if len(sys.argv) != 2 or sys.argv[1] not in PM:
sys.exit("Usage {0} {1}".format(sys.argv[0], "/".join(PM)))

delta = int("{0}1".format(sys.argv[1]))

import os
import re
from configparser import RawConfigParser

# read input file
f = os.path.join(os.environ["XDG_CONFIG_HOME"], "xfce4", "terminal", "terminalrc")
c = RawConfigParser()
c.optionxform = str # make keys case-sensitive
c.read(f)
font, size = re.search(r'^(.*) (\d+)$', c['Configuration']['FontName']).group(1, 2)
size = int(size) + delta
c['Configuration']['FontName'] = "{0} {1}".format(font, size)

with open(f, 'w') as c_new:
c.write(c_new)

0 comments on commit 1aecae5

Please sign in to comment.