Last active
December 21, 2015 22:19
-
-
Save blmarket/6374458 to your computer and use it in GitHub Desktop.
Terminator plugin which sets font size to 85% of config if window size is smaller than specified value(HARD-CODED)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pango | |
from terminatorlib.util import dbg | |
import terminatorlib.plugin as plugin | |
# AVAILABLE must contain a list of all the classes that you want exposed | |
AVAILABLE = ['AutoFontSizePlugin'] | |
class Resizer: | |
def __init__(self, term): | |
self.term = term | |
self.term.vte.connect('size-allocate', self.on_resize) | |
def on_resize(self, widget, allocation): | |
# current = self.term.vte.get_font() | |
config = pango.FontDescription(self.term.config['font']) | |
# dbg(current.get_size()) | |
dbg(config.get_size()) | |
dbg(allocation) | |
if allocation.width < 600 or allocation.height < 400: | |
config.set_size(int(config.get_size() * 0.85)) | |
self.term.set_font(config) | |
class AutoFontSizePlugin(plugin.Plugin): | |
capabilities = ['autofontsize'] | |
def __init__(self): | |
terminator = plugin.Terminator() | |
for term in terminator.terminals: | |
dbg(term) | |
Resizer(term) # it also connects signal handler. | |
pass | |
def unload(self): | |
# IDK how to disconnect 'size-allocate' from vte | |
pass | |
def do_test(self): | |
dbg('TestPluginWin') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: put it in ~/.config/terminator/plugins, and enable it in plugin window(preferences - Plugins - Enable AutoFontSizePlugin - PROFIT)