I regularly work on different hosts using ssh, and I sometimes get confused about which computer I'm running commands on. I've occasionally come close to issuing halt(8) commands to the wrong host.

Ideally, I'd like to colour-code the top ribbon of the terminal window based on which host I'm currently logged into. I use Openbox and gnome-terminal, but would consider switching to any terminal emulator that makes this kind of thing easy or at least possible.

Does anyone know of a way to do this? I'm not scared of doing some work myself if you can point me at the way to programmatically change window colours.


by "window colors", do you mean the color of the window boarder? if so tell your window manager to set the color of the window boarder based on the title of the window as most have a pattern of user@host: /path. it would be easy for it to check if this is a Terminal by its window class and then parse the title when it changes and update the color used. but i don't know the flows involved so i don't know how much work.

but this is possible.

(i don't know if openbox could do this but after thinking about it this is the easier way to do it)


after looking at the source to openbox, i think patching the framerender_frame function in openbox/framerender.c so that if the window is a Terminal depending the host in the title, a different theme is used instead of the global ob_rr_theme, one which has the colors you want for that window in it.

[in the context of framerender_frame, the window title might be self->client->title]

doing this would require changing framerender_frame so that it refers to the global ob_rr_theme via a local theme and would require writing code to load the host:theme map and the additional themes

in pseudo code (i.e. this will not run):

RrTheme* theme = ob_rr_theme;
if "gnome-terminal" equals self->client->class: # for example only
    host = parse_title(self->client->title)
    theme = lookup host in by_host if not found use theme
# and then in the rest of framerender_frame use theme instead of ob_rr_theme

where by_host maps host strings to RrTheme themes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.