LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-09-2011, 02:37 PM   #1
trough
LQ Newbie
 
Registered: May 2011
Distribution: Slackware 13.37
Posts: 3

Rep: Reputation: 0
How do I make the virtual consoles behave like monochrome terminals?


By "virtual consoles" I mean the terminals accessible with [Ctrl]+[Alt]+[F1-F6]. I just installed Slackware 13.37 with kernel 2.6.37.6-smp. By default the console behaves like a color terminal. The normal text is grey, and many programs (ls, man, emacs, vi, etc.) use other colors as well. But I would really like it to behave like a monochrome terminal: displaying text as normal, underlined, highlighted, or bold, with no colors other than the normal and bold colors. Preferably in amber or green. I'm not using X windows and I plan on spending most of my time within these virtual consoles, so I'm willing to put some work into getting them looking right.

Code:
setterm -foreground yellow -background black -store
If I use setterm to make the text yellow, the normal text looks like a decent amber, but the bold looks like bright yellow. Is there any way I can redefine that bright yellow as a different set of r,g,b values?

If I use setterm to make the text green it looks good enough. But still, using either of these commands does not permanently change the color. It only changes the color of the console from which it was executed. And even then, programs still act like it's a color terminal and print colors. When I reboot the console forgets its previous color settings and is back to the default grey. I want all the consoles to be monochrome all the time, even while booting, if possible.

This website said the problem could be solved by modifying the kernel source in the file "/usr/src/linux/drivers/char/console.c" Unfortunately, I cannot find the file to which they are referring.

I was able to stop ls from displaying in color by disabling the dircolors script and adding some aliases to /etc/profile. But I still don't how to make all the other programs run in monochrome mode.


Thank you for your time and consideration. Any advice is greatly appreciated!

Regards,
trough
 
Old 05-09-2011, 03:32 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
IIRC, these console shells are considered login shells, so they don't read bashrc by default. They do read /etc/profile and bash_profile however (see the INVOCATION section of the bash man page).

So you can use one of these files to add your startup commands, or to import your bashrc or another file from it.

Code:
#import contents of /etc/bashrc if it exists
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
However, if you do this, you may find that some commands don't do so well outside of an xterm (Having an XTITLE section in your PS1 prompt, for example). So you can add a test to specify different behaviors depending on the kind of console that's running.
Code:
if [[ "$TERM" =~ xterm ]]; then
        commands
else
        setterm -foreground yellow -background black -store
fi
 
1 members found this post helpful.
Old 05-09-2011, 05:29 PM   #3
trough
LQ Newbie
 
Registered: May 2011
Distribution: Slackware 13.37
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you. That does make ~/.bashrc work. Now when I login, the colors are changed. But is there any way this could be done when the computer boots?

How can I prevent the console from displaying other colors? Can I redefine all the other colors somehow?
 
Old 05-11-2011, 09:05 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I really don't know all that much personally about how terminals/consoles are customized. It's still all a confusing morass of crypto-jargon to me .

But I just ran across this: Bashish. Perhaps it can help you do what you want?
 
Old 05-11-2011, 11:34 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,377

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
As David the H. has pointed out, the key script is /etc/profile.
When Slackware boots, /etc/inittab is consulted for the standard console login getties.
The agetty entries default to running /bin/login which in turn runs /bin/bash by default as specified in /etc/passwd.
In /etc/profile there is:
Code:
# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi
So the TERM environment variable is set to linux by default. You can change this to another value e.g. linux-m which will set to a mono terminal (man terminfo for details).
By doing this I can then have a mono terminal that obeys the 'setterm -foreground yellow' style of command.

To complicate matters, also in /etc/profile there is:
Code:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
You have already found that you can disable colours by 'chmod -x /etc/profile.d/coreutils-dircolors.sh'.
This is needed to stop programs such as ls causing problems for your mono look.

You will probably have to look at decolourising other outputs to make this stick. 'man' as it stands will upset things.
 
Old 05-16-2011, 06:34 AM   #6
trough
LQ Newbie
 
Registered: May 2011
Distribution: Slackware 13.37
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you, this has been very useful information. I was also able to get vi and man to run in monochrome, unfortunately I can't get emacs do to it though. But this is good enough for me. Thanks for the help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Have to log out of a virtual terminal twice in order to exit virtual terminals narnie Linux - Newbie 5 02-24-2010 12:49 AM
Why does linux start 6 virtual consoles/terminals? pantherlehr Linux - General 3 07-17-2008 12:25 AM
How I Make More Virtual Terminal Other Than 6 Pre Available Terminals Tauseef Anwar Red Hat 2 05-25-2008 01:37 AM
there are many consoles/terminals in KDE. whats the difference? 286 Linux - Newbie 3 12-20-2003 10:52 AM
Consoles and Terminals jarget Linux - Newbie 2 09-05-2003 11:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration