User Tools

Site Tools


linux:ricing:virtual_terminal_color

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:ricing:virtual_terminal_color [2020/07/17 15:44] chucklinux:ricing:virtual_terminal_color [2025/01/20 12:33] (current) – external edit 127.0.0.1
Line 13: Line 13:
 They //should// work on Ubuntu and other Debian based distributions as well.</WRAP> They //should// work on Ubuntu and other Debian based distributions as well.</WRAP>
 ====Setting Up==== ====Setting Up====
-  * If it's not already installed, install ''%%kbd%%'': +  * If it's not already installed, install ''%%kbd%%'':<code bash> 
-    * ''%%sudo apt install kbd%%''+sudo apt install kbd 
 +</code>
  
-<HTML> +----
-<hr style="border: 0;height: 0;border-top: 1px solid rgba(0, 0, 0, 0.1);border-bottom: 1px solid rgba(255, 255, 255, 0.3);"> +
-</HTML>+
  
 ====Modify initramfs==== ====Modify initramfs====
 Add the **setvtrgb** executable to the **initramfs** so that it's available during boot.  Add the **setvtrgb** executable to the **initramfs** so that it's available during boot. 
  
-  * Create a shell script in the hooks directory: +  * Create a shell script in the hooks directory:<code bash> 
-    * ''%%sudoedit /etc/initramfs-tools/hooks/setvtrgb_hook%%'':<file sh setvtrgb_hook>+sudoedit /etc/initramfs-tools/hooks/setvtrgb_hook 
 +</code> 
 + 
 +  * And add the contents:<file sh setvtrgb_hook>
 #!/bin/sh #!/bin/sh
 PREREQ="" PREREQ=""
Line 43: Line 45:
 copy_exec /usr/bin/setvtrgb /bin copy_exec /usr/bin/setvtrgb /bin
 </file> </file>
-  * Set the script to be executable: +  * Set the script to be executable:<code bash> 
-    * ''%%sudo chmod +x /etc/initramfs-tools/hooks/setvtrgb_hook%%''+sudo chmod +x /etc/initramfs-tools/hooks/setvtrgb_hook 
 +</code>
  
-<HTML> +----
-<hr style="border: 0;height: 0;border-top: 1px solid rgba(0, 0, 0, 0.1);border-bottom: 1px solid rgba(255, 255, 255, 0.3);"> +
-</HTML>+
  
 ====Choose a colorscheme==== ====Choose a colorscheme====
Line 58: Line 59:
       * I chose the **init-top** directory because it gets called as early as possible into the boot process.        * I chose the **init-top** directory because it gets called as early as possible into the boot process. 
       * Refer to **man initramfs-tools** BOOT SCRIPTS section and change it to suit your needs.       * Refer to **man initramfs-tools** BOOT SCRIPTS section and change it to suit your needs.
-  * Set the script to be executable: +  * Set the script to be executable:<code bash> 
-    * ''%%sudo chmod +x /etc/initramfs-tools/scripts/init-top/my_colorscheme%%''+sudo chmod +x /etc/initramfs-tools/scripts/init-top/my_colorscheme 
 +</code>
  
  
  
-<HTML> +----
-<hr style="border: 0;height: 0;border-top: 1px solid rgba(0, 0, 0, 0.1);border-bottom: 1px solid rgba(255, 255, 255, 0.3);"> +
-</HTML>+
  
 ====Update initramfs==== ====Update initramfs====
 After completing the above steps, we will generate the new initramfs After completing the above steps, we will generate the new initramfs
-  * Update the initramfs: +  * Update the initramfs:<code bash> 
-    * ''%%sudo update-initramfs -u%%'' +sudo update-initramfs -u 
-  * Verify that **setvtrgb** was added: +</code> 
-    * ''%%lsinitramfs -l /boot/initrd.img-4.19.0-9-amd64 | grep setvtrgb%%''+  * Verify that **setvtrgb** was added:<code bash> 
 +lsinitramfs -l /boot/initrd.img-4.19.0-9-amd64 | grep setvtrgb 
 +</code>
     * //make sure to modify the above command to point to your initrd//     * //make sure to modify the above command to point to your initrd//
   * Reboot   * Reboot
  
  
-<HTML> +----
-<hr style="overflow: visible;padding: 0;border: none;border-top: medium double #b5b5b5;color: #b5b5b5;text-align: center;"> +
-</HTML>+
  
 =====Applying a VT Colorscheme after boot===== =====Applying a VT Colorscheme after boot=====
Line 85: Line 85:
  
   * Copy or create a [[#vt-colorschemes|colorscheme]] somewhere such as ''%%/etc/custom-vt-colors%%''.   * Copy or create a [[#vt-colorschemes|colorscheme]] somewhere such as ''%%/etc/custom-vt-colors%%''.
-  * Create a systemd service: +  * Create a systemd service:<code bash> 
-    * ''%%sudoedit /etc/systemd/system/custom-vt-colors.service%%'':<file sh custom-vt-colors.service> +sudoedit /etc/systemd/system/custom-vt-colors.service 
 +</code> 
 +  * Add the contents:<file sh custom-vt-colors.service> 
 [Unit] [Unit]
 Description=Load custom VT color palette Description=Load custom VT color palette
Line 97: Line 99:
 WantedBy=multi-user.target WantedBy=multi-user.target
 </file> </file>
-  * Start and enable the service: +  * Start and enable the service:<code bash> 
-    * ''%%sudo systemctl enable --now custom-vt-colors.service%%''+sudo systemctl enable --now custom-vt-colors.service 
 +</code>
  
 \\ \\
  
-<HTML> +---- 
-<hr style="overflow: visible;padding: 0;border: none;border-top: medium double #b5b5b5;color: #b5b5b5;text-align: center;"> +
-</HTML>+
 =====VT Colorschemes===== =====VT Colorschemes=====
 For the colorschemes below (except default), I imported the Xresources of each colorscheme to https://terminal.sexy to convert the hex values to rgb quickly. Then I created the files using those rgb values. For the colorschemes below (except default), I imported the Xresources of each colorscheme to https://terminal.sexy to convert the hex values to rgb quickly. Then I created the files using those rgb values.
Line 125: Line 127:
   * [[linux:ricing:colorscheme:solarized_light#solarized_light_vt_colorscheme|Solarized Light Colorscheme]]   * [[linux:ricing:colorscheme:solarized_light#solarized_light_vt_colorscheme|Solarized Light Colorscheme]]
  
-<HTML> +----
-<hr style="border: 0;height: 0;border-top: 1px solid rgba(0, 0, 0, 0.1);border-bottom: 1px solid rgba(255, 255, 255, 0.3);"> +
-</HTML>+
  
 ====VT Colorscheme Format==== ====VT Colorscheme Format====
Line 142: Line 142:
  
 For a working example and/or to make a backup of the current settings: For a working example and/or to make a backup of the current settings:
-  * Save/view current vt colors in a **setvtrgb** usable format: +  * Save/view current vt colors in a **setvtrgb** usable format:<code bash> 
-    * ''%%cat /sys/module/vt/parameters/default_{red,grn,blu} > ~/consolecolors%%''+cat /sys/module/vt/parameters/default_{red,grn,blu} > ~/consolecolors 
 +</code>
  
-<HTML> +----
-<hr style="border: 0;height: 0;border-top: 1px solid rgba(0, 0, 0, 0.1);border-bottom: 1px solid rgba(255, 255, 255, 0.3);"> +
-</HTML>+
  
 ===Converting Hex Colors to RGB=== ===Converting Hex Colors to RGB===
-  * Convert hex values to rgb with each of r,g,b being on a newline:<file sh hexrgb.sh>+  * Convert hex values to rgb with each of r,g,b being on a newline:<file bash hexrgb.sh>
 #!/usr/bin/env bash #!/usr/bin/env bash
  
-Take input hex number, convert to uppercase, strip # +hex_regex='^#?([[:xdigit:]]{6})$' 
-hexinput=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed 's/#//g' )+ 
 +# Check if input is valid hex 
 +if [[ "${1}" =~ ${hex_regex} ]]; then 
 +  hexinput=$(echo "${1}" | tr '[:lower:]' '[:upper:]' | sed 's/#//g' ) 
 +else 
 +  printf '%s\n' "[ERROR] ${1} is not a valid hex color code" >&2 && exit 1 
 +fi
  
 # Print RGB output with each on it's own line # Print RGB output with each on it's own line
-printf "%d\n%d\n%d\n" 0x${hexinput:0:2} 0x${hexinput:2:2} 0x${hexinput:4:2}+printf '%d\n"0x${hexinput:0:2}" "0x${hexinput:2:2}" "0x${hexinput:4:2}
 + 
 +# vim: ft=sh ts=2 sts=2 sw=2 sr et
 </file> </file>
   * Run it:    * Run it: 
Line 163: Line 170:
     * Escaping or quoting the hex value starting with a # is necessary else bash will think it's a comment.     * Escaping or quoting the hex value starting with a # is necessary else bash will think it's a comment.
  
-\\ 
  
-<HTML> +----
-<hr style="overflow: visible;padding: 0;border: none;border-top: medium double #b5b5b5;color: #b5b5b5;text-align: center;"> +
-</HTML>+
  
-=====VT Fonts===== 
-Nothing too exciting yet.. 
- 
-  * Change the font & size interactively: 
-    * ''%%sudo dpkg-reconfigure -plow console-setup%%'' 
-  * Change the font & size manually: 
-    * ''%%sudoedit /etc/default/console-setup%%'' 
-  * VT font directory is: 
-    * ''%%/usr/share/consolefonts%%'' 
-  * Show current font. (Run in a tty): 
-    * ''%%showconsolefont%%'' 
- 
-<HTML> 
-<hr style="overflow: visible;padding: 0;border: none;border-top: medium double #b5b5b5;color: #b5b5b5;text-align: center;"> 
-</HTML> 
  
 =====References===== =====References=====
Line 192: Line 181:
   * https://stackoverflow.com/a/7254022 - Convert hex to rgb   * https://stackoverflow.com/a/7254022 - Convert hex to rgb
   * https://serverfault.com/a/476699 - Adding executable to initramfs   * https://serverfault.com/a/476699 - Adding executable to initramfs
- 
-====Fonts==== 
-  * ''%%man console-setup%%'' 
  
 ====General==== ====General====
   * http://blog.startaylor.net/2016/05/30/howto-console/   * http://blog.startaylor.net/2016/05/30/howto-console/
 +
linux/ricing/virtual_terminal_color.1595000690.txt.gz · Last modified: by chuck