Discussion:
URXVT background color
(too old to reply)
arnaud gaboury via arch-general
2017-03-18 10:51:16 UTC
Permalink
Raw Message
I run many urxvt windows on my screen. Some are for the host system and
some are for my container (managed by systemd-nspawn).
I am looking for a way to change color background according to hostname in
order to quickly see which terminal I am on.
My idea was to test $HOST variable in my ~/.xinitrc and give a specific
.Xressource accordingly, but it doesn't work as .xinitrc is obviously not
invoked when I fire a new terminal window.

How can I manage what I am looking for (if I can)?
Thank you for hints.
Maarten de Vries via arch-general
2017-03-18 11:47:27 UTC
Permalink
Raw Message
On 18 March 2017 at 11:51, arnaud gaboury via arch-general <
Post by arnaud gaboury via arch-general
I run many urxvt windows on my screen. Some are for the host system and
some are for my container (managed by systemd-nspawn).
I am looking for a way to change color background according to hostname in
order to quickly see which terminal I am on.
My idea was to test $HOST variable in my ~/.xinitrc and give a specific
.Xressource accordingly, but it doesn't work as .xinitrc is obviously not
invoked when I fire a new terminal window.
How can I manage what I am looking for (if I can)?
Thank you for hints.
​You could make a wrapper script that calls `exec urxvt -bg ....` with a
color​

​based on the hostname.​ I'd recommend a wrapper script and not an alias
since the wrapper script will work everywhere, not just in your shell. Just
put the script somewhere that is accessible in the host system and the
container and set $PATH accordingly for your user.

--
​ Maarten​
arnaud gaboury via arch-general
2017-03-19 16:00:22 UTC
Permalink
Raw Message
Post by Maarten de Vries via arch-general
On 18 March 2017 at 11:51, arnaud gaboury via arch-general <
I run many urxvt windows on my screen. Some are for the host system and
some are for my container (managed by systemd-nspawn).
I am looking for a way to change color background according to hostname in
order to quickly see which terminal I am on.
My idea was to test $HOST variable in my ~/.xinitrc and give a specific
.Xressource accordingly, but it doesn't work as .xinitrc is obviously not
invoked when I fire a new terminal window.
How can I manage what I am looking for (if I can)?
Thank you for hints.
​You could make a wrapper script that calls `exec urxvt -bg ....` with a
color​
​based on the hostname.​ I'd recommend a wrapper script and not an alias
since the wrapper script will work everywhere, not just in your shell. Just
put the script somewhere that is accessible in the host system and the
container and set $PATH accordingly for your user.
Well, I tried this way, but without success. Here is the wrapper:
------------------------------------------
#!/bin/sh

if [[ "$HOST" == "hortensia" ]] ; then
exec urxvt -bg "#161695"
else
exec urxvt -bg "#161616"
fi
----------------------------------------------

I placed this scrpt, calld myUrxvt, in ~/bin (it is in my path).

As I use i3, i modify this line to start my terminal:
--------------------
bindsym $mod+Return exec --no-startup-id myUrxvt
--------------------

Starting a new terminal in host, hortensia, works, but not for the
container. After a close look, in fact terminal in container is xterm and
start by console-getty.service in the container.
So the solution is something less obvious.
I tried to play with the condition $TERM == xterm , but this does not work
too.
Post by Maarten de Vries via arch-general
--
​ Maarten​
Christian Rebischke
2017-03-18 15:38:29 UTC
Permalink
Raw Message
Post by arnaud gaboury via arch-general
I run many urxvt windows on my screen. Some are for the host system and
some are for my container (managed by systemd-nspawn).
I am looking for a way to change color background according to hostname in
order to quickly see which terminal I am on.
My idea was to test $HOST variable in my ~/.xinitrc and give a specific
.Xressource accordingly, but it doesn't work as .xinitrc is obviously not
invoked when I fire a new terminal window.
Hi,
I think you don't want to use the terminal background for this. The
better solution would be a custom prompt for your containers (I use
powerlevel9k with zsh for this [1]).

The problem here is that if you want to do this over the terminal
background you would need custom wrappers that will open a new terminal
for you + your command to spawn into the container. I can imagine that
this workflow will annoy in future.

just my two cents,

chris


[1] https://paste.archlinux.de/xRYkm/ thats my current workflow. This
prompt detects virtualization and SSH sessions.
arnaud gaboury via arch-general
2017-03-18 16:45:48 UTC
Permalink
Raw Message
On Sat, Mar 18, 2017 at 4:38 PM Christian Rebischke <
Post by Christian Rebischke
Post by arnaud gaboury via arch-general
I run many urxvt windows on my screen. Some are for the host system and
some are for my container (managed by systemd-nspawn).
I am looking for a way to change color background according to hostname
in
Post by arnaud gaboury via arch-general
order to quickly see which terminal I am on.
My idea was to test $HOST variable in my ~/.xinitrc and give a specific
.Xressource accordingly, but it doesn't work as .xinitrc is obviously not
invoked when I fire a new terminal window.
Hi,
I think you don't want to use the terminal background for this. The
better solution would be a custom prompt for your containers (I use
powerlevel9k with zsh for this [1]).
I already have different prompts in my .zshinit, but it is not enough to
quickly distinguish which host term I am on.
The urxvt wrapper is a good idea.
Post by Christian Rebischke
The problem here is that if you want to do this over the terminal
background you would need custom wrappers that will open a new terminal
for you + your command to spawn into the container. I can imagine that
this workflow will annoy in future.
just my two cents,
chris
[1] https://paste.archlinux.de/xRYkm/ thats my current workflow. This
prompt detects virtualization and SSH sessions.
Loading...