如何在终端中配置更改字体大小的步骤?我现在使用10pt,使用键盘快捷键时的下一步太大了。如何配置步长?
下面的脚本将一次以0.5的步长设置所有配置文件的字体大小。您将不得不查看这是否足以满足您的需要;终端不会对所有步骤都做出反应。
就我而言,
10 --> 10.5 --> 11
10.5
11
但是从
11 --> 11.5
都没有效果,直到增加一次,以
12
这可能与字体大小有关,与窗口大小有关,由于您在终端中使用的是单色字体,因此它不允许浮动。
但是,脚本提供了这种情况下存在的大小。
#!/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)
terminalfont.py
通过以下命令测试脚本:
python3 /path/to/terminalfont.py up
增加字体大小,以及
python3 /path/to/terminalfont.py down
减小字体大小
不幸的是,没有可用的按键gsettings
来设置终端的字体大小。我们需要dconf
直接使用以读取和编辑设置。
我们可以先通过以下命令获取配置文件列表:
dconf read /org/gnome/terminal/legacy/profiles:/list
获得配置文件列表后,该脚本将首先使用默认字体(每个配置文件)禁用:
dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/use-system-font false
b1dcc9dd-5262-4d8d-a863-c897e6d979b9
个人资料的ID在哪里
随后,我们使用命令读取当前字体和大小:
dconf read /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/font
...我们解析字体大小,添加或减去0.5
,然后通过以下方式设置新大小:
dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/font 'Monospace 14.0'
如前所述,如果这足以满足您的要求,则只能由您进行测试。但是,如果没有,恐怕我们将无法修复它,因为字体大小必须与单色字体的终端窗口成一定比例。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句