mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-29 06:15:24 -04:00
😔 Old builder package removed
Builder is responsible for building the cursors from png files, That's stored in <root>/bitmaps' directory. As clickgen(v1.1.8) is build cursors individually, Bibata builder need to be improved.
This commit is contained in:
parent
d3234e6114
commit
f819ff2e00
10 changed files with 0 additions and 473 deletions
71
build.py
71
build.py
|
@ -1,71 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from argparse import ArgumentParser
|
||||
from os import path, listdir
|
||||
from typing import List
|
||||
|
||||
from builder.pkg_info import info
|
||||
from builder.config import ConfigProvider
|
||||
from builder.cursor import CursorBuilder
|
||||
|
||||
|
||||
def get_args_parser() -> ArgumentParser:
|
||||
"""Parse command line arguments"""
|
||||
parser = argparse.ArgumentParser(description=info["description"])
|
||||
|
||||
parser.add_argument(
|
||||
"-x",
|
||||
"--x11",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help=("Bundle X11 cursors from bitmaps" " (default: %(default)s)"),
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-w",
|
||||
"--windows",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help=("Bundle Windows cursors from bitmaps" " (default: %(default)s)"),
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def build() -> None:
|
||||
""" Build Bibata cursor """
|
||||
parser = get_args_parser()
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
except Exception:
|
||||
sys.exit(0)
|
||||
|
||||
bitmaps_dir = "./bitmaps"
|
||||
out_dir = "./themes"
|
||||
|
||||
# print builder information
|
||||
print(info["description"])
|
||||
|
||||
bitmaps_dirs = listdir(bitmaps_dir)
|
||||
configs: List[ConfigProvider] = []
|
||||
builders: List[CursorBuilder] = []
|
||||
|
||||
for index, name in enumerate(bitmaps_dirs):
|
||||
theme_bitmaps_dir = path.join(bitmaps_dir, name)
|
||||
configs.append(ConfigProvider(name, theme_bitmaps_dir, out_dir))
|
||||
builders.append(CursorBuilder(configs[index]))
|
||||
|
||||
for builder in builders:
|
||||
if args.x11 == args.windows:
|
||||
builder.build_cursors()
|
||||
elif args.x11:
|
||||
builder.build_x11_cursors()
|
||||
elif args.windows:
|
||||
builder.build_win_cursors()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
build()
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .log import save_logs_to_file
|
||||
|
||||
save_logs_to_file()
|
|
@ -1,80 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import shutil
|
||||
from os import listdir, path, remove, rename
|
||||
|
||||
from .config import ConfigProvider
|
||||
|
||||
# Windows Cursors Config
|
||||
windows_cursors = {
|
||||
"left_ptr_watch.ani": "AppStarting.ani",
|
||||
"left_ptr.cur": "Arrow.cur",
|
||||
"crosshair.cur": "Cross.cur",
|
||||
"hand2.cur": "Hand.cur",
|
||||
"pencil.cur": "Handwriting.cur",
|
||||
"dnd-ask.cur": "Help.cur",
|
||||
"xterm.cur": "IBeam.cur",
|
||||
"circle.cur": "NO.cur",
|
||||
"all-scroll.cur": "SizeAll.cur",
|
||||
"bd_double_arrow.cur": "SizeNWSE.cur",
|
||||
"sb_v_double_arrow.cur": "SizeNS.cur",
|
||||
"fd_double_arrow.cur": "SizeNESW.cur",
|
||||
"sb_h_double_arrow.cur": "SizeWE.cur",
|
||||
"right_ptr.cur": "Alternate.cur",
|
||||
"wait.ani": "Wait.ani",
|
||||
}
|
||||
|
||||
|
||||
class Bundler:
|
||||
"""
|
||||
Create crisp package for Bibata Windows & X11 packages 📦.
|
||||
"""
|
||||
|
||||
def __init__(self, config: ConfigProvider) -> None:
|
||||
self.__name = config.name
|
||||
self.__tmpdir = config.tmpdir
|
||||
self.__x11_dest = path.join(config.out_dir, self.__name)
|
||||
self.__win_dest = path.join(config.out_dir, self.__name + "-Windows")
|
||||
self.__content = config.get_windows_script()
|
||||
|
||||
def __save_win_install_script(self) -> None:
|
||||
""" Save `install.inf` file in windows cursor theme. """
|
||||
file_path = path.join(self.__win_dest, "install.inf")
|
||||
with open(file_path, "w") as file:
|
||||
file.write(self.__content)
|
||||
|
||||
def __clean_win_bundle(self) -> None:
|
||||
""" Remvoe unnecessary cursor from directory generated by `clickgen` """
|
||||
# Remove & Rename cursors
|
||||
# If Key found => Rename else Remove
|
||||
for cursor in listdir(self.__win_dest):
|
||||
old_path = path.join(self.__win_dest, cursor)
|
||||
|
||||
try:
|
||||
new_path = path.join(self.__win_dest, windows_cursors[cursor])
|
||||
rename(old_path, new_path)
|
||||
except KeyError:
|
||||
remove(old_path)
|
||||
|
||||
self.__save_win_install_script()
|
||||
|
||||
def win_bundle(self) -> None:
|
||||
""" Make cursor theme installable on `Windows OS`. """
|
||||
src = path.join(self.__tmpdir, self.__name, "win")
|
||||
shutil.copytree(src, self.__win_dest)
|
||||
self.__clean_win_bundle()
|
||||
|
||||
def x11_bundle(self) -> None:
|
||||
""" Make cursor theme installable on `x11`. """
|
||||
src = path.join(self.__tmpdir, self.__name, "x11")
|
||||
shutil.copytree(src, self.__x11_dest, symlinks=True)
|
||||
|
||||
def bundle(self) -> None:
|
||||
""" Make cursor theme installable on `x11` & `Windows OS`. """
|
||||
x11_src = path.join(self.__tmpdir, self.__name, "x11")
|
||||
shutil.copytree(x11_src, self.__x11_dest, symlinks=True)
|
||||
|
||||
win_src = path.join(self.__tmpdir, self.__name, "win")
|
||||
shutil.copytree(win_src, self.__win_dest)
|
||||
self.__clean_win_bundle()
|
|
@ -1,54 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
from os import mkdir, path
|
||||
|
||||
from . import __path__
|
||||
from .pkg_info import info
|
||||
|
||||
# Build Config
|
||||
delay = 35
|
||||
sizes = [22, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96]
|
||||
|
||||
# read hotspots file
|
||||
with open(path.join(__path__[0], "hotspots.json")) as hotspot_file:
|
||||
hotspots = json.loads(hotspot_file.read())
|
||||
|
||||
|
||||
class ConfigProvider:
|
||||
"""
|
||||
Configure `Bibata` building process 🔧.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str, bitmaps_dir: str, out_dir: str) -> None:
|
||||
# cleanup old packages
|
||||
if path.exists(out_dir):
|
||||
shutil.rmtree(out_dir)
|
||||
|
||||
mkdir(out_dir)
|
||||
|
||||
# Checking Bitmaps directory
|
||||
if not path.exists(bitmaps_dir):
|
||||
print(
|
||||
"⚠ BITMAPS NOT FOUND.\n\n`yarn install && yarn render` to Generates Bitmaps"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
self.name: str = name
|
||||
self.bitmaps_dir: str = path.abspath(bitmaps_dir)
|
||||
self.tmpdir: str = tempfile.mkdtemp()
|
||||
self.out_dir: str = path.abspath(out_dir)
|
||||
|
||||
def get_windows_script(self) -> str:
|
||||
""" Get `install.inf` content for this cursor theme. """
|
||||
with open(path.join(__path__[0], "windows.inf")) as f:
|
||||
data = f.read()
|
||||
inf_content = data.replace(
|
||||
"<inject_theme_name>", self.name + " Cursors"
|
||||
).replace("<inject_author_name>", info["author"])
|
||||
|
||||
return inf_content
|
|
@ -1,64 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from clickgen import build_cursor_theme, build_win_cursor_theme, build_x11_cursor_theme
|
||||
|
||||
from .bundler import Bundler
|
||||
from .config import ConfigProvider, delay, hotspots, sizes
|
||||
|
||||
|
||||
class CursorBuilder:
|
||||
"""
|
||||
Build Bibata Windows & X11 cursors 🚀.
|
||||
"""
|
||||
|
||||
def __init__(self, config: ConfigProvider) -> None:
|
||||
self.__name = config.name
|
||||
self.__bitmaps_dir = config.bitmaps_dir
|
||||
self.__bundler = Bundler(config)
|
||||
self.__tmpdir = config.tmpdir
|
||||
|
||||
def build_x11_cursors(self) -> None:
|
||||
""" Build `x11` platform cursors. """
|
||||
print("🌈 Building %s Theme ..." % self.__name)
|
||||
build_x11_cursor_theme(
|
||||
name=self.__name,
|
||||
image_dir=self.__bitmaps_dir,
|
||||
cursor_sizes=sizes,
|
||||
hotspots=hotspots,
|
||||
out_path=self.__tmpdir,
|
||||
archive=False,
|
||||
delay=delay,
|
||||
)
|
||||
|
||||
self.__bundler.x11_bundle()
|
||||
|
||||
def build_win_cursors(self) -> None:
|
||||
""" Build `Windows` platform cursors. """
|
||||
print("🌈 Building %s Theme ..." % self.__name)
|
||||
build_win_cursor_theme(
|
||||
name=self.__name,
|
||||
image_dir=self.__bitmaps_dir,
|
||||
cursor_sizes=sizes,
|
||||
hotspots=hotspots,
|
||||
out_path=self.__tmpdir,
|
||||
archive=False,
|
||||
delay=delay,
|
||||
)
|
||||
|
||||
self.__bundler.win_bundle()
|
||||
|
||||
def build_cursors(self) -> None:
|
||||
""" Build `x11` & `Windows` platform cursors. """
|
||||
print("🌈 Building %s Theme ..." % self.__name)
|
||||
build_cursor_theme(
|
||||
name=self.__name,
|
||||
image_dir=self.__bitmaps_dir,
|
||||
cursor_sizes=sizes,
|
||||
hotspots=hotspots,
|
||||
out_path=self.__tmpdir,
|
||||
archive=False,
|
||||
delay=delay,
|
||||
)
|
||||
|
||||
self.__bundler.bundle()
|
|
@ -1,99 +0,0 @@
|
|||
{
|
||||
"all_scroll": { "xhot": 100, "yhot": 100 },
|
||||
"dotbox": { "xhot": 100, "yhot": 100 },
|
||||
"move": { "xhot": 100, "yhot": 100 },
|
||||
"plus": { "xhot": 100, "yhot": 100 },
|
||||
"vertical_text": { "xhot": 100, "yhot": 100 },
|
||||
"wait": { "xhot": 100, "yhot": 100 },
|
||||
"wayland_cursor": { "xhot": 100, "yhot": 100 },
|
||||
"x_cursor": { "xhot": 100, "yhot": 100 },
|
||||
"xterm": { "xhot": 100, "yhot": 100 },
|
||||
|
||||
"bd_double_arrow": { "xhot": 98, "yhot": 100 },
|
||||
"fd_double_arrow": { "xhot": 98, "yhot": 100 },
|
||||
|
||||
"bottom_left_corner": { "xhot": 31, "yhot": 172 },
|
||||
"bottom_right_corner": { "xhot": 170, "yhot": 172 },
|
||||
|
||||
"bottom_side": { "xhot": 100, "yhot": 164 },
|
||||
"bottom_tee": { "xhot": 100, "yhot": 164 },
|
||||
|
||||
"center_ptr": { "xhot": 98, "yhot": 131 },
|
||||
|
||||
"circle": { "xhot": 48, "yhot": 25 },
|
||||
"context_menu": { "xhot": 48, "yhot": 25 },
|
||||
"copy": { "xhot": 48, "yhot": 25 },
|
||||
"link": { "xhot": 48, "yhot": 25 },
|
||||
"pointer_move": { "xhot": 48, "yhot": 25 },
|
||||
|
||||
"cross": { "xhot": 98, "yhot": 96 },
|
||||
|
||||
"crossed_circle": { "xhot": 100, "yhot": 100 },
|
||||
|
||||
"crosshair": { "xhot": 99, "yhot": 99 },
|
||||
|
||||
"dnd_ask": { "xhot": 86, "yhot": 79 },
|
||||
"dnd_copy": { "xhot": 86, "yhot": 79 },
|
||||
"dnd_link": { "xhot": 86, "yhot": 79 },
|
||||
"dnd_move": { "xhot": 86, "yhot": 79 },
|
||||
"dnd_no_drop": { "xhot": 86, "yhot": 79 },
|
||||
|
||||
"dnd_none": { "xhot": 99, "yhot": 98 },
|
||||
|
||||
"grabbing": { "xhot": 106, "yhot": 79 },
|
||||
|
||||
"hand1": { "xhot": 113, "yhot": 95 },
|
||||
|
||||
"hand2": { "xhot": 88, "yhot": 32 },
|
||||
|
||||
"left_ptr_watch": { "xhot": 50, "yhot": 28 },
|
||||
|
||||
"left_ptr": { "xhot": 53, "yhot": 36 },
|
||||
|
||||
"left_side": { "xhot": 35, "yhot": 100 },
|
||||
|
||||
"left_tee": { "xhot": 165, "yhot": 95 },
|
||||
|
||||
"ll_angle": { "xhot": 34, "yhot": 165 },
|
||||
|
||||
"lr_angle": { "xhot": 167, "yhot": 164 },
|
||||
|
||||
"pencil": { "xhot": 37, "yhot": 161 },
|
||||
|
||||
"question_arrow": { "xhot": 102, "yhot": 102 },
|
||||
|
||||
"right_ptr": { "xhot": 150, "yhot": 29 },
|
||||
|
||||
"right_side": { "xhot": 163, "yhot": 98 },
|
||||
|
||||
"right_tee": { "xhot": 30, "yhot": 96 },
|
||||
|
||||
"sb_down_arrow": { "xhot": 100, "yhot": 126 },
|
||||
|
||||
"sb_h_double_arrow": { "xhot": 100, "yhot": 100 },
|
||||
"sb_v_double_arrow": { "xhot": 100, "yhot": 100 },
|
||||
|
||||
"sb_left_arrow": { "xhot": 86, "yhot": 100 },
|
||||
|
||||
"sb_right_arrow": { "xhot": 113, "yhot": 100 },
|
||||
|
||||
"sb_up_arrow": { "xhot": 99, "yhot": 86 },
|
||||
|
||||
"tcross": { "xhot": 98, "yhot": 100 },
|
||||
|
||||
"top_left_corner": { "xhot": 29, "yhot": 27 },
|
||||
|
||||
"top_right_corner": { "xhot": 170, "yhot": 28 },
|
||||
|
||||
"top_side": { "xhot": 98, "yhot": 34 },
|
||||
|
||||
"top_tee": { "xhot": 98, "yhot": 29 },
|
||||
|
||||
"ul_angle": { "xhot": 34, "yhot": 35 },
|
||||
|
||||
"ur_angle": { "xhot": 164, "yhot": 34 },
|
||||
|
||||
"zoom_in": { "xhot": 90, "yhot": 89 },
|
||||
|
||||
"zoom_out": { "xhot": 93, "yhot": 90 }
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
||||
def save_logs_to_file() -> None:
|
||||
""" Save `clickgen` logs to `build.log` in current working directory. """
|
||||
logging.basicConfig(filename='%s/build.log' % os.getcwd(), filemode='w',
|
||||
format='%(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = "1.0.3"
|
||||
|
||||
info = {
|
||||
"pkg_name": "builder",
|
||||
"version": __version__,
|
||||
"author": "Kaiz Khatri",
|
||||
"description": f"⚡ Bibata Builder - v{__version__}",
|
||||
"email": "kaizmandhu@gmail.com",
|
||||
"url": "https://github.com/ful1e5/Bibata_Cursor/",
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
[Version]
|
||||
signature="$CHICAGO$"
|
||||
<inject_theme_name> By Kaiz Khatri
|
||||
https://github.com/ful1e5/Bibata_Cursor
|
||||
|
||||
[DefaultInstall]
|
||||
CopyFiles = Scheme.Cur
|
||||
AddReg = Scheme.Reg
|
||||
|
||||
[DestinationDirs]
|
||||
Scheme.Cur = 10,"%CUR_DIR%"
|
||||
|
||||
[Scheme.Reg]
|
||||
HKCU,"Control Panel\Cursors\Schemes","%SCHEME_NAME%",,"%10%\%CUR_DIR%\%pointer%,%10%\%CUR_DIR%\%help%,%10%\%CUR_DIR%\%work%,%10%\%CUR_DIR%\%busy%,%10%\%CUR_DIR%\%Cross%,%10%\%CUR_DIR%\%Text%,%10%\%CUR_DIR%\%Hand%,%10%\%CUR_DIR%\%Unavailiable%,%10%\%CUR_DIR%\%Vert%,%10%\%CUR_DIR%\%Horz%,%10%\%CUR_DIR%\%Dgn1%,%10%\%CUR_DIR%\%Dgn2%,%10%\%CUR_DIR%\%move%,%10%\%CUR_DIR%\%alternate%,%10%\%CUR_DIR%\%link%"
|
||||
|
||||
; -- Installed files
|
||||
|
||||
[Scheme.Cur]
|
||||
"Arrow.cur"
|
||||
"Help.cur"
|
||||
"AppStarting.ani"
|
||||
"Wait.ani"
|
||||
"Cross.cur"
|
||||
"IBeam.cur"
|
||||
"Handwriting.cur"
|
||||
"NO.cur"
|
||||
"SizeNS.cur"
|
||||
"SizeWE.cur"
|
||||
"SizeNWSE.cur"
|
||||
"SizeNESW.cur"
|
||||
"SizeAll.cur"
|
||||
"Alternate.cur"
|
||||
"Hand.cur"
|
||||
|
||||
[Strings]
|
||||
CUR_DIR = "Cursors\<inject_theme_name>"
|
||||
SCHEME_NAME = "<inject_theme_name>"
|
||||
pointer = "Arrow.cur"
|
||||
help = "Help.cur"
|
||||
work = "AppStarting.ani"
|
||||
busy = "Wait.ani"
|
||||
cross = "Cross.cur"
|
||||
text = "IBeam.cur"
|
||||
hand = "Handwriting.cur"
|
||||
unavailiable = "NO.cur"
|
||||
vert = "SizeNS.cur"
|
||||
horz = "SizeWE.cur"
|
||||
dgn1 = "SizeNWSE.cur"
|
||||
dgn2 = "SizeNESW.cur"
|
||||
move = "SizeAll.cur"
|
||||
alternate = "Alternate.cur"
|
||||
link = "Hand.cur"
|
23
setup.py
23
setup.py
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from builder.pkg_info import info
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
setup(
|
||||
name=info["pkg_name"],
|
||||
version=info["version"],
|
||||
description=info["description"],
|
||||
url=info["url"],
|
||||
author=info["author"],
|
||||
author_email=info["email"],
|
||||
install_requires=["Pillow>=7.2.0", "clickgen==1.1.7"],
|
||||
packages=find_namespace_packages(include=["builder"]),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue