Compare commits

...

40 Commits

Author SHA1 Message Date
Azalea (on HyDEV-Daisy) 512d40f4de [U] Release 1.1.3-pre1 2022-07-29 11:04:30 -04:00
Azalea (on HyDEV-Daisy) 17a28c0495 [O] Allow abbreviation in selection 2022-07-29 10:50:20 -04:00
Azalea (on HyDEV-Daisy) de0d381ee2 [F] Fix choice saving 2022-07-29 10:45:51 -04:00
Azalea (on HyDEV-Daisy) 4835bbba40 [O] Adapt fore-back configuration 2022-07-29 10:37:46 -04:00
Azalea (on HyDEV-Daisy) e35db2b838 Merge branch 'master' of https://github.com/hykilpikonna/neofetch 2022-07-29 09:55:11 -04:00
Azalea (on HyDEV-Daisy) 9c187da44a [F] Fix duplicate random color arrangements 2022-07-29 09:55:09 -04:00
Hykilpikonna 0d5cb3da51 [PR] #6 YisuiDenghua/patch-3 Readme.md update
Update README.md
2022-07-27 16:18:05 -04:00
Hykilpikonna 255e1d3f99 [-] Remove unused numpy file 2022-07-26 22:48:45 -04:00
Milena - 一穗灯花 9dfbeeb3fe Update README.md 2022-07-26 17:46:32 +08:00
Azalea (on HyDEV-Daisy) 92623417f9 [U] Release 1.1.2 2022-07-25 21:24:43 -04:00
Azalea (on HyDEV-Daisy) 47e8a4b6ae Merge branch 'master' of https://github.com/hykilpikonna/neofetch 2022-07-25 21:21:25 -04:00
Azalea (on HyDEV-Daisy) ce787650ff [F] Remove numpy requirement 2022-07-25 21:21:19 -04:00
Hykilpikonna f38da1da7b [U] Readme: Add nixos demo 2022-07-25 21:16:24 -04:00
Hykilpikonna aa2a46c307 [U] Update todo & future changelog 2022-07-25 21:11:34 -04:00
Hykilpikonna 249d88968a [PR] #5 larobitrumpet/master - Add more flags
Add Various Pride Flags
2022-07-25 21:07:24 -04:00
Azalea (on HyDEV-Daisy) 47ad86c1b3 Merge branch 'master' of https://github.com/hykilpikonna/neofetch 2022-07-25 21:06:31 -04:00
Azalea (on HyDEV-Daisy) 3358918a96 [U] Release v1.1.1 2022-07-25 21:06:27 -04:00
Hykilpikonna d210e8b717 [U] Changelog 2022-07-25 21:05:33 -04:00
Azalea (on HyDEV-Daisy) 2a0e05e228 [+] Create color scale without numpy 2022-07-25 21:02:10 -04:00
Hykilpikonna f80262b615 [PR] #4 YisuiDenghua/patch-1 Add NixOS instructions
Update README.md
2022-07-25 20:51:37 -04:00
Hykilpikonna 7aa46cb623 Merge branch 'master' into patch-1 2022-07-25 20:51:13 -04:00
Hykilpikonna 2a4242c57a [PR] #3 emixa-d/master - Add Guix installation instructions
Add Guix installation instructions
2022-07-25 20:48:29 -04:00
Azalea (on HyDEV-Daisy) 8d3a3cc7f0 [F] Fix config upgrade error 2022-07-25 20:43:52 -04:00
Lucy Robillard bee34b6262 Fix bigender flag 2022-07-25 12:59:23 -07:00
Lucy Robillard f4b91ddb9a Add bigender flag 2022-07-25 12:54:48 -07:00
Lucy Robillard 348c6d4dcc Add omnisexual flag 2022-07-25 12:43:55 -07:00
Lucy Robillard d9a46c97c8 Add abrosexual flag 2022-07-25 12:38:50 -07:00
Lucy Robillard 06d299f2f7 Add 5 stripe gay men flag 2022-07-20 12:51:04 -07:00
Lucy Robillard cd0f55cd92 Add polysexual 2022-07-20 12:37:10 -07:00
Lucy Robillard 5f31542362 Add demigender, demiboy, and demigirl 2022-07-20 12:27:40 -07:00
Lucy Robillard edd5d39f73 Add genderfae and demifae 2022-07-20 12:13:11 -07:00
Lucy Robillard 73bf1e7fdf Add genderfaun flag 2022-07-20 11:04:51 -07:00
Lucy Robillard a511742239 Add transfeminine flag 2022-07-20 10:56:09 -07:00
Lucy Robillard abed2f36e0 Add 3 versions of the aroace flag 2022-07-20 10:40:44 -07:00
Milena - 一穗灯花 7682408554 Update README.md 2022-06-30 17:03:21 +08:00
Milena - 一穗灯花 9e85fbc151 修正了语法错误 2022-06-30 17:01:34 +08:00
Milena - 一穗灯花 10408af1a2 修正了语法错误 2022-06-30 16:59:44 +08:00
Milena - 一穗灯花 23814863f1 Update README.md 2022-06-30 16:58:12 +08:00
Milena - 一穗灯花 8d65521fad Update README.md 2022-06-30 16:54:44 +08:00
Maxime Devos 707eac5087 [U] guix: Update readme usage 2022-05-12 13:24:14 +00:00
7 changed files with 284 additions and 59 deletions
+23 -4
View File
@@ -19,10 +19,13 @@ pip install hyfetch
Currently, these distributions have existing packages for HyFetch:
* ArchLinux: `yay -S hyfetch` (Thanks to @ Aleksana)
* NixOS: `nix-env -i hyfetch` ([In Progress](https://github.com/NixOS/nixpkgs/pull/170309))
* Guix: [In progress](https://issues.guix.gnu.org/54847#8-lineno27)
* Nix (Nixpkgs): `nix-env -i hyfetch` ([In Progress](https://github.com/NixOS/nixpkgs/pull/170309))
* Nix ([NUR](nur.nix-community.org)): Install package `nur.repos.YisuiMilena.hyfetch`. (Thanks to @ YisuiDenghua)
* Guix: `guix install hyfetch` (Thanks to @ WammKD)
Currently, if you're using NixOS, you can use HyFetch with `nix-env -if https://github.com/hykilpikonna/hyfetch/tarball/master -A hyfetch`
Currently, if you're using Nix the package manager or NixOS, you can use HyFetch with `nix-env -if https://github.com/hykilpikonna/hyfetch/tarball/master -A hyfetch`
> `hyfetch` is also available in our NixOS-CN's flake. You can add [NixOS-CN](https://github.com/nixos-cn/flakes) in your [Nix Flake](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html) at first, then install package `hyfetch`. (Thanks to @ YisuiDenghua and @ linyinfeng )
## Usage
@@ -48,8 +51,24 @@ Feel free to experiment with it!
### TODO
* [ ] Add interactive configurator for adjusting brightness
* [ ] Add configuration to emphasize certain parts of the original ASCII art (to make icons like Fedora and Ubuntu look nicer)
* [ ] Paginate flags
### 1.1.2
* Add more flags ([#5](https://github.com/hykilpikonna/hyfetch/pull/5))
* Removed `numpy` dependency that was used in 1.1.0
### 1.1.0
* Refactored a lot of things
* Added Beiyang flag xD
* Added interactive configurator for brightness adjustment
* Added dark/light mode selection
* Added color bar preview for RGB/8bit mode selection
* Added random color arrangement feature (for NixOS)
<img src="https://user-images.githubusercontent.com/22280294/180901539-014f036e-c926-4470-ac72-a6d6dcf30672.png" width="100px" />
### 1.0.7
+26 -21
View File
@@ -1,66 +1,71 @@
"""
This version of color_scale is a special version made without numpy dependency. The numpy version
would be faster, but numpy is 11 MB large. In comparison, hyfetch 1.0.7 is only 105 kB, so it's not
a good idea to depend on numpy.
"""
from __future__ import annotations
import numpy as np
from numpy import ndarray
from .color_util import RGB
def create_gradient_hex(colors: list[str], resolution: int = 300) -> ndarray:
def create_gradient_hex(colors: list[str], resolution: int = 300) -> list[RGB]:
"""
Create gradient array from hex
"""
colors = np.array([RGB.from_hex(s) for s in colors])
colors = [RGB.from_hex(s) for s in colors]
return create_gradient(colors, resolution)
def create_gradient(colors: ndarray, resolution: int) -> ndarray:
def create_gradient(colors: list[RGB], resolution: int) -> list[RGB]:
"""
Create gradient 2d array.
Create gradient array
Usage: arr[ratio / len(arr), :] = Scaled gradient color at that point
Usage: arr[ratio / len(arr)] = Scaled gradient color at that point
"""
result = np.zeros((resolution * (len(colors) - 1), 3), dtype='uint8')
result = []
# Create gradient mapping
for i in range(len(colors) - 1):
c1 = colors[i, :]
c2 = colors[i + 1, :]
c1 = colors[i]
c2 = colors[i + 1]
bi = i * resolution
for r in range(resolution):
ratio = r / resolution
result[bi + r, :] = c2 * ratio + c1 * (1 - ratio)
for ri in range(resolution):
ratio = ri / resolution
r = int(c2.r * ratio + c1.r * (1 - ratio))
g = int(c2.g * ratio + c1.g * (1 - ratio))
b = int(c2.b * ratio + c1.b * (1 - ratio))
result.append(RGB(r, g, b))
return result
def get_raw(gradient: ndarray, ratio: float) -> ndarray:
def get_raw(gradient: list[RGB], ratio: float) -> RGB:
"""
:param gradient: Gradient array (2d)
:param ratio: Between 0-1
:return: RGB subarray (1d, has 3 values)
"""
if ratio == 1:
return gradient[-1, :]
return gradient[-1]
i = int(ratio * len(gradient))
return gradient[i, :]
return gradient[i]
class Scale:
colors: ndarray
rgb: ndarray
colors: list[RGB]
rgb: list[RGB]
def __init__(self, scale: list[str], resolution: int = 300):
self.colors = np.array([RGB.from_hex(s) for s in scale])
self.colors = [RGB.from_hex(s) for s in scale]
self.rgb = create_gradient(self.colors, resolution)
def __call__(self, ratio: float) -> RGB:
"""
:param ratio: Between 0-1
"""
return RGB(*get_raw(self.rgb, ratio))
return get_raw(self.rgb, ratio)
def test_color_scale():
+1 -1
View File
@@ -7,7 +7,7 @@ from pathlib import Path
from typing_extensions import Literal
CONFIG_PATH = Path.home() / '.config/hyfetch.json'
VERSION = '1.1.0'
VERSION = '1.1.3-pre.1'
# Obtain terminal size
try:
+49 -25
View File
@@ -13,7 +13,8 @@ from hyfetch import presets
from .color_util import printc, color, clear_screen, LightDark
from .constants import CONFIG_PATH, VERSION, TERM_LEN, TEST_ASCII_WIDTH, TEST_ASCII, GLOBAL_CFG
from .models import Config
from .neofetch_util import run_neofetch, get_distro_ascii, ColorAlignment, ascii_size, color_alignments
from .neofetch_util import run_neofetch, get_distro_ascii, ColorAlignment, ascii_size, fore_back, \
get_fore_back
from .presets import PRESETS
@@ -27,7 +28,10 @@ def check_config() -> Config:
:return: Config object
"""
if CONFIG_PATH.is_file():
return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8')))
try:
return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8')))
except KeyError:
return create_config()
return create_config()
@@ -51,13 +55,29 @@ def literal_input(prompt: str, options: Iterable[str], default: str, show_ops: b
else:
printc(f'{prompt} (default: {default})')
selection = input('> ') or default
while not selection.lower() in lows:
def find_selection(sel: str):
if not sel:
return None
# Find exact match
if sel in lows:
return options[lows.index(sel)]
# Find starting abbreviation
for i, op in enumerate(lows):
if op.startswith(sel):
return options[i]
return None
selection = input('> ').lower() or default
while not find_selection(selection):
print(f'Invalid selection! {selection} is not one of {"|".join(options)}')
selection = input('> ') or default
selection = input('> ').lower() or default
print()
return options[lows.index(selection)]
return find_selection(selection)
def create_config() -> Config:
@@ -178,29 +198,30 @@ def create_config() -> Config:
color_alignment = None
while True:
clear_screen(title)
printc(f'&a5. Let\'s choose a color arrangement!')
printc(f'You can choose standard horizontal or vertical alignment, or use one of the random color schemes, or assign colors yourself (TODO).')
print()
asc = get_distro_ascii()
asc_width = ascii_size(asc)[0]
asciis = [
[*ColorAlignment('horizontal').recolor_ascii(asc, _prs).split('\n'), 'Horizontal'.center(asc_width)],
[*ColorAlignment('vertical').recolor_ascii(asc, _prs).split('\n'), 'Vertical'.center(asc_width)],
fore_back = get_fore_back()
arrangements = [
('Horizontal', ColorAlignment('horizontal', fore_back=fore_back)),
('Vertical', ColorAlignment('vertical'))
]
ascii_per_row = TERM_LEN // (asc_width + 2)
# Random color schemes
# ascii_indices =
pis = list(range(len(_prs.unique_colors().colors)))
while len(pis) < len(set(re.findall('(?<=\\${c)[0-9](?=})', asc))):
slots = len(set(re.findall('(?<=\\${c)[0-9](?=})', asc)))
while len(pis) < slots:
pis += pis
perm = list(permutations(pis))
perm = {p[:slots] for p in permutations(pis)}
random_count = ascii_per_row * 2 - 2
choices = random.sample(perm, random_count)
choices = [{i: n for i, n in enumerate(c)} for c in choices]
asciis += [[*ColorAlignment('custom', r).recolor_ascii(asc, _prs).split('\n'), f'random{i}'.center(asc_width)]
for i, r in enumerate(choices)]
if random_count > len(perm):
choices = perm
else:
choices = random.sample(perm, random_count)
choices = [{i + 1: n for i, n in enumerate(c)} for c in choices]
arrangements += [(f'random{i}', ColorAlignment('custom', r)) for i, r in enumerate(choices)]
asciis = [[*ca.recolor_ascii(asc, _prs).split('\n'), k.center(asc_width)] for k, ca in arrangements]
while asciis:
current = asciis[:ascii_per_row]
@@ -210,6 +231,8 @@ def create_config() -> Config:
[printc(' '.join(line)) for line in zip(*current)]
print()
printc(f'&a5. Let\'s choose a color arrangement!')
printc(f'You can choose standard horizontal or vertical alignment, or use one of the random color schemes.')
print('You can type "roll" to randomize again.')
print()
choice = literal_input(f'Your choice?', ['horizontal', 'vertical', 'roll'] + [f'random{i}' for i in range(random_count)], 'horizontal')
@@ -217,12 +240,13 @@ def create_config() -> Config:
if choice == 'roll':
continue
if choice in ['horizontal', 'vertical']:
color_alignment = ColorAlignment(choice)
elif choice.startswith('random'):
color_alignment = ColorAlignment('custom', choices[int(choice[6])])
# Save choice
arrangement_index = {k.lower(): ca for k, ca in arrangements}
if choice in arrangement_index:
color_alignment = arrangement_index[choice]
else:
raise NotImplementedError()
print('Invalid choice.')
continue
break
@@ -306,7 +330,7 @@ def run():
# Debug recommendations
if args.debug_list:
distro = args.debug_list
ca = color_alignments[distro]
ca = fore_back[distro]
print(distro)
GLOBAL_CFG.override_distro = distro
+25 -7
View File
@@ -150,6 +150,10 @@ def get_distro_ascii(distro: str | None = None) -> str:
return normalize_ascii(check_output([get_command_path(), cmd]).decode().strip())
def get_distro_name():
return check_output([get_command_path(), 'ascii_distro_name']).decode().strip()
def run_neofetch(preset: ColorProfile, alignment: ColorAlignment):
asc = get_distro_ascii()
w, h = ascii_size(asc)
@@ -179,12 +183,26 @@ def run_neofetch(preset: ColorProfile, alignment: ColorAlignment):
subprocess.run(full_cmd)
# Color alignment recommendations
color_alignments = {
'fedora': ColorAlignment('horizontal', fore_back=(2, 1)),
'ubuntu': ColorAlignment('horizontal', fore_back=(2, 1)),
'NixOS.*': ColorAlignment('custom', {1: 1, 2: 0}),
# 'arch': ColorAlignment('horizontal'),
# 'centos': ColorAlignment('horizontal'),
def get_fore_back(distro: str | None = None) -> tuple[int, int] | None:
"""
Get recommended foreground-background configuration for distro, or None if the distro ascii is
not suitable for fore-back configuration.
:return:
"""
if not distro and GLOBAL_CFG.override_distro:
distro = GLOBAL_CFG.override_distro
if not distro:
distro = get_distro_name().lower()
for k, v in fore_back.items():
if distro.startswith(k.lower()):
return v
return None
# Foreground-background recommendation
fore_back = {
'fedora': (2, 1),
'ubuntu': (2, 1),
}
+159
View File
@@ -201,6 +201,30 @@ PRESETS: dict[str, ColorProfile] = {
'#1AB3FF'
]),
'polysexual': ColorProfile([
'#F714BA',
'#01D66A',
'#1594F6',
]),
# omnisexual sorced from https://www.flagcolorcodes.com/omnisexual
'omnisexual': ColorProfile([
'#FE9ACE',
'#FF53BF',
'#200044',
'#6760FE',
'#8EA6FF',
]),
# gay men sourced from https://www.flagcolorcodes.com/gay-men
'gay-men': ColorProfile([
'#078D70',
'#98E8C1',
'#FFFFFF',
'#7BADE2',
'#3D1A78'
]),
'lesbian': ColorProfile([
'#D62800',
'#FF9B56',
@@ -209,6 +233,16 @@ PRESETS: dict[str, ColorProfile] = {
'#A40062'
]),
# abrosexual used colorpicker to source from
# https://fyeahaltpride.tumblr.com/post/151704251345/could-you-guys-possibly-make-an-abrosexual-pride
'abrosexual': ColorProfile([
'#46D294',
'#A3E9CA',
'#FFFFFF',
'#F78BB3',
'#EE1766',
]),
'asexual': ColorProfile([
'#000000',
'#A4A4A4',
@@ -224,6 +258,35 @@ PRESETS: dict[str, ColorProfile] = {
'#000000'
]),
# aroace1 sourced from https://flag.library.lgbt/flags/aroace/
'aroace1': ColorProfile([
'#E28C00',
'#ECCD00',
'#FFFFFF',
'#62AEDC',
'#203856'
]),
'aroace2': ColorProfile([
'#000000',
'#810081',
'#A4A4A4',
'#FFFFFF',
'#A8D47A',
'#3BA740'
]),
'aroace3': ColorProfile([
'#3BA740',
'#A8D47A',
'#FFFFFF',
'#ABABAB',
'#000000',
'#A4A4A4',
'#FFFFFF',
'#810081'
]),
# below sourced from https://www.flagcolorcodes.com/flags/pride
# goto f"https://www.flagcolorcodes.com/{preset}" for info
# todo: sane sorting
@@ -260,6 +323,51 @@ PRESETS: dict[str, ColorProfile] = {
'#000000',
]),
# bigender sourced from https://www.flagcolorcodes.com/bigender
'bigender': ColorProfile([
'#C479A2',
'#EDA5CD',
'#D6C7E8',
'#FFFFFF',
'#D6C7E8',
'#9AC7E8',
'#6D82D1',
]),
# demigender yellow sourced from https://lgbtqia.fandom.com/f/p/4400000000000041031
# other colors sourced from demiboy and demigirl flags
'demigender': ColorProfile([
'#7F7F7F',
'#C4C4C4',
'#FBFF75',
'#FFFFFF',
'#FBFF75',
'#C4C4C4',
'#7F7F7F',
]),
# demiboy sourced from https://www.flagcolorcodes.com/demiboy
'demiboy': ColorProfile([
'#7F7F7F',
'#C4C4C4',
'#9DD7EA',
'#FFFFFF',
'#9DD7EA',
'#C4C4C4',
'#7F7F7F',
]),
# demigirl sourced from https://www.flagcolorcodes.com/demigirl
'demigirl': ColorProfile([
'#7F7F7F',
'#C4C4C4',
'#FDADC8',
'#FFFFFF',
'#FDADC8',
'#C4C4C4',
'#7F7F7F',
]),
'transmasculine': ColorProfile([
'#FF8ABD',
'#CDF5FE',
@@ -270,6 +378,29 @@ PRESETS: dict[str, ColorProfile] = {
'#FF8ABD',
]),
# transfeminine used colorpicker to source from https://www.deviantart.com/pride-flags/art/Trans-Woman-Transfeminine-1-543925985
# linked from https://gender.fandom.com/wiki/Transfeminine
'transfeminine': ColorProfile([
'#73DEFF',
'#FFE2EE',
'#FFB5D6',
'#FF8DC0',
'#FFB5D6',
'#FFE2EE',
'#73DEFF',
]),
# genderfaun sourced from https://www.flagcolorcodes.com/genderfaun
'genderfaun': ColorProfile([
'#FCD689',
'#FFF09B',
'#FAF9CD',
'#FFFFFF',
'#8EDED9',
'#8CACDE',
'#9782EC',
]),
'demifaun': ColorProfile([
'#7F7F7F',
'#7F7F7F',
@@ -286,6 +417,34 @@ PRESETS: dict[str, ColorProfile] = {
'#7F7F7F',
]),
# genderfae sourced from https://www.flagcolorcodes.com/genderfae
'genderfae': ColorProfile([
'#97C3A5',
'#C3DEAE',
'#F9FACD',
'#FFFFFF',
'#FCA2C4',
'#DB8AE4',
'#A97EDD',
]),
# demifae used colorpicker to source form https://www.deviantart.com/pride-flags/art/Demifae-870194777
'demifae': ColorProfile([
'#7F7F7F',
'#7F7F7F',
'#C5C5C5',
'#C5C5C5',
'#97C3A4',
'#C4DEAE',
'#FFFFFF',
'#FCA2C5',
'#AB7EDF',
'#C5C5C5',
'#C5C5C5',
'#7F7F7F',
'#7F7F7F',
]),
'neutrois': ColorProfile([
'#FFFFFF',
'#1F9F00',
+1 -1
View File
@@ -32,7 +32,7 @@ setup(
packages=['hyfetch'],
package_data={'hyfetch': ['hyfetch/*']},
include_package_data=True,
install_requires=['setuptools', 'typing_extensions', 'numpy'],
install_requires=['setuptools', 'typing_extensions'],
entry_points={
"console_scripts": [
"hyfetch=hyfetch.main:run",