Bibata_Cursor/build.py

62 lines
1.6 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-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
from builder import __info__
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-10 07:52:02 -04:00
parser = argparse.ArgumentParser(description=__info__)
2020-10-07 06:05:51 -04:00
parser.add_argument("-x", "--x11", action="store_true", default=False,
2020-10-10 07:52:02 -04:00
help=("Bundle X11 cursors using bitmaps"
2020-10-07 06:05:51 -04:00
" (default: %(default)s)"))
2020-10-10 07:52:02 -04:00
parser.add_argument("-w", "--windows", action="store_true", default=False,
help=("Bundle Windows cursors using 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-10 07:52:02 -04:00
def main() -> None:
parser = get_args_parser()
try:
args = parser.parse_args()
except:
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
print(__info__)
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
bitmaps_dirs = listdir(bitmaps_dir)
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:
if (args.x11 == args.windows):
builder.build_cursors()
elif(args.x11):
builder.build_x11_cursors()
elif(args.windows):
builder.build_win_cursors()
2020-08-23 09:02:58 -04:00
2020-10-10 07:52:02 -04:00
if __name__ == "__main__":
main()