mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-22 11:15:17 -04:00
🔗 (#88) Custom Unix cursor packager
This commit is contained in:
parent
6fbeb96ae6
commit
b7b0797458
3 changed files with 33 additions and 6 deletions
|
@ -6,9 +6,10 @@ from typing import Any, Dict, NamedTuple
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
from bbpkg.constants import AUTHOR, URL
|
from bbpkg.constants import AUTHOR, URL
|
||||||
|
from bbpkg.packager import XPackager
|
||||||
from bbpkg.symlinks import add_missing_xcursor
|
from bbpkg.symlinks import add_missing_xcursor
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path, info: Info) -> No
|
||||||
|
|
||||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||||
x_cfg = alias.create(x_sizes, delay)
|
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)
|
||||||
|
|
||||||
add_missing_xcursor(x_out_dir / "cursors")
|
add_missing_xcursor(x_out_dir / "cursors")
|
||||||
|
@ -77,7 +78,7 @@ def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path, info: Info) ->
|
||||||
win_cfg = alias.reproduce(
|
win_cfg = alias.reproduce(
|
||||||
win_size, canvas_size, position, delay=win_delay
|
win_size, canvas_size, position, delay=win_delay
|
||||||
).rename(win_key)
|
).rename(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)
|
||||||
|
|
||||||
WindowsPackager(win_out_dir, info.name, info.comment, AUTHOR, URL)
|
WindowsPackager(win_out_dir, info.name, info.comment, AUTHOR, URL)
|
||||||
|
@ -112,7 +113,7 @@ def build(
|
||||||
win_cfg = alias.reproduce(
|
win_cfg = alias.reproduce(
|
||||||
win_size, canvas_size, position, delay=win_delay
|
win_size, canvas_size, position, delay=win_delay
|
||||||
).rename(win_key)
|
).rename(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)
|
||||||
|
|
||||||
for _, item in config.items():
|
for _, item in config.items():
|
||||||
|
@ -123,7 +124,7 @@ def build(
|
||||||
|
|
||||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||||
x_cfg = alias.create(x_sizes, delay)
|
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)
|
||||||
|
|
||||||
if item.get("win_key"):
|
if item.get("win_key"):
|
||||||
|
|
26
builder/bbpkg/packager.py
Normal file
26
builder/bbpkg/packager.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from string import Template
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
THEME_FILES_TEMPLATES: Dict[str, Template] = {
|
||||||
|
"cursor.theme": Template("[Icon Theme]\nName=$theme_name\nInherits=$theme_name"),
|
||||||
|
"index.theme": Template(
|
||||||
|
'[Icon Theme]\nName=$theme_name\nComment=$comment\nInherits="hicolor"'
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def XPackager(directory: Path, theme_name: str, comment: str) -> None:
|
||||||
|
""" Create a crispy `XCursors` theme package. """
|
||||||
|
|
||||||
|
# Writing all .theme files
|
||||||
|
files: Dict[str, str] = {}
|
||||||
|
for file, template in THEME_FILES_TEMPLATES.items():
|
||||||
|
files[file] = template.safe_substitute(theme_name=theme_name, comment=comment)
|
||||||
|
|
||||||
|
for f, data in files.items():
|
||||||
|
fp: Path = directory / f
|
||||||
|
fp.write_text(data)
|
|
@ -109,7 +109,7 @@ comments = {
|
||||||
x_out_dir = Path(args.out_dir) / name
|
x_out_dir = Path(args.out_dir) / name
|
||||||
win_out_dir = Path(args.out_dir) / f"{name}-Windows"
|
win_out_dir = Path(args.out_dir) / f"{name}-Windows"
|
||||||
|
|
||||||
print(f"=> Creating {name}")
|
print(f"Getting '{name}' bitmaps ready for build...")
|
||||||
|
|
||||||
config = get_config(
|
config = get_config(
|
||||||
bitmaps_dir,
|
bitmaps_dir,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue