Mini Project: Change the color of the terminal based on the time of day
background-color, bash, colors, gnome-terminal, solaris
Solution
If I were doing this, I'd start with PROMPT_COMMAND. Bash will run that script just before displaying a prompt.
You have a couple of choices. You could have a script itself inside PROMPT_COMMAND:
PROMPT_COMMAND='if [ is_morning ]; then echo "MORNING_COLORS'; else echo "EVENING_COLORS"; fi
Or you could have PROMPT_COMMAND run an external command (which could also be a bash script or you could use a different language if you wanted) to do all the work there:
PROMPT_COMMAND=/path/to/setcolor_timeofday
The only hole I see in this is that if you have a program running when the time changes over (for example, using `tail -f` to watch a file), the background won't change until you return to the bash prompt.
Problem
Good Evening, I am pretty new to Unix so maybe this mini project is too ambitious. Hoping someone could point in in the right direction. Working in a cubicle and I can't see how light it is outside. In general I use a yellow terminal in the morning (sunny) and a black/green past 3:00 (night). What I would like to do (partly just to practice my bash). Is to write a script that will at 3:00 change the color of all of my terminals. If that works maybe I will make them change every hour or something like that. Would that be safe? Is this possible? Here are some of my specs: Solaris 10 Bash shell Gnome I am looking at this right now: Change Gnome terminal theme programmatically