The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

Any ideas how to change the font size for a urxvt terminal opened on a specific display or workspace?

asked Apr 2 '15

g-eorge gravatar image

I would like to use a different font size in my terminal if it is opened on an external display. Is this possible somehow?

3 answers

Sort by » oldest newest most voted
1

answered Apr 7 '15

g-eorge gravatar image

Here's the solution I went with for my system which has a hidpi display on eDP1. It uses a combination of both previous answers, since I suspect that updating the Xresources would change settings for all displays, instead of just the current one (haven't tested that though).

term_for_display.sh - a script to open a terminal differently on a particular display

#!/bin/bash

hidpi_display="eDP1"
current_display=$(get_display.py)

if [ "$current_display" != "$hidpi_display" ]; then 
  urxvt -fn "xft:Terminus:pixelsize=18,style=Regular"
else
  urxvt
fi

get_display.py - a script to find the name of the current display

#!/usr/bin/env python

import json
from subprocess import check_output

out = check_output(["i3-msg", "-t", "get_workspaces"])
workspaces = json.loads(out.decode("utf-8"))
focused_workspace = filter(lambda x: x["focused"], workspaces)
print(next(focused_workspace)["output"])

.i3/config - run the new script to open a terminal

bindsym Mod1+Return exec --no-startup-id /path/to/term_for_display.sh

Comments

Thanks to previous posters. Sorry I don't have enough points to upvote or accept answers!

g-eorge gravatar imageg-eorge (Apr 7 '15)edit
0

answered Apr 2 '15

i3convert gravatar image

updated Apr 2 '15

Solution sketch (assuming that urxvt is your terminal):

  1. Create two copies of .Xresources with different font sizes.
  2. Write a script that figures out which display you are on. To this end, you can process the output of i3-msg -t get_workspaces.
  3. Write another script that first, based on the output of the previous script, executes xrdb /path/.Xresources-with-specific-font-size (which loads a specific configuration) and then runs urxvt.

I hope you know how to write scripts (it's never too late to learn!). If not, I hope someone else fills out the gaps.

Comments

Great idea, I'll try that out. Thanks!

g-eorge gravatar imageg-eorge (Apr 4 '15)edit
0

answered Apr 3 '15

topernic gravatar image

Launch with options. See 'man urxvt' urxvt -fn "xft:Bitstream Vera Sans Mono:pixelsize=15"

Comments

Nice! I didn't know that there was a command line switch. He probably still needs an additional script to figure out what display he is on.

i3convert gravatar imagei3convert (Apr 4 '15)edit

Thanks for the tip, I'll look into that.

g-eorge gravatar imageg-eorge (Apr 4 '15)edit

Question Tools

Stats

Asked: Apr 2 '15

Seen: 445 times

Last updated: Apr 07