Skip to content

Commit

Permalink
🔗 (#88) Custom Unix cursor packager
Browse files Browse the repository at this point in the history
  • Loading branch information
ful1e5 committed Feb 25, 2021
1 parent 6fbeb96 commit b7b0797
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
11 changes: 6 additions & 5 deletions builder/bbpkg/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

from clickgen.builders import WindowsCursor, XCursor
from clickgen.core import CursorAlias
from clickgen.packagers import WindowsPackager, XPackager
from clickgen.packagers import WindowsPackager

from bbpkg.constants import AUTHOR, URL
from bbpkg.packager import XPackager
from bbpkg.symlinks import add_missing_xcursor


Expand Down Expand Up @@ -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:
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)

add_missing_xcursor(x_out_dir / "cursors")
Expand Down Expand Up @@ -77,7 +78,7 @@ def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path, info: Info) ->
win_cfg = alias.reproduce(
win_size, canvas_size, position, delay=win_delay
).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)

WindowsPackager(win_out_dir, info.name, info.comment, AUTHOR, URL)
Expand Down Expand Up @@ -112,7 +113,7 @@ def win_build(item: Dict[str, Any], alias: CursorAlias) -> None:
win_cfg = alias.reproduce(
win_size, canvas_size, position, delay=win_delay
).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)

for _, item in config.items():
Expand All @@ -123,7 +124,7 @@ def win_build(item: Dict[str, Any], alias: CursorAlias) -> None:

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)

if item.get("win_key"):
Expand Down
26 changes: 26 additions & 0 deletions builder/bbpkg/packager.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion builder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
x_out_dir = Path(args.out_dir) / name
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(
bitmaps_dir,
Expand Down

0 comments on commit b7b0797

Please sign in to comment.