dotfiles/etc/vt-color-scheme.py

77 lines
1.9 KiB
Python
Raw Normal View History

2022-01-22 22:55:38 +00:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Usage:
# 1. Save as `vt-color-scheme.py` in $PATH (/usr/bin for example)
# 2. Make executable `chmod +x vt-color-scheme.py`
# 3. Add `$(vt-color-scheme.py)` to `GRUB_CMDLINE_LINUX` in `/etc/default/grub`
# example `GRUB_CMDLINE_LINUX="$(vt-color-scheme.py)"`
# 4. Create new grub config with `sudo grub-mkconfig -o /boot/grub/grub.cfg`
# 5. Reboot to apply changes
KERNEL_PARAMS = ['vt.default_red', 'vt.default_grn', 'vt.default_blu', ]
MEOW_SCHEME = [
'#242030',
'#d65c70',
'#88a344',
'#b7a55d',
'#4b7da8',
'#75507b',
'#6fbcba',
'#9f98b7',
'#494251',
'#e53d59',
'#b3d65c',
'#d8c67d',
'#78addb',
'#ad7fa8',
'#addddd',
'#beb2ea',
]
AWOO_SCHEME = [
'#010c10', # black
'#3f7575', # red
'#b4e0e0', # green
'#336464', # yellow
'#8a9ea0', # blue
'#8a9ea0', # purple
'#8a9ea0', # cyan
'#8a9ea0', # light gray
'#687171', # dark gray
'#336464', # bright red
'#b4e0e0', # bright green
'#336464', # bright yellow
'#8a9ea0', # bright blue
'#8a9ea0', # bright purple
'#8a9ea0', # bright cyan
'#b9d2d4', # white
]
def color_scheme_to_rgb_channel_data(color_scheme):
"""
[ '#r1g1b1', '#r2g2b2', ... ] => [ [r1, r2, ...], [g1, g2, ...], [b1, b2, ...], ]
"""
def split_to_rgb(color):
# rgb str -> [red, green, blue]
hex_value = int(color, 16)
return [hex_value >> 16 & 255, hex_value >> 8 & 255, hex_value & 255]
return zip(*[split_to_rgb(color.strip('#')) for color in color_scheme])
def prepare_param(param, channel_data):
return '{param}={values}'.format(param=param, values=','.join(hex(byte) for byte in channel_data))
def main(colors):
print(' '.join(prepare_param(param, channel) for param, channel in \
zip(KERNEL_PARAMS, color_scheme_to_rgb_channel_data(colors))))
if __name__ == '__main__':
main(AWOO_SCHEME)