LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 07-28-2013, 11:12 PM   #1
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Rep: Reputation: 5
color font on startup


so, i just installed salix in a vm to test it out, and i looked that it has these colors on the messages on the boot, is there a way to do this on slackware? or it just not possible? thanks a lot.
 
Old 07-28-2013, 11:22 PM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,578

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
Yes, it's possible. The default scripts just don't do it, but there's support for it in /etc/rc.d/init.d/functions.
 
1 members found this post helpful.
Old 07-29-2013, 01:53 AM   #3
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Original Poster
Rep: Reputation: 5
so its something that needs to change in every single script?

not really sure what the functions file do, but in these lines
Quote:
BOOTUP=color
RES_COL=60
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \\033[0;39m"
LOGLEVEL=1
seems like the colors for the text are already there, so... im lost, gonna dive into it later. seeya.

Last edited by cisneros; 07-29-2013 at 01:56 AM.
 
Old 07-30-2013, 01:28 AM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,578

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
Well, I partially lied up there.

/etc/rc.d/rc.cups uses the stuff in functions to give you the green OK and red FAIL colors.
 
Old 07-30-2013, 01:15 PM   #5
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
You can blame me. I used to have colorized rc.d scripts at my web site before I ended the site.

Several years ago the Zenwalk developers adopted my colorized scripts and modified the color scheme to their liking. Salix is maintained by folks who originally helped maintain Zenwalk. Some of them left the Zenwalk project to start Salix. The Salix folks continued the colorized scripts with their distro.

That said, as Salix is advertised as compatible with the parent Slackware, you should be able to use all of the Salix scripts in Slackware or at least most of them. If you are uncertain about all changes, use a graphical diff front-end, such as kompare, to review the differences between the Salix and Slackware scripts.

Be forewarned that some of the doinstall scripts in Slackware packages automatically overwrite existing rc.d scripts. The rc.udev script is an example. Some sort of backup strategy is needed to preserve colorization efforts. I maintain a *.bak file that is easily restored.

Remember that rc.d scripts provided in third party packages, such as from slackbuilds.org, do not contain colorization. I have to edit those scripts and maintain backups too.

The colorized [ok] and [fail] outputs used in the rc.cups script is mostly a Red Hat convention. Most distros derived from Red Hat use the same convention.

As colorization is not supported upstream, there is some maintenace involved to keep the scripts colorized while not changing the function of the scripts. Every time I update to a new Slackware release I spend about an hour reviewing all scripts and adding colorization to new scripts.

In all, not a lot of work to have colorized scripts. I still use all of my colorized scripts. Helps with readability when the boot and shutdown process scrolls. Without a splash image during the boot and shutdown events, the colorized output does provide a more "professional" look too. At least for desktop systems. Like the honey badger, server folks probably don't give a sh-t.
 
2 members found this post helpful.
Old 07-30-2013, 01:33 PM   #6
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Original Poster
Rep: Reputation: 5
so, it is something that needs to be adjusted in every single script?, do you have any guide or tips to start with it? thanks a lot. Im gonna check salix scripts, wanna see diffs between the files.
 
Old 07-30-2013, 01:46 PM   #7
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Remember there is no upstream support for colorization. Therefore nothing exists. Every script that is colorized must be edited. That initial effort takes a while to complete, but the Salix scripts already have most of that done.

The /etc/shell-colors file contains the escape sequences for the color scheme used. The modified rc.d scripts use the echo -e command. For example, from rc.M:

echo -e "${BOLDYELLOW}Going to multi user mode.${COLOR_RESET}"

Each modified rc.d script (or any other colorized script, such as user scripts stored in /usr/local/(s)bin), need to source /etc/shell-colors at the top of the script.

Inserting the escape sequences in /etc/shell-colors allows for easier readability in the rc.d scripts as to which color is being used because human usable color names are used.
 
Old 07-31-2013, 10:34 PM   #8
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,578

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
Is /etc/shell-colors a Salix thing?
 
Old 07-31-2013, 10:51 PM   #9
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Quote:
Is /etc/shell-colors a Salix thing?
That was my invention, although originally I had a different file name. The Zenwalk folks changed the name to shell-colors and I liked that name too. Perhaps the Salix devs who once worked on Zenwalk changed the name.

Last edited by Woodsman; 07-31-2013 at 10:53 PM.
 
Old 07-31-2013, 11:47 PM   #10
Kallaste
Member
 
Registered: Nov 2011
Distribution: Slackware
Posts: 344

Rep: Reputation: 84
That's pretty neat, actually. I might give it a go as well. Nice work, Woodsman!
 
Old 07-31-2013, 11:50 PM   #11
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Original Poster
Rep: Reputation: 5
it would be great that slackware 14.1 have colorization on the boot. just sayin.
 
1 members found this post helpful.
Old 08-01-2013, 12:29 AM   #12
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Quote:
it would be great that slackware 14.1 have colorization on the boot. just sayin.
Would be great, yes, but now convince Pat.

Anybody could propose a collection of colorized scripts, but the shell-colors file has to support a simple way to disable all colorization. I don't know how the Salix folks handle this as I have not looked at their file, but on my system I use a script variable of COLORED_SCRIPTS=yes and a simple if/then test in the script. When disabled all colors are set to ${ESC}00m. Like this:

Code:
#!/bin/sh
# /etc/shell-colors
#
# This file provides escape code options for adding color to echo and
# printf script commands. Source this file as necessary. Add additional
# colors if desired.

# Sourcing this script allows writing scripts with human readable
# color references rather than embedding the actual raw escape codes,
# which few people remember or know. A human readable variable enables
# a person to read a script and know the intended color.

# Write a script to include the human readable color code variables.
# Example:
# echo -e "${BOLDRED}This is a warning message!${COLOR_RESET}"
# echo -e "${BOLDWHITE}Your network interface is: ${BOLDGREEN}eth0${COLOR_RESET}"

# When this script is sourced and run, the $COLORED_SCRIPT variable will
# determine whether the end-user sees color. For example, people running a
# server might care less about colored scripts, but people running desktop
# boxes likely will want otherwise.

# Modify this variable to produce the desired effect:
COLORED_SCRIPTS=yes

ESC="\033["

# This color scheme looks good with a black background.
# Feel free to modify for other background color schemes.
if [ "$COLORED_SCRIPTS" = "yes" ]; then
  # user wants colorized scripts :-)
  BOLDRED="${ESC}01;31m"
  BOLDGREEN="${ESC}01;32m"
  BOLDYELLOW="${ESC}01;33m"
  BOLDBLUE="${ESC}01;34m"
  BOLDMAGENTA="${ESC}01;35m"
  BOLDCYAN="${ESC}01;36m"
  BOLDWHITE="${ESC}01;37m"
  COLOR_RESET="${ESC}00m"
else
  # user does not want colorized scripts :-(
  BOLDRED="${ESC}00m"
  BOLDGREEN="${ESC}00m"
  BOLDYELLOW="${ESC}00m"
  BOLDBLUE="${ESC}00m"
  BOLDMAGENTA="${ESC}00m"
  BOLDCYAN="${ESC}00m"
  BOLDWHITE="${ESC}00m"
  COLOR_RESET="${ESC}00m"
fi
With this setup, all rc.d scripts have the colorization code in them. If $COLORED_SCRIPTS = no, then the effect is to print no color.

I have no idea whether adding color to scripts slows the boot process. I'm guessing that even if you convinced Pat to add colorization, the default likely would be off.

I use a black terminal backgrounds. The color scheme I use won't work with white backgrounds. So the shell-colors file would have to have alternate color schemes for different backgrounds. As the basic console is black I don't know how I'd handle different color backgrounds. Possibly some testing would reveal a single color scheme that would work with most background colors.

I don't have any related notes in my shell-colors, but in my modified rc.d scripts I use a basic color strategy for consistent stdout. I use red for failure messages, yellow for warnings and runlevel changes, blue for the beginning announcement of each script, green to emphasize data in a message, and white for emphasizing certain stdout messages or to separate stdout messages into sections. For example:

echo -e "${BOLDWHITE}Starting loopback interface ${BOLDGREEN}lo${BOLDWHITE}:${COLOR_RESET}"

Possibly another option in shell-colors would be to add a list of color types. That is, something like BOLDFAILURE, BOLDWARNING, BOLDINTRODUCTION, BOLDMESSAGE, BOLDDATA. Then the rc.d scripts could use that instead of BOLDRED, BOLDYELLOW, BOLDBLUE, BOLDWHITE, and BOLDGREEN.

In summary, alternate color schemes are needed for different background colors and there would need to be a consensus opinion of the overall color strategy as well and neither can conflict with the other. Things can get complicated because of different user desires. If you get that far then you might be able to bend Pat's ear, but if not you could submit the scripts as a slackbuilds.org collection.
 
2 members found this post helpful.
Old 08-01-2013, 04:40 AM   #13
solarfields
Member
 
Registered: Feb 2006
Location: Outer Shpongolia
Distribution: Slackware
Posts: 494

Rep: Reputation: 132Reputation: 132
Quote:
before I ended the site
why, man, why...

you had so many cool things there!
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to change font color and font size in terminal ? wlaw Linux - Newbie 3 05-15-2007 09:57 PM
Font Color at Kernel startup Hioushi Linux - Software 2 08-18-2006 01:29 PM
QT and font color atomas123 Programming 2 12-20-2005 02:20 PM
Terminal font and color berkay Linux - Newbie 10 09-23-2004 03:19 AM
font color Joey.Dale Linux - General 1 06-19-2003 01:52 PM


All times are GMT -5. The time now is 03:57 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration