mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-17 16:44:59 -04:00
commit
a7bb7bf3f0
7 changed files with 90 additions and 118 deletions
|
@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Setup target updated inside `builder/Makefile`
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `applbuild` modules relative imports
|
||||||
|
- Removed `setup.py` from `builder/`
|
||||||
|
|
||||||
## [1.1.4] - 4 Apr 2021
|
## [1.1.4] - 4 Apr 2021
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -18,7 +18,6 @@ windows: clean render bitmaps
|
||||||
@cd builder && make build_windows && make clean
|
@cd builder && make build_windows && make clean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
theme := macOSBigSur
|
theme := macOSBigSur
|
||||||
src := ./themes/$(theme)
|
src := ./themes/$(theme)
|
||||||
|
|
|
@ -9,17 +9,12 @@ WIN_CANVAS_SIZE ?= 32
|
||||||
WIN_SIZE ?= 24
|
WIN_SIZE ?= 24
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf applbuild.egg-info build dist
|
@python3 -m pip uninstall -y clickgen
|
||||||
@find -iname "*.pyc" -delete
|
@find -iname "*.pyc" -delete
|
||||||
|
@rm -rf applbuild/__pycache__
|
||||||
|
|
||||||
# Removing setup.py package files if installed
|
setup: clean
|
||||||
@if [ -f "files.txt" ]; then
|
@python3 -m pip install clickgen==1.1.9 --user
|
||||||
@xargs rm -rf < files.txt
|
|
||||||
@rm -rf files.txt
|
|
||||||
@fi
|
|
||||||
|
|
||||||
setup: clean setup.py
|
|
||||||
@python3 setup.py install --user --record files.txt
|
|
||||||
|
|
||||||
build: setup build.py
|
build: setup build.py
|
||||||
@python3 build.py --xsizes $(X_SIZES) --win-size $(WIN_SIZE) --win-canvas-size $(WIN_CANVAS_SIZE)
|
@python3 build.py --xsizes $(X_SIZES) --win-size $(WIN_SIZE) --win-canvas-size $(WIN_CANVAS_SIZE)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pathlib import Path
|
from typing import Any, Dict, Tuple, TypeVar
|
||||||
from typing import Any, Dict, Tuple, TypeVar, Union
|
|
||||||
|
|
||||||
from applbuild.constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
|
|
||||||
from clickgen.util import PNGProvider
|
from clickgen.util import PNGProvider
|
||||||
|
|
||||||
|
from .constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
|
||||||
|
|
||||||
X = TypeVar("X")
|
X = TypeVar("X")
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,29 +14,31 @@ def to_tuple(x: X) -> Tuple[X, X]:
|
||||||
return (x, x)
|
return (x, x)
|
||||||
|
|
||||||
|
|
||||||
def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
|
def get_config(bitmaps_dir, **kwargs) -> Dict[str, Any]:
|
||||||
"""Return configuration of `macOSBigSur` pointers.
|
"""Return configuration of `GoogleDot` pointers.
|
||||||
|
|
||||||
:param bitmaps_dir: Path to .png file's directory.
|
:param bitmaps_dir: Path to .png file's directory.
|
||||||
:type bitmaps_dir: Union[str, Path]
|
:type bitmaps_dir: ``str`` or ``pathlib.Path``
|
||||||
|
|
||||||
:param x_sizes: List of pixel-sizes for xcursors.
|
:param **kwargs:
|
||||||
:type x_sizes: List[int]
|
See below
|
||||||
|
|
||||||
:param win_canvas_size: Windows cursor's canvas pixel-size.
|
:Keyword Arguments:
|
||||||
:type win_canvas_size: int
|
* *x_sizes* (``List[int]``) --
|
||||||
|
List of pixel-sizes for xcursors.
|
||||||
:param win_size: Pixel-size for Windows cursor.
|
* *win_canvas_size* (``int``) --
|
||||||
:type win_size: int
|
Windows cursor's canvas pixel-size.
|
||||||
|
* *win_size* (``int``) --
|
||||||
|
Pixel-size for Windows cursor.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
get_config(
|
get_config(
|
||||||
"./bitmaps",
|
bitmaps_dir="./bitmaps",
|
||||||
x_sizes=[(24, 24), (32, 32)],
|
x_sizes=[24, 28, 32],
|
||||||
win_canvas_size=(32, 32),
|
win_canvas_size=32,
|
||||||
win_size=(24, 24),
|
win_size=24,
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
@ -49,6 +51,7 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
|
||||||
for size in raw_x_sizes:
|
for size in raw_x_sizes:
|
||||||
x_sizes.append(to_tuple(size))
|
x_sizes.append(to_tuple(size))
|
||||||
|
|
||||||
|
png_provider = PNGProvider(bitmaps_dir)
|
||||||
config: Dict[str, Any] = {}
|
config: Dict[str, Any] = {}
|
||||||
|
|
||||||
for key, item in X_CURSORS_CFG.items():
|
for key, item in X_CURSORS_CFG.items():
|
||||||
|
@ -57,13 +60,12 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
|
||||||
hotspot: Tuple[int, int] = (x_hot, y_hot)
|
hotspot: Tuple[int, int] = (x_hot, y_hot)
|
||||||
|
|
||||||
delay: int = int(item.get("delay", X_DELAY))
|
delay: int = int(item.get("delay", X_DELAY))
|
||||||
pngs = PNGProvider(bitmaps_dir).get(key)
|
png = png_provider.get(key)
|
||||||
|
if not png:
|
||||||
if not pngs:
|
raise FileNotFoundError(f"{key} not found")
|
||||||
raise FileNotFoundError(f"{key} not found in {bitmaps_dir}")
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"png": pngs,
|
"png": png,
|
||||||
"x_sizes": x_sizes,
|
"x_sizes": x_sizes,
|
||||||
"hotspot": hotspot,
|
"hotspot": hotspot,
|
||||||
"delay": delay,
|
"delay": delay,
|
||||||
|
@ -94,7 +96,6 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
|
||||||
"win_size": win_size,
|
"win_size": win_size,
|
||||||
"win_delay": win_delay,
|
"win_delay": win_delay,
|
||||||
}
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
config[key] = data
|
config[key] = data
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,38 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""This module provides build methods for ``macOSBigSur``."""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from applbuild.constants import AUTHOR, COMMENT, THEME_NAME, URL
|
|
||||||
from applbuild.symlinks import add_missing_xcursor
|
|
||||||
from clickgen.builders import WindowsCursor, XCursor
|
from clickgen.builders import WindowsCursor, XCursor
|
||||||
from clickgen.core import CursorAlias
|
from clickgen.core import CursorAlias
|
||||||
from clickgen.packagers import WindowsPackager, XPackager
|
from clickgen.packagers import WindowsPackager, XPackager
|
||||||
|
|
||||||
|
from .constants import AUTHOR, COMMENT, THEME_NAME, URL
|
||||||
|
from .symlinks import add_missing_xcursor
|
||||||
|
|
||||||
def xbuild(
|
|
||||||
config: Dict[str, Dict[str, Any]],
|
def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path) -> None:
|
||||||
x_out_dir: Path,
|
|
||||||
) -> None:
|
|
||||||
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.
|
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.
|
||||||
|
|
||||||
:param config: `macOSBigSur` configuration.
|
:param config: `macOSBigSur` configuration.
|
||||||
:type config: Dict[str, Dict[str, Any]]
|
:type config: Dict
|
||||||
|
|
||||||
:param x_out_dir: Path to the output directory, \
|
:param x_out_dir: Path to the output directory,\
|
||||||
Where the `X11` cursor theme package will\
|
Where the `X11` cursor theme package will generate.\
|
||||||
generate. It also creates a directory if not exists.
|
It also creates a directory if not exists.
|
||||||
:type x_out_dir: Path
|
:type x_out_dir: Path
|
||||||
|
|
||||||
|
:param info: Content theme name & comment
|
||||||
|
:type info: Info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for _, item in config.items():
|
for _, item in config.items():
|
||||||
png = item["png"]
|
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||||
hotspot = item["hotspot"]
|
x_cfg = alias.create(item["x_sizes"], item["delay"])
|
||||||
x_sizes = item["x_sizes"]
|
|
||||||
delay = item["delay"]
|
|
||||||
|
|
||||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
|
||||||
x_cfg = alias.create(x_sizes, delay)
|
|
||||||
print(f"Building '{x_cfg.stem}' XCursor...")
|
print(f"Building '{x_cfg.stem}' XCursor...")
|
||||||
XCursor.create(x_cfg, x_out_dir)
|
XCursor.create(x_cfg, x_out_dir)
|
||||||
|
|
||||||
|
@ -45,33 +44,29 @@ def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path) -> None:
|
||||||
"""Build `macOSBigSur` cursor theme for only `Windows` platforms.
|
"""Build `macOSBigSur` cursor theme for only `Windows` platforms.
|
||||||
|
|
||||||
:param config: `macOSBigSur` configuration.
|
:param config: `macOSBigSur` configuration.
|
||||||
:type config: Dict[str, Dict[str, Any]]
|
:type config: Dict
|
||||||
|
|
||||||
:param win_out_dir: Path to the output directory, \
|
:param win_out_dir: Path to the output directory,\
|
||||||
Where the `Windows` cursor theme package will\
|
Where the `Windows` cursor theme package will generate.\
|
||||||
generate. It also creates a directory if not exists.
|
It also creates a directory if not exists.
|
||||||
:type win_out_dir: Path
|
:type win_out_dir: Path
|
||||||
|
|
||||||
|
:param info: Content theme name & comment
|
||||||
|
:type info: Info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for _, item in config.items():
|
for _, item in config.items():
|
||||||
png = item["png"]
|
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||||
hotspot = item["hotspot"]
|
alias.create(item["x_sizes"], item["delay"])
|
||||||
x_sizes = item["x_sizes"]
|
|
||||||
delay = item["delay"]
|
|
||||||
|
|
||||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
|
||||||
alias.create(x_sizes, delay)
|
|
||||||
|
|
||||||
if item.get("win_key"):
|
if item.get("win_key"):
|
||||||
position = item["position"]
|
|
||||||
win_size = item["win_size"]
|
|
||||||
win_key = item["win_key"]
|
|
||||||
canvas_size = item["canvas_size"]
|
|
||||||
win_delay = item["win_delay"]
|
|
||||||
|
|
||||||
win_cfg = alias.reproduce(
|
win_cfg = alias.reproduce(
|
||||||
win_size, canvas_size, position, delay=win_delay
|
size=item["win_size"],
|
||||||
).rename(win_key)
|
canvas_size=item["canvas_size"],
|
||||||
|
position=item["position"],
|
||||||
|
delay=item["win_delay"],
|
||||||
|
).rename(item["win_key"])
|
||||||
|
|
||||||
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
||||||
WindowsCursor.create(win_cfg, win_out_dir)
|
WindowsCursor.create(win_cfg, win_out_dir)
|
||||||
|
|
||||||
|
@ -84,45 +79,40 @@ def build(
|
||||||
"""Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms.
|
"""Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms.
|
||||||
|
|
||||||
:param config: `macOSBigSur` configuration.
|
:param config: `macOSBigSur` configuration.
|
||||||
:type config: Dict[str, Dict[str, Any]]
|
:type config: Dict
|
||||||
|
|
||||||
:param x_out_dir: Path to the output directory, \
|
:param x_out_dir: Path to the output directory,\
|
||||||
Where the `X11` cursor theme package will\
|
Where the `X11` cursor theme package will generate.\
|
||||||
generate. It also creates a directory if not exists.
|
It also creates a directory if not exists.
|
||||||
:type x_out_dir: Path
|
:type x_out_dir: Path
|
||||||
|
|
||||||
:param win_out_dir: Path to the output directory, \
|
:param win_out_dir: Path to the output directory,\
|
||||||
Where the `Windows` cursor theme package will\
|
Where the `Windows` cursor theme package will generate.\
|
||||||
generate. It also creates a directory if not exists.
|
It also creates a directory if not exists.
|
||||||
:type win_out_dir: Path
|
:type win_out_dir: Path
|
||||||
|
|
||||||
|
:param info: Content theme name & comment
|
||||||
|
:type info: Info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def win_build(item: Dict[str, Any], alias: CursorAlias) -> None:
|
|
||||||
position = item["position"]
|
|
||||||
win_size = item["win_size"]
|
|
||||||
win_key = item["win_key"]
|
|
||||||
canvas_size = item["canvas_size"]
|
|
||||||
win_delay = item["win_delay"]
|
|
||||||
|
|
||||||
win_cfg = alias.reproduce(
|
|
||||||
win_size, canvas_size, position, delay=win_delay
|
|
||||||
).rename(win_key)
|
|
||||||
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
|
||||||
WindowsCursor.create(win_cfg, win_out_dir)
|
|
||||||
|
|
||||||
for _, item in config.items():
|
for _, item in config.items():
|
||||||
png = item["png"]
|
|
||||||
hotspot = item["hotspot"]
|
|
||||||
x_sizes = item["x_sizes"]
|
|
||||||
delay = item["delay"]
|
|
||||||
|
|
||||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||||
x_cfg = alias.create(x_sizes, delay)
|
x_cfg = alias.create(item["x_sizes"], item["delay"])
|
||||||
|
|
||||||
print(f"Building '{x_cfg.stem}' XCursor...")
|
print(f"Building '{x_cfg.stem}' XCursor...")
|
||||||
XCursor.create(x_cfg, x_out_dir)
|
XCursor.create(x_cfg, x_out_dir)
|
||||||
|
|
||||||
if item.get("win_key"):
|
if item.get("win_key"):
|
||||||
win_build(item, alias)
|
win_cfg = alias.reproduce(
|
||||||
|
size=item["win_size"],
|
||||||
|
canvas_size=item["canvas_size"],
|
||||||
|
position=item["position"],
|
||||||
|
delay=item["win_delay"],
|
||||||
|
).rename(item["win_key"])
|
||||||
|
|
||||||
|
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
||||||
|
WindowsCursor.create(win_cfg, win_out_dir)
|
||||||
|
|
||||||
add_missing_xcursor(x_out_dir / "cursors")
|
add_missing_xcursor(x_out_dir / "cursors")
|
||||||
XPackager(x_out_dir, THEME_NAME, COMMENT)
|
XPackager(x_out_dir, THEME_NAME, COMMENT)
|
||||||
|
|
|
@ -12,7 +12,7 @@ def add_missing_xcursor(directory: Union[str, Path]) -> None:
|
||||||
"""Add missing `XCursor` to the Unix cursor package.
|
"""Add missing `XCursor` to the Unix cursor package.
|
||||||
|
|
||||||
:param directory: directory where XCursors are available.
|
:param directory: directory where XCursors are available.
|
||||||
:type directory: Union[str, Path]
|
:type directory: ``str`` or ``pathlib.Path``
|
||||||
"""
|
"""
|
||||||
|
|
||||||
symlinks: List[Dict[str, Union[str, List[str]]]] = [
|
symlinks: List[Dict[str, Union[str, List[str]]]] = [
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from setuptools import setup
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="applbuild",
|
|
||||||
version="1.1.4",
|
|
||||||
description="Generate 'macOSBigSur' cursor theme from PNGs file",
|
|
||||||
url="https://github.com/ful1e5/apple_cursor",
|
|
||||||
packages=["applbuild"],
|
|
||||||
package_dir={"applbuild": "applbuild"},
|
|
||||||
author="Kaiz Khatri",
|
|
||||||
author_email="kaizmandhu@gamil.com",
|
|
||||||
install_requires=["clickgen==1.1.9"],
|
|
||||||
classifiers=[
|
|
||||||
"Programming Language :: Python :: 3",
|
|
||||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
||||||
],
|
|
||||||
python_requires=">=3.8",
|
|
||||||
zip_safe=True,
|
|
||||||
)
|
|
Loading…
Add table
Add a link
Reference in a new issue