Bibata_Cursor/builder/config.py

72 lines
2 KiB
Python
Raw Normal View History

2020-10-08 01:34:47 -04:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
2020-10-08 03:04:19 -04:00
import log
2020-10-08 02:29:27 -04:00
import sys
2020-10-08 03:04:19 -04:00
import json
2020-10-08 01:34:47 -04:00
import builder
2020-10-08 08:15:11 -04:00
import tempfile
2020-10-08 02:29:27 -04:00
from os import path, listdir
2020-10-08 01:34:47 -04:00
import shutil
2020-10-08 08:15:11 -04:00
class ConfigProvider():
2020-10-08 01:34:47 -04:00
"""
2020-10-08 02:29:27 -04:00
Configure `Bibata` building process.
2020-10-08 01:34:47 -04:00
"""
2020-10-08 02:29:27 -04:00
# Build Config
2020-10-08 08:15:11 -04:00
delay = 35
sizes = [22, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96]
2020-10-08 02:29:27 -04:00
# Windows Cursors Config
2020-10-08 08:15:11 -04:00
windows_cursors = {
2020-10-08 02:29:27 -04:00
"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": "SizeNESW.cur",
"sb_v_double_arrow.cur": "SizeNS.cur",
"fd_double_arrow.cur": "SizeNWSE.cur",
"sb_h_double_arrow.cur": "SizeWE.cur",
"sb_up_arrow.cur": "UpArrow.cur",
"wait.ani": "Wait.ani",
}
2020-10-08 01:34:47 -04:00
2020-10-08 02:29:27 -04:00
def __init__(self, bitmaps_dir: str, out_dir: str) -> None:
2020-10-08 01:34:47 -04:00
2020-10-08 02:29:27 -04:00
# cleanup old packages
if path.exists(out_dir):
2020-10-08 01:34:47 -04:00
shutil.rmtree(out_dir)
2020-10-08 02:29:27 -04:00
# 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)
2020-10-08 01:34:47 -04:00
os.mkdir(out_dir)
2020-10-08 08:15:11 -04:00
self.bitmaps_dir: str = bitmaps_dir
self.temp_out_dir: str = tempfile.mkdtemp()
self.out_dir: str = out_dir
2020-10-08 02:29:27 -04:00
2020-10-08 03:04:19 -04:00
# read hotspots file
with open(path.join(builder.__path__[0], "hotspots.json")) as hotspot_file:
self.hotspots = json.loads(hotspot_file.read())
2020-10-08 01:34:47 -04:00
def get_windows_script(self, theme_name: str, author: str) -> str:
with open(path.join(builder.__path__[0], "windows.inf")) as f:
data = f.read()
inf_content = data.replace(
"<inject_theme_name>", theme_name+" Cursors").replace("<inject_author_name>", author)
return inf_content