#!/usr/bin/env python3
import subprocess
import sys
import ast
"""
Copyright (C) 2016 Jacob Vlijm
https://launchpad.net/~vlijm/+contactuser
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or any later version. This
program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. You
should have received a copy of the GNU General Public License along with this
program. If not, see <http://www.gnu.org/licenses/>.
"""
arg = sys.argv[1]
k = ["/org/gnome/terminal/legacy/profiles:/:", "/use-system-font", "font"]
def get(cmd):
return subprocess.check_output(cmd).decode("utf-8").strip()
def run(cmd):
subprocess.Popen(cmd)
def set_size(profile):
def_font = k[0]+profile+k[1]
# first set use default font to false
run(["dconf", "write", def_font, "false"])
# read the current font
currfont = ast.literal_eval(get(["dconf", "read", k[0]+profile+"/"+k[2]])).split()
# read the current size
currsize = float(currfont[-1])
# set the newsize
if arg == "up":
newsize = currsize+0.5
elif arg == "down":
newsize = currsize-0.5
run(["dconf", "write", k[0]+profile+"/"+k[2], "'"+currfont[0]+" "+str(newsize)+"'"])
# get profiles
prf = k[0][:-1]+"list"
# set fontsize up/down 0.5
for p in ast.literal_eval(get(["dconf", "read", prf])):
set_size(p)
下面的脚本将一次设置所有配置文件的字体大小,步长为 0.5。你必须看看这对你来说是否足够;终端不会对所有步骤做出反应。
就我而言,从
10.5
11
但随后从
直到再次增加到
12
这可能与字体大小有关,与窗口大小有关,因为您在终端中使用的是单型字体,所以它不允许浮动。
然而,该脚本提供了在这种情况下存在的大小。
剧本
如何使用
terminalfont.py
通过以下命令测试运行脚本:
增加字体大小,以及
减小字体大小
解释
不幸的是,没有可
gsettings
用于设置终端字体大小的键。我们需要dconf
直接使用来读取和编辑设置。我们可以先通过以下命令获取配置文件列表:
一旦我们有了配置文件列表,脚本就会首先禁用默认字体(每个配置文件):
b1dcc9dd-5262-4d8d-a863-c897e6d979b9
个人资料的 ID在哪里随后我们使用以下命令读取当前字体和大小:
...我们解析字体大小,添加或减去
0.5
,并通过以下方式设置新大小:笔记
如前所述,如果这对您来说足够了,则只能由您进行测试。但是,如果没有,恐怕我们无法修复它,因为字体大小必须与单字体的终端窗口成一定比例。