feat(ags): finish migrating v1 to v2

This commit is contained in:
matt1432 2025-02-28 21:56:54 -05:00
parent 7d64a1fe25
commit 2e15e10fd5
24 changed files with 1196 additions and 1026 deletions

File diff suppressed because one or more lines are too long

45
packages/coloryou/coloryou.py Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
"""
The original script:
https://github.com/dharmx/vile/blob/7d486c128c7e553912673755f97b118aaab0193d/src/shell/playerctl.py#L2
"""
import argparse
import json
from material_color_utilities_python import themeFromImage, hexFromArgb, Image
def range_type(value_string):
value = int(value_string)
if value not in range(0, 101):
raise argparse.ArgumentTypeError("%s is out of range, choose in [0-100]" % value)
return value
parser = argparse.ArgumentParser(
prog='coloryou',
description='This program extract Material You colors from an image. It returns them as a JSON object for scripting.')
parser.add_argument("image_path", help="A full path to your image", type=str)
parser.add_argument('-i', '--image', dest='image', default=40, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the main image accent.")
parser.add_argument('-b', '--button', dest='button', default=90, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button accent.")
parser.add_argument('-t', '--text', dest='text', default=10, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button text accent.")
parser.add_argument('-o', '--hover', dest='hover', default=80, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the hovering effect accent.")
args = parser.parse_args()
img = Image.open(args.image_path)
basewidth = 64
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
theme = themeFromImage(img).get("palettes").get("primary")
parsed_colors = {"imageAccent": hexFromArgb(theme.tone(args.image)),
"buttonAccent": hexFromArgb(theme.tone(args.button)),
"buttonText": hexFromArgb(theme.tone(args.text)),
"hoverAccent": hexFromArgb(theme.tone(args.hover))}
print(json.dumps(parsed_colors))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
"""
The original script:
https://github.com/dharmx/vile/blob/7d486c128c7e553912673755f97b118aaab0193d/src/shell/playerctl.py#L2
"""
import argparse
import json
from material_color_utilities_python import themeFromImage, hexFromArgb, Image
def range_type(value_string):
value = int(value_string)
if value not in range(0, 101):
raise argparse.ArgumentTypeError("%s is out of range, choose in [0-100]" % value)
return value
parser = argparse.ArgumentParser(
prog='coloryou',
description='This program extract Material You colors from an image. It returns them as a JSON object for scripting.')
parser.add_argument("image_path", help="A full path to your image", type=str)
parser.add_argument('-i', '--image', dest='image', default=40, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the main image accent.")
parser.add_argument('-b', '--button', dest='button', default=90, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button accent.")
parser.add_argument('-t', '--text', dest='text', default=10, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button text accent.")
parser.add_argument('-o', '--hover', dest='hover', default=80, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the hovering effect accent.")
args = parser.parse_args()
img = Image.open(args.image_path)
basewidth = 64
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
theme = themeFromImage(img).get("palettes").get("primary")
parsed_colors = {"imageAccent": hexFromArgb(theme.tone(args.image)),
"buttonAccent": hexFromArgb(theme.tone(args.button)),
"buttonText": hexFromArgb(theme.tone(args.text)),
"hoverAccent": hexFromArgb(theme.tone(args.hover))}
print(json.dumps(parsed_colors))

View file

@ -0,0 +1,20 @@
{ python3Packages }:
python3Packages.buildPythonPackage rec {
pname = "coloryou";
version = "0.0.1";
src = ./.;
propagatedBuildInputs = with python3Packages; [ utils material-color-utilities ];
postInstall = ''
mv -v $out/bin/coloryou.py $out/bin/coloryou
'';
meta = {
description = ''
Get Material You colors from an image.
'';
};
}

View file

@ -0,0 +1,2 @@
material-color-utilities
utils

View file

@ -0,0 +1,7 @@
from distutils.core import setup
setup(
name='coloryou',
version='0.0.1',
scripts=['coloryou.py',],
)

View file

@ -0,0 +1,8 @@
with import <nixpkgs> {};
with pkgs.python311Packages;
buildPythonPackage rec {
name = "coloryou";
src = ./.;
propagatedBuildInputs = [ material-color-utilities utils ];
}

View file

@ -0,0 +1,20 @@
{ python3Packages }:
python3Packages.buildPythonPackage rec {
pname = "coloryou";
version = "0.0.1";
src = ./.;
propagatedBuildInputs = with python3Packages; [ utils material-color-utilities ];
postInstall = ''
mv -v $out/bin/coloryou.py $out/bin/coloryou
'';
meta = {
description = ''
Get Material You colors from an image.
'';
};
}

View file

@ -0,0 +1,2 @@
material-color-utilities
utils

View file

@ -0,0 +1,7 @@
from distutils.core import setup
setup(
name='coloryou',
version='0.0.1',
scripts=['coloryou.py',],
)

View file

@ -0,0 +1,8 @@
with import <nixpkgs> {};
with pkgs.python311Packages;
buildPythonPackage rec {
name = "coloryou";
src = ./.;
propagatedBuildInputs = [ material-color-utilities utils ];
}