You are not logged in.

#1 2013-08-17 12:22:21

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

setcolors - Change your Linux VT color palette (at boot time too!)

Hey guys,

I've created a small utility that will change the Linux VT101 virtual console color palette on the fly.

You can run the utility from your VT and pass it a colorscheme file and it will update the color palette. This has an advantage over the method described here that when you issue the "reset" command, the colors wont default back to the Linux VT defaults.

The colorscheme file that the utility reads should just contain 15 hexadecimal color values separated by new lines. the first line being color 0 and the last being 15. You can also prepend the hexadecimal values with "x#" where x is a number between 0 and 15, this way you can order the colors differently (like if you want to put the color pairs next to each other).

Bonus package!

I've also created a mkinitcpio hook that will set your Linux VT colors during early userspace. This way you can have your sexy color scheme from the moment you boot Arch!

For this package all you have to do is definie your colors in the /etc/vconsole.conf file using variables COLOR_x=hexcode where x is a number between 0 and 15.

I will upload the PKGBUILD files to the AUR once I figure out why the AUR is complaining when I upload them...

Now available in the AUR!

All feedback is very much appreciated! These are my first packages I've put on the AUR.

Last edited by EvanPurkhiser (2013-08-19 01:56:37)

Offline

#2 2013-08-18 00:23:38

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Maybe  I missed something but I pulled from your git and built both the hook and setcolors-git but after i build with "mkinitcpio -p linux-ck" All goes smooth without warning yet with a copy of the solarized example in the config as described I see no changes at boot. heres my  /etc/vconsole.conf

COLOR_0=002b36
COLOR_1=dc322f
COLOR_2=859900
COLOR_3=b58900
COLOR_4=268bd2
COLOR_5=d33682
COLOR_6=2aa198
COLOR_7=eee8d5
COLOR_8=002b36
COLOR_9=cb4b16
COLOR_10=586e75
COLOR_11=657b83
COLOR_12=839496
COLOR_13=6c71c4
COLOR_14=93a1a1
COLOR_15=fdf6e3
FONT=ter-112n

and my /etc/mkinitcpio.conf

# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES="piix ide_disk reiserfs"
MODULES="i915"

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=""

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=""

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No raid, lvm2, or encrypted root is needed.
#    HOOKS="base"
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS="base udev autodetect block filesystems"
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS="base udev block filesystems"
#
##   This setup assembles a pata mdadm array with an encrypted root FS.
##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
#    HOOKS="base udev block mdadm encrypt filesystems"
#
##   This setup loads an lvm2 volume group on a usb device.
#    HOOKS="base udev block lvm2 filesystems"
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
HOOKS="consolefont colors base udev autodetect modconf block resume filesystems keyboard fsck shutdown"

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
COMPRESSION="lzop"
#COMPRESSION="cat"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=""

I've tried prepending the hex values with "#", "\x" and as above with no results. I also tried quoting them as well. I checked though journalctl and dmesg for any errors and couldn't find anything related to it. Any ideas? I'd love being able to set my console colors early at boot.


"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#3 2013-08-18 00:38:15

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Your configuration does look right.

Can you try running `setcolors example-colors/(one of the example files)` in your VT and make sure it sets the terminal colors?

Offline

#4 2013-08-18 00:43:30

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Been trying that just a few minutes ago and nothing. It just resets the console.
If there's any other info you may need just let me know. I use zsh both in and out of root. and have console font set early to terminus though the i915 driver. Could those have any impact on it?
Also when done with the example config it just hangs without being able to ctrl-c/d to exit.

Last edited by Thme (2013-08-18 00:49:52)


"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#5 2013-08-18 00:52:58

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

I'm also setting terminus at early userspace. I'm not using the i915 driver, though I can test it (I don't think that's the problem though). Pretty sure zsh wouldn't be the problem either since the color palette changes at the kernel level.

I did notice you were using linux-ck which could be the problem.

I'm going out to eat right now but I'll give a few things a try later tonight and hopeful figure out what's up.

Also when done with the example config it just hangs without being able to ctrl-c/d to exit.

So when you execute `setcolors [some-example-config]` it will just clear the screen and then hang? no prompt?

Last edited by EvanPurkhiser (2013-08-18 00:54:50)

Offline

#6 2013-08-18 01:38:32

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

EvanPurkhiser wrote:

I did notice you were using linux-ck which could be the problem.

I'm going out to eat right now but I'll give a few things a try later tonight and hopeful figure out what's up.

Also when done with the example config it just hangs without being able to ctrl-c/d to exit.

So when you execute `setcolors [some-example-config]` it will just clear the screen and then hang? no prompt?

Yes no prompt. and also I'll try stock kernel as it's in my  grub.cfg


"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#7 2013-08-18 04:03:11

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

I just tried it with linux-ck and zsh as my shell. Still works fine.

Could you try running it like this "strace -o debug.log setcolors [example-config-file]" and post the output of debug.log.

Thanks!

Offline

#8 2013-08-18 15:26:23

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

EvanPurkhiser wrote:

I just tried it with linux-ck and zsh as my shell. Still works fine.

Could you try running it like this "strace -o debug.log setcolors [example-config-file]" and post the output of debug.log.

Thanks!

Nothing. This time it just resets the console(with prompt available). No output.

I also ran everything mentioned earlier on a vanilla kernel and got same results.

Last edited by Thme (2013-08-18 15:28:13)


"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#9 2013-08-18 15:31:11

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Was the debug.log file completely empty?

Offline

#10 2013-08-18 15:46:56

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Oops. First time debugging a c program. I was expecting a print out to console. LOL, Should've known "-o" is used most of the time for output... Anyhow... here:

execve("/usr/bin/setcolors", ["setcolors", "/home/maat/SRC/linux-vt-setcolor"...], [/* 30 vars */]) = 0
brk(0)                                  = 0x1616000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=214897, ...}) = 0
mmap(NULL, 214897, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f31da22c000
close(3)                                = 0
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \33\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2035252, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31da22b000
mmap(NULL, 3852848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f31d9c93000
mprotect(0x7f31d9e36000, 2097152, PROT_NONE) = 0
mmap(0x7f31da036000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a3000) = 0x7f31da036000
mmap(0x7f31da03c000, 14896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f31da03c000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31da22a000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31da229000
arch_prctl(ARCH_SET_FS, 0x7f31da22a700) = 0
mprotect(0x7f31da036000, 16384, PROT_READ) = 0
mprotect(0x7f31da261000, 4096, PROT_READ) = 0
munmap(0x7f31da22c000, 214897)          = 0
brk(0)                                  = 0x1616000
brk(0x1637000)                          = 0x1637000
open("/home/maat/SRC/linux-vt-setcolors-master/example-colors/tomorrow-jellybean", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=157, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31da260000
read(3, "0#1D1F21\n8#373B41\n\n1#A54242\n9#CC"..., 4096) = 157
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f31da260000, 4096)            = 0
open("/proc/self/fd/0", O_RDWR|O_NOCTTY) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7fff92e0a857)     = 0
ioctl(3, PIO_CMAP, 0x7fff92e0a8b0)      = 0
write(3, "\33[2J\33[1;1H", 10)          = 10
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#11 2013-08-19 01:27:41

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Well this is rather embarrassing! I seem to have made a change to my code but failed to test it and never upgraded my own package!

I've fixed the issue now, re-install the package and all will be good smile

Sorry about that, I feel really dumb now!

Last edited by EvanPurkhiser (2013-08-19 01:30:32)

Offline

#12 2013-08-19 13:30:29

Thme
Member
From: Raleigh NC
Registered: 2012-01-22
Posts: 105

Re: setcolors - Change your Linux VT color palette (at boot time too!)

EvanPurkhiser wrote:

Well this is rather embarrassing! I seem to have made a change to my code but failed to test it and never upgraded my own package!

I've fixed the issue now, re-install the package and all will be good smile

Sorry about that, I feel really dumb now!

It's alright I'll let you know when I test it again later.
EDIT: It works excellently. fidling with it and got a Black/Red scheme kinda so far.

Last edited by Thme (2013-08-19 16:10:32)


"Hidden are the ways for those who pass by, for light is perished and darkness comes into being." Nephthys:
Ancient Egyptian Coffin Texts

Offline

#13 2013-08-29 16:20:39

askurihin
Member
Registered: 2012-10-03
Posts: 5

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Thanks for this, really awesome.

Offline

#14 2013-10-16 10:40:21

emorkay
Member
From: India
Registered: 2012-06-06
Posts: 43

Re: setcolors - Change your Linux VT color palette (at boot time too!)

This is very nice...working perfectly...thank you!

Offline

#15 2013-12-29 22:50:13

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

thanks for this wonderful addition to my setup!

it works nicely.
i especially like the early-boot-hook.

a few points:
i had to put the colors manually into /etc/vconsole.conf.
they don't get applied until i run "sudo mkinitcpio -p linux".
after changing the colors in /etc/vconsole.conf, i had to run "sudo mkinitcpio -p linux-lts" again for the changes to take effect.
otherwise it would stay with the previous scheme.

is it supposed to be like that, or am i missing something?

Offline

#16 2013-12-29 22:55:22

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Yes, all of your points are intentional.

Because the colors are set during early boot (before root is mounted) we can't simply read from /etc/vconsole.conf. The color configuration itself is written into the initramfs, so when you change colors you will have to rebuild the initramfs like you described.

Offline

#17 2013-12-29 23:06:55

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

i see.
thanks again.

Last edited by ondoho (2015-10-31 20:56:57)

Offline

#18 2013-12-31 08:43:12

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: setcolors - Change your Linux VT color palette (at boot time too!)

nice, I'm liking this a lot - thanks for posting.

Offline

#19 2014-11-24 01:09:43

Gulver
Member
Registered: 2013-05-24
Posts: 208

Re: setcolors - Change your Linux VT color palette (at boot time too!)

There doesn't seem to be a way to give you some credit on any medium so.. Thank you.

Offline

#20 2015-07-28 06:17:53

dancer69
Banned
Registered: 2011-08-05
Posts: 66

Re: setcolors - Change your Linux VT color palette (at boot time too!)

ondoho wrote:

thanks for this wonderful addition to my setup!

it works nicely.
i especially like the early-boot-hook.

a few points:
i had to put the colors manually into /etc/vconsole.conf.
they don't get applied until i run "sudo mkinitcpio -p linux".
after changing the colors in /etc/vconsole.conf, i had to run "sudo mkinitcpio -p linux-lts" again for the changes to take effect.
otherwise it would stay with the previous scheme.

is it supposed to be like that, or am i missing something?

I followed these suggestions, colors don't change.
Here is vconsole.conf:

KEYMAP=us
KEYMAP_TOGGLE=gr
FONT=Greek-Terminus22x11
FONT_MAP=8859-7
#set virtual console colors
COLOR_0=002b36
COLOR_1=dc322f
COLOR_2=859900
COLOR_3=b58900
COLOR_4=268bd2
COLOR_5=d33682
COLOR_6=2aa198
COLOR_7=eee8d5
COLOR_8=002b36
COLOR_9=cb4b16
COLOR_1=586e75
COLOR_11=657b83
COLOR_12=839496
COLOR_13=6c71c4
COLOR_14=93a1a1
COLOR_15=fdf6e3

the mkinitcpio.conf:

# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES="piix ide_disk reiserfs"
MODULES=""

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=""

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=""

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No raid, lvm2, or encrypted root is needed.
#    HOOKS="base"
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS="base udev autodetect block filesystems"
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS="base udev block filesystems"
#
##   This setup assembles a pata mdadm array with an encrypted root FS.
##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
#    HOOKS="base udev block mdadm encrypt filesystems"
#
##   This setup loads an lvm2 volume group on a usb device.
#    HOOKS="base udev block lvm2 filesystems"
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
HOOKS="consolefont colors base udev resume autodetect modconf block filesystems keyboard fsck"

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=""

The output of  mkinitcpio -p linux:

Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 4.1.2-2-ARCH
  -> Running build hook: [consolefont]
  -> Running build hook: [colors]
==> WARNING: colors: Not all colors specified in configuration
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [resume]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 4.1.2-2-ARCH
  -> Running build hook: [consolefont]
  -> Running build hook: [colors]
==> WARNING: colors: Not all colors specified in configuration
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [resume]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: aic94xx
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img
==> Image generation successful

And I run "grub-mkconfig -o /boot/grub/grub.cfg" after the generation. Do I miss something, or is something wrong?
I can change the colors by manuall run the "setcolors" command.

Offline

#21 2015-07-29 09:15:59

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: setcolors - Change your Linux VT color palette (at boot time too!)

^ maybe you have to use a different format for color definitions in /etc/vconsole.conf.
it's been a while since i used this, but i remember having a problem there, and a little trial & error to get it working.

Offline

#22 2015-07-29 12:54:30

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Mine *is* working... all I did was run the sed command from the github page to convert my setcolors conf file to vconsole.conf and run the mkinitcpio

sed 's/^\(.*\)#\(.\{6\}\).*$/COLOR_\1=\2/'

All I have are the colour definitions though, not font or keymap so maybe it's worth trying without that.  I'm also not very imaginative so I'm using one of the example colour schemes provided

Offline

#23 2015-07-29 15:40:47

dancer69
Banned
Registered: 2011-08-05
Posts: 66

Re: setcolors - Change your Linux VT color palette (at boot time too!)

I don't understand what this command does and where to run it. I' don't see any setcolors.conf file in github, only the example files. Can you post your working vconsole.conf? This would be much more easier.

EDIT:
I just went to github page and read the instructions. I have the colors in console.conf as explained there, so no need to run the sed command. But it doesn't work.
I get a
==> WARNING: colors: Not all colors specified in configuration
when run mkinitcpio, but I have all colors(0-15) so I don't know what means.

Last edited by dancer69 (2015-07-29 16:07:51)

Offline

#24 2015-07-29 17:59:49

ksksks
Member
Registered: 2014-01-17
Posts: 1

Re: setcolors - Change your Linux VT color palette (at boot time too!)

dancer69 wrote:

==> WARNING: colors: Not all colors specified in configuration
when run mkinitcpio, but I have all colors(0-15) so I don't know what means.

COLOR_9=cb4b16
COLOR_1=586e75
COLOR_11=657b83

___^______________ks____________________^___

Offline

#25 2015-07-29 18:48:58

dancer69
Banned
Registered: 2011-08-05
Posts: 66

Re: setcolors - Change your Linux VT color palette (at boot time too!)

Thank you very much! That was the problem.

Offline

Board footer

Powered by FluxBB