Bibata_Cursor/build.py

72 lines
1.7 KiB
Python
Raw Normal View History

2020-08-25 03:13:38 -04:00
#!/usr/bin/env python
2020-10-10 07:52:02 -04:00
# -*- coding: utf-8 -*-
2020-08-25 03:13:38 -04:00
2020-10-10 07:52:02 -04:00
import sys
2020-10-07 06:05:51 -04:00
import argparse
2020-10-10 07:52:02 -04:00
from argparse import ArgumentParser
from os import path, listdir
2020-10-14 23:20:27 -04:00
from typing import List
2020-08-23 09:02:58 -04:00
2020-10-14 23:20:27 -04:00
from builder.pkg_info import info
2020-10-10 07:52:02 -04:00
from builder.config import ConfigProvider
from builder.cursor import CursorBuilder
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
def get_args_parser() -> ArgumentParser:
2020-10-07 06:05:51 -04:00
"""Parse command line arguments"""
2020-10-14 23:20:27 -04:00
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)"),
)
2020-10-07 06:05:51 -04:00
2020-10-10 07:52:02 -04:00
return parser
2020-10-07 06:05:51 -04:00
2020-08-23 09:02:58 -04:00
2020-10-14 22:33:13 -04:00
def build() -> None:
2020-10-14 22:55:11 -04:00
""" Build Bibata cursor """
2020-10-10 07:52:02 -04:00
parser = get_args_parser()
try:
args = parser.parse_args()
except Exception:
2020-10-10 07:52:02 -04:00
sys.exit(0)
2020-10-07 06:05:51 -04:00
2020-10-10 07:52:02 -04:00
bitmaps_dir = "./bitmaps"
out_dir = "./themes"
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
# print builder information
2020-10-24 00:33:15 -04:00
print(info["description"])
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
bitmaps_dirs = listdir(bitmaps_dir)
2020-10-14 23:20:27 -04:00
configs: List[ConfigProvider] = []
builders: List[CursorBuilder] = []
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
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]))
2020-08-23 09:56:45 -04:00
2020-10-10 07:52:02 -04:00
for builder in builders:
2020-10-14 23:20:27 -04:00
if args.x11 == args.windows:
2020-10-10 07:52:02 -04:00
builder.build_cursors()
2020-10-14 23:20:27 -04:00
elif args.x11:
2020-10-10 07:52:02 -04:00
builder.build_x11_cursors()
2020-10-14 23:20:27 -04:00
elif args.windows:
2020-10-10 07:52:02 -04:00
builder.build_win_cursors()
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
if __name__ == "__main__":
2020-10-14 22:33:13 -04:00
build()