Mini Project: terminal color change depending on the time of day

Good evening,

I am new to Unix, so perhaps this mini-project is too ambitious. Hoping someone can point in the right direction.

Work in the cab, and I do not see the light outside. In general, I use the yellow terminal in the morning (sunny) and black / green, past 3:00 (night).

What I would like to do (partly just practicing my bash). Is to write a script that at 3:00 will change the color of all my terminals. If that works, I can make them change every hour or something. Would that be safe? Is it possible?

Here are some of my specs: Solaris 10 Bash Gnome Shell

I'm looking at it right now: Programmatically change the theme of the Gnome terminal

+7
background-color bash colors solaris gnome-terminal
source share
3 answers

If I did, I would start with PROMPT_COMMAND . Bash will run this script just before the tooltip is displayed.

You have several options. You may have a script inside PROMPT_COMMAND:

PROMPT_COMMAND='if [ is_morning ]; then echo "MORNING_COLORS'; else echo "EVENING_COLORS"; fi 

Or you could run PROMPT_COMMAND an external command (which could also be a Bash script or you could use a different language if you want) to do all the work there:

 PROMPT_COMMAND=/path/to/setcolor_timeofday 

The only hole that I see in this is that if you have a program that works when the time changes (for example, using tail -f to view the file), the background will not change until you return to Bash.

+4
source share

Changing the background color of the foreground and background using PS1 in bash will be the easiest thing that others are talking about here. The R Samuel Klatchko approach with PROMPT_COMMAND is probably the most universal. However, this has its drawbacks. bash can only use "boring" background colors, and its foreground / background colors can be canceled by any application. Modifying the Gnome Terminal theme programmatically, especially in real time, will be much more difficult, but will give much more beautiful results.

+2
source share

Use cron , this is a Unix task scheduler. And install it to run a command that modifies .bashrc, as in the question you linked. The problem is that it will only work for new terminals, if you open them, it will not change them.

0
source share

All Articles