nvidia😡

This commit is contained in:
2025-08-08 17:20:56 +02:00
parent 572a00828b
commit f28222614e
13 changed files with 125 additions and 68 deletions

View File

@@ -40,6 +40,7 @@ import shutil
import argparse
from typing import Callable
FLAVOR_NAME_PLACEHOLDER = "<FLAVOR_NAME>"
FLAVOR_HEX_PLACEHOLDER = "<FLAVOR_HEX>"
@@ -105,6 +106,10 @@ def copy_template(src: Path, dist_dir: Path | None) -> Path:
return dist
def hex2rgb(hex_color: str) -> tuple[int, int, int]:
return tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4)) # type: ignore
def _change_kvantum(_, flavor):
os.system(f'kvantummanager --set catppuccin-mocha-{flavor}')
# execute twice to ensure the theme is installed AND applied
@@ -208,7 +213,7 @@ apply_theme_funcs: dict[str, Callable[[dict[str, str], str], None]] = {
'hypr': _change_hypr,
'rofi': _change_rofi,
'waybar': _change_waybar,
'oh-myposh': _change_ohmyposh,
'oh-my-posh': _change_ohmyposh,
'fastfetch': _change_fastfetch,
'mako': _change_mako,
'yazi': _change_yazi,
@@ -229,9 +234,6 @@ def match_color(color: str, palette: dict[str, str]) -> str:
color = color.lower().strip().removeprefix('#')
def hex2rgb(hex_color: str) -> tuple[int, int, int]:
return tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4)) # type: ignore
# weigh by CCIR 601 luminosity
fr, fg, fb = 0.299 / 255 / 255, 0.587 / 255 / 255, 0.114 / 255 / 255
lfr, lfg, lfb = 0.299 / 255, 0.587 / 255, 0.114 / 255
@@ -282,6 +284,39 @@ def match_color(color: str, palette: dict[str, str]) -> str:
return closest_color
def pick_flavor(palette: dict[str, str]) -> str:
def is_interactive() -> bool:
return sys.stdin.isatty() and sys.stdout.isatty()
def is_truecolor() -> bool:
colorterm = os.environ.get('COLORTERM', '')
term = os.environ.get('TERM', '')
return (
'truecolor' in colorterm or
'24bit' in colorterm or
term.endswith('-256color')
)
if is_interactive():
isTruecolor = is_truecolor()
print("Available flavors:")
for i, flavor in enumerate(palette.keys(), 1):
r, g, b = hex2rgb(palette[flavor])
if isTruecolor:
print(f"\033[38;2;{r};{g};{b}m█ {i}. {flavor}: #{palette[flavor]}\033[0m")
else:
print(f"{i}. {flavor}")
while True:
choice = input("Pick a flavor by number: ")
if choice.isdigit() and 1 <= int(choice) <= len(palette):
return list(palette.keys())[int(choice) - 1]
print("Invalid choice. Try again.")
else:
print("No flavor specified.")
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Change color theme for various applications.")
parser.add_argument('-i', '--image', type=str, help="Path to the image")
@@ -313,8 +348,7 @@ def main():
flavor = match_color(color, palette)
print(f"Extracted color: {flavor}")
else:
import random
flavor = random.choice(list(palette.keys()))
flavor = pick_flavor(palette)
return flavor
def parse_apps() -> list[str]:

View File

@@ -1,29 +0,0 @@
#!/bin/fish
# if the path is given as an argument, use that
if test (count $argv) -eq 1
set image $argv[1]
else
set image (zenity --file-selection --title="Open File" --file-filter="*.jpg *.jpeg *.png")
end
if test -z "$image"
exit 1
end
if not test -f "$image"
notify-send "Error" "Selected file does not exist."
exit 1
end
if string match -q "* *" "$image"
notify-send "Error" "The path of selected file contains white spaces, please select a file without white spaces."
exit 1
end
hyprctl hyprpaper reload ,"$image"
echo "preload = $image" > ~/.config/hypr/hyprpaper.conf
echo "wallpaper = , $image" >> ~/.config/hypr/hyprpaper.conf
notify-send "Wallpaper Changed" "$image"
notify-send "Extracting colors from wallpaper" "This may take a few seconds..."
change-colortheme.py -i "$image"

23
.scripts/change-wallpaper.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/env bash
if [ -z "$1" ]; then
image=$(zenity --file-selection --title="Open File" --file-filter="*.jpg *.jpeg *.png *.webp *.bmp *.jfif *.tiff *.avif *.heic *.heif")
else
image="$1"
fi
[ -z "$image" ] && exit 1
ext=${image##*.}
image_copied="$HOME/.config/hypr/wallpaper.$ext"
cp -f "$image" "$image_copied" || exit 1
hyprctl hyprpaper reload ,"$image_copied" || exit 1
echo "preload = $image_copied" >"$HOME/.config/hypr/hyprpaper.conf"
echo "wallpaper = , $image_copied" >>"$HOME/.config/hypr/hyprpaper.conf"
notify-send "Wallpaper Changed" "$image"
notify-send "Extracting colors from wallpaper" "This may take a few seconds..."
change-colortheme.py -i "$image_copied" || exit 1