You are not logged in.

#1 2009-06-22 08:05:12

rickynils
Member
Registered: 2006-10-18
Posts: 9

Switching terminal color/font at runtime

Hi,

Does someone know about a way to dynamically switch background/foreground colors and fonts in terminals? I'm running Xmonad with Xterm, and I would really like to switch all my open terminals between white-on-black and black-on-white by the press of a key. Similarly for the font size/face. I don't mind changing from Xterm to another terminal if this functionality can be found anywhere else.

I know that both Xterm and rxvt can be controlled dynamically by executing special commands inside the terminal, but I need a way to do it from the "outside", for all running terminals.

I expect some problems in programs like vim, where this color switching might mess up the current color scheme, but in the worst case I can switch color scheme in vim manually to get around that.


Regards,
  Rickard

Offline

#2 2009-06-22 14:52:19

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 987

Re: Switching terminal color/font at runtime

The only way I'm aware of to do what you're asking is to use gnome-terminal and control its appearance by changing the theme in gnome-settings-manager.  (I think.)  There's probably an equivalent arrangement that does the same thing under KDE.  But I don't imagine that someone who runs Xmonad is interested in having gnome-settings-daemon running all the time and interfering with other stuff...

As far as I know, most of the more popular non-DE-specific terminals (urxvt, xterm, etc) don't support this kind of global theme-switching, which I am inclined to see as a feature; it could really mess up applications running in other terminals (as you mentioned).  But you might somehow write a script to do so (I have no idea how/if this could be implemented).

Offline

#3 2009-06-23 01:33:54

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Switching terminal color/font at runtime

Here is an example that should work for switching fonts in the rxvt-unicode terminal. Not sure about colors though sorry.

echo -e '\e]710;xft:Terminus:style=Regular\007'
vim
echo -e '\e]710;xft:lime:style=Regular\007'

Offline

#4 2009-06-23 03:54:03

harpo
Member
Registered: 2009-05-14
Posts: 21

Re: Switching terminal color/font at runtime

rickynils wrote:

Hi,
Does someone know about a way to dynamically switch background/foreground colors and fonts in terminals? I'm running Xmonad with Xterm, and I would really like to switch all my open terminals between white-on-black and black-on-white by the press of a key. Similarly for the font size/face. I don't mind changing from Xterm to another terminal if this functionality can be found anywhere else.

How about something like this (not tested properly):

pacman -S xtermcontrol

for x in `ls /dev/pts | xargs`
do
  xtermcontrol --bg white > /dev/pts/$x
done

Offline

#5 2009-06-23 11:24:50

rickynils
Member
Registered: 2006-10-18
Posts: 9

Re: Switching terminal color/font at runtime

Trent wrote:

The only way I'm aware of to do what you're asking is to use gnome-terminal and control its appearance by changing the theme in gnome-settings-manager.  (I think.)  There's probably an equivalent arrangement that does the same thing under KDE.  But I don't imagine that someone who runs Xmonad is interested in having gnome-settings-daemon running all the time and interfering with other stuff...

I tested this idea, and it actually worked out pretty good. For various reasons, I am already running gnome-settings-deamon along with Xmonad and it works fine. The only thing I had to do was to run my xmonad starter script with dbus-launch, otherwise the gconftool-2 wouldn't work correctly.

So now I can map keys to commands like:

  gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/font "Terminus 12"

and then all open gnome-terminals are changed accordingly.

Thanks for the tip! I might continue looking for solutions for other terminals though.

Offline

#6 2009-06-23 11:30:44

rickynils
Member
Registered: 2006-10-18
Posts: 9

Re: Switching terminal color/font at runtime

harpo wrote:

How about something like this (not tested properly):

pacman -S xtermcontrol

for x in `ls /dev/pts | xargs`
do
  xtermcontrol --bg white > /dev/pts/$x
done

I'll try that out when I get home. Thanks!

Offline

Board footer

Powered by FluxBB