Compare commits

...

53 Commits

Author SHA1 Message Date
Hykilpikonna 8616ff0504 [U] Release 1.4.3 2022-10-30 13:24:53 -04:00
Hykilpikonna dde9443ec7 [U] Update changelog 2022-10-30 13:23:16 -04:00
Hykilpikonna b6f0a80bb1 [F] Specify /usr/bin/env bash to prevent ld signature check on iOS 2022-10-30 13:21:21 -04:00
Hykilpikonna a758b4ba04 [U] Update changelog 2022-10-30 13:16:30 -04:00
Hykilpikonna 700f651378 [F] Fix cols coloring reset for bash 3.2
Introduce by #24
2022-10-30 13:11:27 -04:00
Hykilpikonna 77614b635f Merge branch 'master' of github.com:hykilpikonna/hyfetch 2022-10-30 12:35:54 -04:00
Hykilpikonna fdd3ef970d [PR] dylanaraps/neofetch#2222 from AwkwardTeenageBoy - VanillaOS neofetch
Upstream PR: https://github.com/dylanaraps/neofetch/pull/2222
Thanks to @AwkwardTeenageBoy

Co-authored-by: Twinkie <105467171+AwkwardTeenageBoy@users.noreply.github.com>
2022-10-30 12:35:36 -04:00
Hykilpikonna e49ed7d080 [PR] #32 from ngkz: Add gender presentation pride flags 2022-10-30 12:25:47 -04:00
Kazutoshi Noguchi a1149ab68b add GNC, femboy and tomboy flags 2022-10-30 18:50:41 +09:00
Twinkie 6390ed10c4 Update neofetch 2022-10-27 12:20:39 -07:00
Twinkie 810b380e47 Update neofetch 2022-10-27 12:17:20 -07:00
Twinkie 1274e977c3 Update neofetch 2022-10-27 12:07:51 -07:00
Twinkie 38fb44cb8e Added Vanilla Logo and Support for Vanilla 2022-10-27 10:15:52 -07:00
Hykilpikonna 90c94044f4 [PR] #31 from yxnan: Check if the output is a tty 2022-10-27 10:39:22 -04:00
yxnan 5bf7fbf2b4 Add options for --stdout 2022-10-27 22:16:10 +08:00
yxnan 23a1b10467 Check if the output is a tty
The color code should not be emitted if the stdout is not a typical terminal, we add the check so there is no need to explictly specify `--stdout`
2022-10-27 00:27:23 +08:00
Hykilpikonna 0dae7ca3f9 [U] Update todo list 2022-10-25 03:27:23 -04:00
Hykilpikonna e23eb980d3 [U] Update screenshot 2022-10-25 03:19:52 -04:00
Azalea (on HyDEV-Daisy) 7171494e95 [F] Fix OSC timeout too short for ssh 2022-10-23 02:51:34 -04:00
Azalea (on HyDEV-Daisy) c00848fd79 [U] Update readme changelog 2022-10-23 02:26:55 -04:00
Azalea (on HyDEV-Daisy) 717ff369c0 [O] Optimize fore_back distro detection 2022-10-23 02:20:51 -04:00
Azalea (on HyDEV-Daisy) ff44ea6185 [+] Add more ubuntu variants with fore_back layout 2022-10-23 02:16:08 -04:00
Azalea (on HyDEV-Daisy) 969a7c668c [O] Dynamic prompt numbering 2022-10-23 02:12:05 -04:00
Azalea (on HyDEV-Daisy) bd5d76167e [F] Fix incorrect coloring when the first color isn't ${c1} 2022-10-23 02:06:45 -04:00
Azalea (on HyDEV-Daisy) f57ad70a20 [O] Clarify prompt 2022-10-23 01:51:42 -04:00
Azalea (on HyDEV-Daisy) a3da5b6c59 [F] Fix lightness logic 2022-10-23 01:51:12 -04:00
Azalea (on HyDEV-Daisy) 3cbb20c899 [F] Refactor lightness logic 2022-10-23 01:37:48 -04:00
Azalea (on HyDEV-Daisy) 0a9ac6a351 [U] Detect background and color mode in main 2022-10-23 01:37:23 -04:00
Azalea (on HyDEV-Daisy) 75ed187e72 [+] termenv: Detect system when detecting ansi mode 2022-10-23 01:36:09 -04:00
Azalea (on HyDEV-Daisy) cd4849f0b8 [F] Fix unhashable type error for RGB 2022-10-23 01:35:54 -04:00
Azalea (on HyDEV-Daisy) 0960024e71 [+] termenv: Translate golang code into python 2022-10-22 19:52:05 -04:00
Azalea (on HyDEV-Daisy) 7411ec87e7 [F] Fix relative import 2022-10-22 18:46:42 -04:00
Azalea (on HyDEV-Daisy) d8f49a2ea2 [+] Detect if a color is light 2022-10-22 18:42:52 -04:00
Azalea (on HyDEV-Daisy) 101d798c0a [O] Refactor HSL and RGB 2022-10-22 18:42:06 -04:00
Azalea (on HyDEV-Daisy) 330de73df3 [M] Rename osc -> termenv 2022-10-22 18:26:00 -04:00
Azalea (on HyDEV-Daisy) 4e11d21401 [+] osc: parse background color 2022-10-22 18:22:51 -04:00
Azalea (on HyDEV-Daisy) cb5635908f [-] osc: remove commented code 2022-10-22 17:53:00 -04:00
Azalea (on HyDEV-Daisy) fbbe3b1c93 [+] Send/read osc responses 2022-10-22 17:52:36 -04:00
Azalea 774598fcb3 [PR] dylanaraps/neofetch#2215 from VitoFe - Add garuda_small, sort _small variants
Upstream PR: https://github.com/dylanaraps/neofetch/pull/2215
Thanks to @VitoFe

Co-authored-by: VitoFe <vito-7@hotmail.it>
2022-10-21 14:42:22 -04:00
Azalea 8abfb0c876 [PR] dylanaraps/neofetch#2213 from EnterTheVoid-x86 - Add Cobalt Linux logo
Upstream PR: https://github.com/dylanaraps/neofetch/pull/2213
Thanks to @EnterTheVoid-x86

Co-authored-by: etvx86 <64978924+EnterTheVoid-x86@users.noreply.github.com>
2022-10-21 14:25:26 -04:00
Hykilpikonna 7a6628d387 [PR] #28 from alyxferrari: Surround macOS build number in parentheses 2022-10-21 13:02:36 +08:00
Azalea (on HyDEV-Daisy) 09185e5a41 [F] Fix light dark detection 2022-10-19 23:48:41 -04:00
Alyx Ferrari 6efd890526 Surround macOS build number in parentheses 2022-10-19 10:25:08 -04:00
VitoFe 05cf31fc14 Add garuda_small, sort _small variants
Added garuda_small
Sorted the _small variants note distro list alphabetically, just like the normal list (for consistency)
2022-10-15 17:55:11 +00:00
Hykilpikonna 220b528c72 [PR] #27 from alyxferrari: arch-linux-readme-fix
Update Arch Linux installation docs
2022-10-14 13:25:37 -04:00
Alyx Ferrari 038d976b39 Update Arch Linux installation docs 2022-10-14 13:23:16 -04:00
Hykilpikonna 60609dfb7e [PR] #26 from alyxferrari: Fix typo
Change 'look' to 'looks' in main.py
2022-10-14 13:21:46 -04:00
Alyx Ferrari 610e06fcd9 Change 'look' to 'looks' in main.py 2022-10-14 13:11:05 -04:00
etvx86 49003c859f add cobalt in help message 2022-10-11 13:44:16 -04:00
etvx86 10bf2fce08 Add Cobalt Linux logo
Hopefully this gets merged -

Cobalt Linux is a distribution I'm currently working on, which will come with window managers and have the goal of customization. It also has a goal of "Arch Linux made easy".
2022-10-11 13:38:11 -04:00
Hykilpikonna 8a091f4d01 [PR] #25 from ben5vik: add unlabeled flag 2022-10-10 10:06:31 -04:00
Ben 10b331052d Update presets.py 2022-10-10 15:45:20 +02:00
Ben 8751faab2e Adding unlabeled 2022-10-10 15:40:14 +02:00
10 changed files with 494 additions and 119 deletions
+20 -4
View File
@@ -2,7 +2,7 @@
neofetch with pride flags <3
<img src="https://user-images.githubusercontent.com/22280294/162614541-af2b4660-f1f7-4287-b978-1aa2266ac70f.png" width="60%">
<img alt="screenshot" src="https://user-images.githubusercontent.com/22280294/197708447-ddee6db2-1017-48f2-b507-8ddf85acef0d.png">
### Running Updated Original Neofetch
@@ -27,7 +27,7 @@ pip install hyfetch
Currently, these distributions have existing packages for HyFetch:
* ArchLinux: `yay -S hyfetch` (Thanks to [@Aleksana](https://github.com/Aleksanaa))
* Arch Linux: `paru -S hyfetch` or `yay -S hyfetch` (Thanks to [@Aleksana](https://github.com/Aleksanaa))
* Nix: `nix-env -i hyfetch` (Thanks to [@YisuiDenghua](https://github.com/YisuiDenghua))
* Guix: `guix install hyfetch` (Thanks to [@WammKD](https://github.com/WammKD))
@@ -84,11 +84,27 @@ Updates to `neowofetch` begins with the emoji 🖼️
### TODO
* [ ] Allow left-right arrow keys for pagination
* [ ] Implement light/dark background detection based on https://github.com/muesli/termenv
* [ ] (Important!) Refactor flag storage & coloring to support non-stride patterns
* [ ] Config menu: Allow left-right arrow keys for pagination
<!-- CHANGELOG STARTS HERE --->
### 1.4.3
* 🌈 **Auto detect terminal background color & rgb support**
* 🌈 **Optimize experience on light-themed terminals**
* 🌈 Fix bugs with lightness and light-mode config not applying
* 🌈 Fix color alignment for distros with first color ≠ `${c1}` (e.g. Ubuntu Budgie)
* 🌈 Add unlabeled flags (#25)
* 🌈 Add gender nonconforming & femboy & tomboy flags (#32)
* 🌈 Fix jailbreak iOS shell `killed: 9` issue caused by ld signature check.
* 🖼️ Distro - Add garuda_small ([dylanaraps#2215](https://github.com/dylanaraps/neofetch/pull/2215))
* 🖼️ Distro - Add Cobalt Linux ([dylanaraps#2213](https://github.com/dylanaraps/neofetch/pull/2213))
* 🖼️ Distro - Add VanillaOS ([dylanaraps#2222](https://github.com/dylanaraps/neofetch/pull/2222))
* 🖼️ Distro - Surround macOS build number in parentheses (#28)
* 🖼️ Misc - Auto select stdout mode based on tty detection (#31)
* 🖼️ Bug Fix - Fix cols coloring reset for bash 3.2 (#24)
### 1.4.2
* 🌈 Detailed runnning/contributing instructions in README.md (#21)
+32 -11
View File
@@ -1,8 +1,7 @@
from __future__ import annotations
import colorsys
from typing import NamedTuple, Callable, Optional
from dataclasses import dataclass, astuple
from typing_extensions import Literal
from .constants import GLOBAL_CFG
@@ -84,11 +83,28 @@ def redistribute_rgb(r: int, g: int, b: int) -> tuple[int, int, int]:
return int(gray + x * r), int(gray + x * g), int(gray + x * b)
class RGB(NamedTuple):
@dataclass(unsafe_hash=True)
class HSL:
h: float
s: float
l: float
def __iter__(self):
return iter(astuple(self))
def rgb(self) -> RGB:
return RGB(*[round(v * 255.0) for v in colorsys.hls_to_rgb(self.h, self.l, self.s)])
@dataclass(unsafe_hash=True)
class RGB:
r: int
g: int
b: int
def __iter__(self):
return iter(astuple(self))
@classmethod
def from_hex(cls, hex: str) -> "RGB":
"""
@@ -100,9 +116,7 @@ class RGB(NamedTuple):
:param hex: Hex color code
:return: RGB object
"""
while hex.startswith('#'):
hex = hex[1:]
hex = hex.lstrip("#")
r = int(hex[0:2], 16)
g = int(hex[2:4], 16)
b = int(hex[4:6], 16)
@@ -177,6 +191,10 @@ class RGB(NamedTuple):
"""
return RGB(*redistribute_rgb(*[v * multiplier for v in self]))
def hsl(self) -> HSL:
h, l, s = colorsys.rgb_to_hls(*[v / 255.0 for v in self])
return HSL(h, s, l)
def set_light(self, light: float, at_least: bool | None = None, at_most: bool | None = None) -> 'RGB':
"""
Set HSL lightness value
@@ -187,16 +205,19 @@ class RGB(NamedTuple):
:return: New color (original isn't modified)
"""
# Convert to HSL
h, l, s = colorsys.rgb_to_hls(*[v / 255.0 for v in self])
hsl = self.hsl()
# Modify light value
if at_least is None and at_most is None:
l = light
hsl.l = light
else:
if at_most:
l = min(l, light)
hsl.l = min(hsl.l, light)
if at_least:
l = max(l, light)
hsl.l = max(hsl.l, light)
# Convert back to RGB
return RGB(*[round(v * 255.0) for v in colorsys.hls_to_rgb(h, l, s)])
return hsl.rgb()
def is_light(self):
return self.hsl().l > 0.5
+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.4.2'
VERSION = '1.4.3'
TEST_ASCII = r"""
+91 -69
View File
@@ -4,13 +4,14 @@ from __future__ import annotations
import argparse
import json
import random
import re
from itertools import permutations
import traceback
from typing import Iterable
from itertools import permutations
from math import ceil
from typing import Iterable
from .color_util import printc, color, clear_screen
from . import termenv
from .color_scale import Scale
from .color_util import printc, color, clear_screen, AnsiMode
from .constants import *
from .models import Config
from .neofetch_util import *
@@ -85,11 +86,28 @@ def create_config() -> Config:
:return: Config object (automatically stored)
"""
# Detect terminal environment
det_bg = termenv.get_background_color()
det_ansi = termenv.detect_ansi_mode()
asc = get_distro_ascii()
asc_width, asc_lines = ascii_size(asc)
title = 'Welcome to &b&lhy&f&lfetch&r! Let\'s set up some colors first.'
logo = color("&b&lhyfetch&r" if det_bg is None or det_bg.is_light() else "&b&lhy&f&lfetch&r")
title = f'Welcome to {logo} Let\'s set up some colors first.'
clear_screen(title)
option_counter = 1
def update_title(k: str, v: str):
nonlocal title, option_counter
if not k.endswith(":"):
k += ':'
title += f"\n&e{option_counter}. {k.ljust(30)} &r{v}"
option_counter += 1
def print_title_prompt(prompt: str):
printc(f'&a{option_counter}. {prompt}')
##############################
# 0. Check term size
try:
@@ -104,11 +122,12 @@ def create_config() -> Config:
##############################
# 1. Select color system
clear_screen(title)
term_len, term_lines = term_size()
try:
# Demonstrate RGB with a gradient. This requires numpy
from .color_scale import Scale
def select_color_system():
if det_ansi == 'rgb':
return 'rgb', 'Detected color mode'
clear_screen(title)
term_len, term_lines = term_size()
scale2 = Scale(['#12c2e9', '#c471ed', '#f7797d'])
_8bit = [scale2(i / term_len).to_ansi_8bit(False) for i in range(term_len)]
@@ -118,28 +137,32 @@ def create_config() -> Config:
printc('&f' + ''.join(c + t for c, t in zip(_rgb, 'RGB Color Testing'.center(term_len))))
print()
printc(f'&a1. Which &bcolor system &ado you want to use?')
print_title_prompt('Which &bcolor system &ado you want to use?')
printc(f'(If you can\'t see colors under "RGB Color Testing", please choose 8bit)')
print()
color_system = literal_input('Your choice?', ['8bit', 'rgb'], 'rgb')
except ModuleNotFoundError:
# Numpy not found, skip gradient test, use fallback
color_system = literal_input('Which &acolor &bsystem &rdo you want to use?',
['8bit', 'rgb'], 'rgb')
return literal_input('Your choice?', ['8bit', 'rgb'], 'rgb'), 'Selected color mode'
# Override global color mode
color_system, ttl = select_color_system()
GLOBAL_CFG.color_mode = color_system
title += f'\n&e1. Selected color mode: &r{color_system}'
update_title(ttl, color_system)
##############################
# 2. Select light/dark mode
clear_screen(title)
light_dark = literal_input(f'2. Is your terminal in &gf(#85e7e9)light mode&r or &gf(#c471ed)dark mode&r?',
['light', 'dark'], 'dark')
is_light = light_dark == 'light'
def select_light_dark():
if det_bg is not None:
return det_bg.is_light(), 'Detected background color'
clear_screen(title)
inp = literal_input(f'2. Is your terminal in &blight mode&r or &4dark mode&r?',
['light', 'dark'], 'dark')
return inp == 'light', 'Selected background color'
is_light, ttl = select_light_dark()
light_dark = 'light' if is_light else 'dark'
GLOBAL_CFG.is_light = is_light
title += f'\n&e2. Light/Dark: &r{light_dark}'
update_title(ttl, light_dark)
##############################
# 3. Choose preset
@@ -168,7 +191,7 @@ def create_config() -> Config:
def print_flag_page(page: list[list[list[str]]], page_num: int):
clear_screen(title)
printc('&a3. Let\'s choose a flag!')
print_title_prompt("Let's choose a flag!")
printc('Available flag presets:')
print(f'Page: {page_num + 1} of {num_pages}')
print()
@@ -198,45 +221,48 @@ def create_config() -> Config:
page -= 1
else:
_prs = PRESETS[preset]
title += f'\n&e3. Selected flag: &r{_prs.color_text(preset)}'
update_title('Selected flag', _prs.set_light_dl_def(light_dark).color_text(preset))
break
#############################
# 4. Dim/lighten colors
clear_screen(title)
printc(f'&a4. Let\'s adjust the color brightness!')
printc(f'The colors might be a little bit too {"bright" if is_light else "dark"} for {light_dark} mode.')
print()
# Print cats
num_cols = term_size()[0] // (TEST_ASCII_WIDTH + 2)
ratios = [col / (num_cols - 1) for col in range(num_cols)]
ratios = [(r * 0.4 + 0.1) if is_light else (r * 0.4 + 0.5) for r in ratios]
lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace(
'{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios]
[printc(' '.join(line)) for line in zip(*lines)]
while True:
def select_lightness():
clear_screen(title)
print_title_prompt("Let's adjust the color brightness!")
printc(f'The colors might be a little bit too {"bright" if is_light else "dark"} for {light_dark} mode.')
print()
printc(f'Which brightness level look the best? (Default: left blank = {GLOBAL_CFG.default_lightness(light_dark):.2f} for {light_dark} mode)')
lightness = input('> ').strip().lower() or None
# Parse lightness
if not lightness or lightness in ['unset', 'none']:
lightness = None
break
# Print cats
num_cols = term_size()[0] // (TEST_ASCII_WIDTH + 2)
mn, mx = 0.15, 0.85
ratios = [col / (num_cols - 1) for col in range(num_cols)]
ratios = [(r * (mx - mn) / 2 + mn) if is_light else ((r * (mx - mn) + (mx + mn)) / 2) for r in ratios]
lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace(
'{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios]
[printc(' '.join(line)) for line in zip(*lines)]
try:
lightness = int(lightness[:-1]) / 100 if lightness.endswith('%') else float(lightness)
assert 0 <= lightness <= 1
break
def_lightness = GLOBAL_CFG.default_lightness(light_dark)
except Exception:
printc('&cUnable to parse lightness value, please input it as a decimal or percentage (e.g. 0.5 or 50%)')
while True:
print()
printc(f'Which brightness level looks the best? (Default: {def_lightness * 100:.0f}% for {light_dark} mode)')
lightness = input('> ').strip().lower() or None
if lightness:
_prs = _prs.set_light_dl(lightness, light_dark)
title += f'\n&e4. Brightness: &r{f"{lightness:.2f}" if lightness else "unset"}'
# Parse lightness
if not lightness or lightness in ['unset', 'none']:
return def_lightness
try:
lightness = int(lightness[:-1]) / 100 if lightness.endswith('%') else float(lightness)
assert 0 <= lightness <= 1
return lightness
except Exception:
printc('&cUnable to parse lightness value, please input it as a decimal or percentage (e.g. 0.5 or 50%)')
lightness = select_lightness()
_prs = _prs.set_light_dl(lightness, light_dark)
update_title('Selected Brightness', f"{lightness:.2f}")
#############################
# 5. Color arrangement
@@ -261,16 +287,16 @@ def create_config() -> Config:
# Random color schemes
pis = list(range(len(_prs.unique_colors().colors)))
slots = len(set(re.findall('(?<=\\${c)[0-9](?=})', asc)))
while len(pis) < slots:
slots = list(set(re.findall('(?<=\\${c)[0-9](?=})', asc)))
while len(pis) < len(slots):
pis += pis
perm = {p[:slots] for p in permutations(pis)}
perm = {p[:len(slots)] for p in permutations(pis)}
random_count = ascii_per_row * ascii_rows - len(arrangements)
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]
choices = [{slots[i]: 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]
@@ -282,7 +308,7 @@ def create_config() -> Config:
[printc(' '.join(line)) for line in zip(*current)]
print()
printc(f'&a5. Let\'s choose a color arrangement!')
print_title_prompt("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()
@@ -302,7 +328,7 @@ def create_config() -> Config:
break
title += f'\n&e5. Color Alignment: &r{color_alignment}'
update_title('Color alignment', color_alignment)
# Create config
clear_screen(title)
@@ -361,12 +387,8 @@ def run():
print(get_distro_ascii())
return
# Load config
config = check_config()
# Reset config
if args.config:
config = create_config()
# Load config or create config
config = create_config() if args.config else check_config()
# Param overwrite config
if args.preset:
@@ -381,13 +403,13 @@ def run():
# Get preset
preset = PRESETS.get(config.preset)
# Lighten
# Lighten (args > config)
if args.scale:
preset = preset.lighten(args.scale)
if args.light:
elif args.light:
preset = preset.set_light_raw(args.light)
if config.lightness:
preset = preset.set_light_dl(config.lightness)
else:
preset = preset.set_light_dl(config.lightness or GLOBAL_CFG.default_lightness())
# Run
try:
+11 -2
View File
@@ -206,7 +206,7 @@ def run_command(args: str, pipe: bool = False) -> str | None:
Run neofetch command
"""
if platform.system() != 'Windows':
full_cmd = shlex.split(f'{get_command_path()} {args}')
full_cmd = shlex.split(f'/usr/bin/env bash {get_command_path()} {args}')
else:
cmd = get_command_path().replace("\\", "/").replace("C:/", "/c/")
@@ -288,8 +288,9 @@ def get_fore_back(distro: str | None = None) -> tuple[int, int] | None:
distro = GLOBAL_CFG.override_distro
if not distro:
distro = get_distro_name().lower()
distro = distro.lower().replace(' ', '-')
for k, v in fore_back.items():
if distro.startswith(k.lower()):
if distro == k.lower():
return v
return None
@@ -298,5 +299,13 @@ def get_fore_back(distro: str | None = None) -> tuple[int, int] | None:
fore_back = {
'fedora': (2, 1),
'ubuntu': (2, 1),
'kubuntu': (2, 1),
'lubuntu': (2, 1),
'xubuntu': (2, 1),
'ubuntu-cinnamon': (2, 1),
'ubuntu-kylin': (2, 1),
'ubuntu-mate': (2, 1),
'ubuntu-studio': (2, 1),
'ubuntu-sway': (2, 1),
}
+62 -1
View File
@@ -112,7 +112,7 @@ class ColorProfile:
"""
return ColorProfile([c.set_light(light, at_least, at_most) for c in self.colors])
def set_light_dl(self, light: float, term: LightDark = GLOBAL_CFG.light_dark()):
def set_light_dl(self, light: float, term: LightDark | None = None):
"""
Set HSL lightness value with respect to dark/light terminals
@@ -120,6 +120,7 @@ class ColorProfile:
:param term: Terminal color (can be "dark" or "light")
:return: New color profile (original isn't modified)
"""
term = term or GLOBAL_CFG.light_dark()
assert term.lower() in ['light', 'dark']
at_least, at_most = (True, None) if term.lower() == 'dark' else (None, True)
return self.set_light_raw(light, at_least, at_most)
@@ -532,4 +533,64 @@ PRESETS: dict[str, ColorProfile] = {
"#F39FCE",
"#EA7BB3",
]),
'unlabeled1': ColorProfile([
'#EAF8E4',
'#FDFDFB',
'#E1EFF7',
'#F4E2C4'
]),
'unlabeled2': ColorProfile([
'#250548',
'#FFFFFF',
'#F7DCDA',
'#EC9BEE',
'#9541FA',
'#7D2557'
]),
'gendernonconforming1': ColorProfile(
ColorProfile([
'#50284d',
'#96467b',
'#5c96f7',
'#ffe6f7',
'#5c96f7',
'#96467b',
'#50284d'
]).with_weights([
4,1,1,1,1,1,4
])
),
'gendernonconforming2': ColorProfile([
'#50284d',
'#96467b',
'#5c96f7',
'#ffe6f7',
'#5c96f7',
'#96467b',
'#50284d'
]),
'femboy': ColorProfile([
"#d260a5",
"#e4afcd",
"#fefefe",
"#57cef8",
"#fefefe",
"#e4afcd",
"#d260a5"
]),
'tomboy': ColorProfile([
"#2f3fb9",
"#613a03",
"#fefefe",
"#f1a9b7",
"#fefefe",
"#613a03",
"#2f3fb9"
]),
}
+162
View File
@@ -0,0 +1,162 @@
from __future__ import annotations
import os
import platform
import signal
import sys
import termios
import tty
from select import select
from .color_util import RGB, AnsiMode
class OSCException(Exception):
pass
def unix_detect_ansi_mode() -> AnsiMode | None:
"""
Translated from Termenv's ColorProfile():
https://github.com/muesli/termenv/blob/42ca574de3e99a262e1724d2fb8daa1aea68a5b9/termenv_unix.go#L23
:return: Ansi mode
"""
if not sys.stdout.isatty():
return 'ansi'
term = os.environ.get('TERM')
color_term = os.environ.get('COLORTERM')
if color_term == 'truecolor' or color_term == '24bit':
if term.startswith('screen') and os.environ.get('TERM_PROGRAM') != 'tmux':
return '8bit'
return 'rgb'
elif color_term == 'true' or color_term == 'yes':
return '8bit'
if term == 'xterm-kitty':
return 'rgb'
elif term == 'linux':
return 'ansi'
if '256color' in term:
return 'rgb'
if 'color' in term:
return '8bit'
if 'ansi' in term:
return 'ansi'
return None
def windows_detect_ansi_mode() -> AnsiMode | None:
"""
Translated from Termenv's ColorProfile():
https://github.com/muesli/termenv/blob/42ca574de3e99a262e1724d2fb8daa1aea68a5b9/termenv_windows.go#L13
:return: Ansi mode
"""
if not sys.stdout.isatty():
return 'ansi'
if os.environ.get("ConEmuANSI") == "ON":
return 'rgb'
release, _, build = map(int, platform.version().split('.'))
if build < 10586 or release < 10:
# No ANSI support before Windows 10 build 10586.
if os.environ.get('ANSICON'):
conv = os.environ.get('ANSICON_VER')
if int(conv) < 181:
return 'ansi'
return '8bit'
return 'ansi'
if build < 14931:
# No true color support before build 14931.
return '8bit'
return 'rgb'
def detect_ansi_mode() -> AnsiMode | None:
system = platform.system().lower()
if system.startswith("linux") or system.startswith("darwin"):
return unix_detect_ansi_mode()
if system.startswith("windows"):
return windows_detect_ansi_mode()
return None
def unix_read_osc(seq: int) -> str:
# screen/tmux can't support OSC, because they can be connected to multiple
# terminals concurrently.
term = os.environ.get('TERM')
if term.startswith("screen") or term.startswith("tmux"):
raise OSCException("Screen/tmux not supported")
t = sys.stdout
if not t.isatty():
raise OSCException("Not a tty")
fd = sys.stdin.fileno()
# Set raw mode
settings = termios.tcgetattr(fd)
tty.setraw(sys.stdin.fileno())
# first, send OSC query, which is ignored by terminal which do not support it
t.write(f"\x1b]{seq};?\x1b\\")
t.flush()
# stdin response timeout should be higher for ssh sessions
timeout = 0.05 if (os.environ.get('SSH_TTY') or os.environ.get('SSH_SESSION')) is None else 0.5
# Wait for input to appear
if not select([sys.stdin], [], [], timeout)[0]:
raise OSCException("No response received")
# Read until termination, or if it doesn't terminate, read until 1 second passes
def handler(signum, frame):
raise IOError()
signal.signal(signal.SIGALRM, handler)
signal.setitimer(signal.ITIMER_REAL, timeout, 1)
code = ""
try:
for _ in range(28):
code += sys.stdin.read(1)
# Terminate with sequence terminator [\ or bell ^G
if code.endswith('\x1b\\') or code.endswith('\a'):
break
signal.alarm(0)
except IOError:
pass
# Reset terminal back to normal mode (previously set to raw mode)
termios.tcsetattr(fd, termios.TCSADRAIN, settings)
# Validate output
if not code:
raise OSCException("No response received")
start = f"\x1b]{seq};"
if not code.startswith(start):
raise OSCException("Received response is not an OSC response")
# Strip starting code and termination code
code = code.lstrip(start).rstrip("\x1b\\").rstrip('\a')
return code
def get_background_color() -> RGB | None:
try:
osc = unix_read_osc(11).lstrip("rgb:")
return RGB.from_hex(''.join([v[:2] for v in osc.split('/')]))
except Exception:
return None
+98 -22
View File
@@ -28,7 +28,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
version=7.3.2
version=7.3.3
# Fallback to a value of '5' for shells which support bash
# but do not set the 'BASH_' shell variables (osh).
@@ -803,11 +803,11 @@ image_source="auto"
# ArcoLinux, Artix, Arya, Asahi, AsteroidOS, astOS, Bedrock, BigLinux, Bitrig, BlackArch,
# blackPanther, BLAG, BlankOn, BlueLight, Bodhi, bonsai, BSD, BunsenLabs, Cachy OS, Calculate,
# CalinixOS, Carbs, CBL-Mariner, CelOS, Center, CentOS, Chakra, ChaletOS, Chapeau, ChonkySealOS,
# Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Condres, Container Linux by CoreOS, CRUX,
# Crystal Linux, Cucumber, CutefishOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, DesaOS,
# Devuan, DietPi, DracOS, DragonFly, Drauger, Droidian, Elementary, Elive, EncryptOS, EndeavourOS,
# Endless, EuroLinux, Exherbo, Exodia Predator OS, Fedora, Feren, Finnix, FreeBSD, FreeMiNT,
# Frugalware, Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU,
# Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt, Condres, Container Linux by CoreOS,
# CRUX, Crystal Linux, Cucumber, CutefishOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin,
# DesaOS, Devuan, DietPi, DracOS, DragonFly, Drauger, Droidian, Elementary, Elive, EncryptOS,
# EndeavourOS, Endless, EuroLinux, Exherbo, Exodia Predator OS, Fedora, Feren, Finnix, FreeBSD,
# FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU,
# GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HamoniKR, HarDClanZ, Hash, Huayra, HydroOS,
# Hyperbola, iglunix, instantOS, IRIX, Itc, januslinux, Kaisen, Kali, KaOS, KDE, Kibojoe, Kogaion,
# Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, LaxerOS, LEDE, LibreELEC, Linspire, Linux, Linux
@@ -824,14 +824,14 @@ image_source="auto"
# Mage, Sparky, Star, SteamOS, Stock Linux, Sulin, SunOS, SwagArch, t2, Tails, TeArch, TorizonCore,
# Trisquel, Twister, Ubuntu, Ubuntu Budgie, Ubuntu Cinnamon, Ubuntu Kylin, Ubuntu MATE, Ubuntu
# Studio, Ubuntu Sway, Ubuntu Touch, Ubuntu-GNOME, ubuntu_old02, Ultramarine Linux, Univalent,
# Univention, Uos, uwuntu, Venom, VNux, Void, VzLinux, wii-linux-ngx, Windows, Windows 10, Windows
# 11, XFerience, Xubuntu, yiffOS, Zorin have ascii logos.
# Univention, Uos, uwuntu, Vanilla, Venom, VNux, Void, VzLinux, wii-linux-ngx, Windows, Windows 10,
# Windows 11, XFerience, Xubuntu, yiffOS, Zorin have ascii logos.
# NOTE: arch, dragonfly, Fedora, LangitKetujuh, nixos, redhat, Ubuntu have 'old' logo variants, use
# {distro}_old to use them.
# NOTE: alpine, android, aoscosretro, arch, arcolinux, artix, CalinixOS, centos, cleanjaro, crux,
# debian, dragonfly, elementary, fedora, freebsd, gentoo, guix, haiku, hyperbola, linuxlite,
# debian, dragonfly, elementary, fedora, freebsd, garuda, gentoo, guix, haiku, hyperbola, linuxlite,
# linuxmint, mac, mageia, manjaro, mx, netbsd, nixos, openbsd, opensuse, orchid, parabola, popos,
# postmarketos, pureos, Raspbian, rocky, slackware, sunos, ubuntu, void have 'small' logo variants,
# use {distro}_small to use them.
@@ -940,11 +940,11 @@ background_color=
# Misc Options
# Stdout mode
# Turn off all colors and disables image backend (ASCII/Image).
# If enabled, turn off all colors and disables image backend (ASCII/Image).
# Useful for piping into another command.
# Default: 'off'
# Values: 'on', 'off'
stdout="off"
# Default: 'auto'
# Values: 'auto', 'on', 'off'
stdout="auto"
EOF
# DETECT INFORMATION
@@ -1275,7 +1275,7 @@ get_distro() {
*) codename=macOS ;;
esac
distro="$codename $osx_version $osx_build"
distro="$codename $osx_version ($osx_build)"
case $distro_shorthand in
on) distro=${distro/ ${osx_build}} ;;
@@ -4656,8 +4656,13 @@ get_cols() {
printf -v block_spaces "%${block_height}s"
# Convert the spaces into rows of blocks.
[[ "$blocks" ]] && cols+="${block_spaces// /${blocks}\[mnl}"
[[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}\[mnl}"
if [[ $BASH_VERSION == 3* ]]; then
[[ "$blocks" ]] && cols+="${block_spaces// /${blocks}nl}"
[[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}nl}"
else
[[ "$blocks" ]] && cols+="${block_spaces// /${blocks}\[mnl}"
[[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}\[mnl}"
fi
# Determine the horizontal offset of the blocks.
case $col_offset in
@@ -5881,7 +5886,7 @@ ASCII:
BlackArch, blackPanther, BLAG, BlankOn, BlueLight, Bodhi, bonsai,
BSD, BunsenLabs, Cachy OS, Calculate, CalinixOS, Carbs, CBL-Mariner,
CelOS, Center, CentOS, Chakra, ChaletOS, Chapeau, ChonkySealOS,
Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Condres,
Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt, Condres,
Container Linux by CoreOS, CRUX, Crystal Linux, Cucumber,
CutefishOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, DesaOS,
Devuan, DietPi, DracOS, DragonFly, Drauger, Droidian, Elementary,
@@ -5912,16 +5917,16 @@ ASCII:
Trisquel, Twister, Ubuntu, Ubuntu Budgie, Ubuntu Cinnamon, Ubuntu
Kylin, Ubuntu MATE, Ubuntu Studio, Ubuntu Sway, Ubuntu Touch,
Ubuntu-GNOME, ubuntu_old02, Ultramarine Linux, Univalent,
Univention, Uos, uwuntu, Venom, VNux, Void, VzLinux, wii-linux-ngx,
Windows, Windows 10, Windows 11, XFerience, Xubuntu, yiffOS, Zorin
have ascii logos.
Univention, Uos, uwuntu, Vanilla, Venom, VNux, Void, VzLinux, wii-
linux-ngx, Windows, Windows 10, Windows 11, XFerience, Xubuntu,
yiffOS, Zorin have ascii logos.
NOTE: arch, dragonfly, Fedora, LangitKetujuh, nixos, redhat, Ubuntu
have 'old' logo variants, use {distro}_old to use them.
NOTE: alpine, android, aoscosretro, arch, arcolinux, artix,
CalinixOS, centos, cleanjaro, crux, debian, dragonfly, elementary,
fedora, freebsd, gentoo, guix, haiku, hyperbola, linuxlite,
fedora, freebsd, garuda, gentoo, guix, haiku, hyperbola, linuxlite,
linuxmint, mac, mageia, manjaro, mx, netbsd, nixos, openbsd,
opensuse, orchid, parabola, popos, postmarketos, pureos, Raspbian,
rocky, slackware, sunos, ubuntu, void have 'small' logo variants,
@@ -5960,7 +5965,10 @@ OTHER:
--config none Launch the script without a config file
--no_config Don't create the user config file.
--print_config Print the default config file to stdout.
--stdout Turn off all colors and disables any ASCII/image backend.
--stdout=on Turn off all colors and disables any ASCII/image backend.
--stdout=off Enable the colored output and ASCII/image backend
--stdout=auto Let the program decide basing on the output type (default behavior)
--stdout Equivalent to '--stdout=on', for backward compatibility
--help Print this text and exit
--version Show neofetch version
-v Display error messages.
@@ -6158,6 +6166,9 @@ get_args() {
;;
"--no_config") no_config="on" ;;
"--stdout") stdout="on" ;;
"--stdout=on") stdout="on" ;;
"--stdout=off") stdout="off" ;;
"--stdout=auto") stdout="auto" ;;
"-v") verbose="on" ;;
"--print_config") printf '%s\n' "$config"; exit ;;
"-vv") set -x; verbose="on" ;;
@@ -7135,6 +7146,28 @@ ${c1} '
'` `'
EOF
;;
"Cobalt"*)
set_colors 33 33 59 31 8
read -rd '' ascii_data <<'EOF'
${c1} ///
${c1} ,//////////////
${c1} ///////////////////////////////
${c1} ///////////////${c5}***********${c1}//////
////${c5}***********************${c1}/////
/////${c5}***********************${c1}////
//////${c5},,,,,,,,,,,,,,,,,,,,,,${c1}///
//////${c5},,,,,,,,,,,,,,,,,,,,,,,,,${c1}/////
/////${c5},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c1}/////
${c4} *****${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}*****
******${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}*****
*******${c3},,,,,,,,,,,,,,,,,,,,,,,,,${c4}******
*******${c3}......................${c4}*******
******${c3}....${c4}***********************
****************************
*****
EOF
;;
"Arya"*)
set_colors 2 1
@@ -8885,6 +8918,17 @@ o/:-...................................:
EOF
;;
"garuda_small")
set_colors 7 7 3 7 2 4
read -rd '' ascii_data <<'EOF'
${c3} .----.
.' ${c6},${c3} '.
${c4} .' ${c6}'${c3}-----|
'${c5}. -----,
'.____.'
EOF
;;
"Garuda"*)
set_colors 7 7 3 7 2 4
read -rd '' ascii_data <<'EOF'
@@ -13271,6 +13315,32 @@ ${c1} | (-- | |
EOF
;;
"Vanilla"*)
set_colors 11 15
read -rd '' ascii_data <<'EOF'
${c1}
.----:
.-------.
:---::----:
.----::-----.
......... :----::-----: ..:::-::::..
.-----------------::------------------:
----::-----------::----------::::---:
-----:::--------::-------:::-------
:------::::--::...:::::---------:
.---------::.. ..:---------.
.::-----::.. .::----::.
.:------:.......:-------:
.--------::::::::-:::-------.
.-------::-----.:-----::------.
-----::------: :------::-----
:--::--------: .-------::---:
:----------:: .:----------
EOF
;;
"Obarun"*)
set_colors 6 6 7 1
@@ -13669,6 +13739,12 @@ main() {
get_distro
get_bold
get_distro_ascii
# check if the output is a interactive terminal
[[ $stdout == auto ]] && {
[[ -t 1 ]] && stdout=off || stdout=on
}
[[ $stdout == on ]] && stdout
# Minix doesn't support these sequences.
+16 -8
View File
@@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
.TH NEOFETCH "1" "October 2022" "Neofetch 7.3.2" "User Commands"
.TH NEOFETCH "1" "October 2022" "Neofetch 7.3.3" "User Commands"
.SH NAME
Neofetch \- manual page for Neofetch 7.3.2
Neofetch \- manual page for Neofetch 7.3.3
.SH SYNOPSIS
.B neofetch
\fI\,func_name --option "value" --option "value"\/\fR
@@ -308,7 +308,7 @@ Artix, Arya, Asahi, AsteroidOS, astOS, Bedrock, BigLinux, Bitrig,
BlackArch, blackPanther, BLAG, BlankOn, BlueLight, Bodhi, bonsai,
BSD, BunsenLabs, Cachy OS, Calculate, CalinixOS, Carbs, CBL\-Mariner,
CelOS, Center, CentOS, Chakra, ChaletOS, Chapeau, ChonkySealOS,
Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Condres,
Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt, Condres,
Container Linux by CoreOS, CRUX, Crystal Linux, Cucumber,
CutefishOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, DesaOS,
Devuan, DietPi, DracOS, DragonFly, Drauger, Droidian, Elementary,
@@ -339,16 +339,15 @@ Stock Linux, Sulin, SunOS, SwagArch, t2, Tails, TeArch, TorizonCore,
Trisquel, Twister, Ubuntu, Ubuntu Budgie, Ubuntu Cinnamon, Ubuntu
Kylin, Ubuntu MATE, Ubuntu Studio, Ubuntu Sway, Ubuntu Touch,
Ubuntu\-GNOME, ubuntu_old02, Ultramarine Linux, Univalent,
Univention, Uos, uwuntu, Venom, VNux, Void, VzLinux, wii\-linux\-ngx,
Windows, Windows 10, Windows 11, XFerience, Xubuntu, yiffOS, Zorin
have ascii logos.
Univention, Uos, uwuntu, Vanilla, Venom, VNux, Void, VzLinux, wiilinux\-ngx, Windows, Windows 10, Windows 11, XFerience, Xubuntu,
yiffOS, Zorin have ascii logos.
.TP
NOTE: arch, dragonfly, Fedora, LangitKetujuh, nixos, redhat, Ubuntu
have 'old' logo variants, use {distro}_old to use them.
.TP
NOTE: alpine, android, aoscosretro, arch, arcolinux, artix,
CalinixOS, centos, cleanjaro, crux, debian, dragonfly, elementary,
fedora, freebsd, gentoo, guix, haiku, hyperbola, linuxlite,
fedora, freebsd, garuda, gentoo, guix, haiku, hyperbola, linuxlite,
linuxmint, mac, mageia, manjaro, mx, netbsd, nixos, openbsd,
opensuse, orchid, parabola, popos, postmarketos, pureos, Raspbian,
rocky, slackware, sunos, ubuntu, void have 'small' logo variants,
@@ -415,9 +414,18 @@ Don't create the user config file.
\fB\-\-print_config\fR
Print the default config file to stdout.
.TP
\fB\-\-stdout\fR
\fB\-\-stdout\fR=\fI\,on\/\fR
Turn off all colors and disables any ASCII/image backend.
.TP
\fB\-\-stdout\fR=\fI\,off\/\fR
Enable the colored output and ASCII/image backend
.TP
\fB\-\-stdout\fR=\fI\,auto\/\fR
Let the program decide basing on the output type (default behavior)
.TP
\fB\-\-stdout\fR
Equivalent to '\-\-stdout=on', for backward compatibility
.TP
\fB\-\-help\fR
Print this text and exit
.TP
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "neowofetch",
"version": "1.4.2",
"version": "1.4.3",
"description": "Updated neofetch",
"repository": {
"type": "git",