diff --git a/install.py b/install.py index f8d0902..ab2ad11 100755 --- a/install.py +++ b/install.py @@ -1 +1,31 @@ -from subprocess import call +#!/bin/python +import curses +from lib.parse import Category, Package, parse +from lib.menu import Menu +from lib.configure import configure + +categories = parse('packages.yml') + +def noop(): + pass + +class App: + def __init__(self, stdscreen): + self.screen = stdscreen + curses.curs_set(0) + + submenu_items = [ + ('do stuff', noop) + ] + submenu = Menu(self.screen, submenu_items) + + main_menu_items = [ + ('install', noop), + ('submenu', submenu.display) + ] + main_menu = Menu(self.screen, main_menu_items) + main_menu.display() + +if __name__ == '__main__': + curses.wrapper(App) + diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lib/configure.py b/lib/configure.py new file mode 100644 index 0000000..eaea5e2 --- /dev/null +++ b/lib/configure.py @@ -0,0 +1,5 @@ +from subprocess import call +from lib.parse import Package + +def configure(package): + pass diff --git a/scripts/install/menu.py b/lib/menu.py similarity index 77% rename from scripts/install/menu.py rename to lib/menu.py index ae89d79..6771aeb 100755 --- a/scripts/install/menu.py +++ b/lib/menu.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import curses from curses import panel @@ -76,27 +74,3 @@ class Menu(BaseMenu): self.should_exit = False self.down() - -class App(object): - def __init__(self, stdscreen): - self.screen = stdscreen - curses.curs_set(0) - - submenu_items = [ - ('beep', curses.beep), - ('flash', curses.flash) - ] - submenu = Menu(self.screen, submenu_items) - - main_menu_items = [ - ('beep', curses.beep), - ('flash', curses.flash), - ('submenu', submenu.display) - ] - main_menu = Menu(self.screen, main_menu_items) - main_menu.display() - -if __name__ == '__main__': - curses.wrapper(App) - - diff --git a/lib/parse.py b/lib/parse.py new file mode 100755 index 0000000..2fd22a3 --- /dev/null +++ b/lib/parse.py @@ -0,0 +1,26 @@ +import yaml + +class Package: + def __init__(self, obj): + if isinstance(obj, dict): + self.name, props = next(iter(obj.items())) + self.source = 'core' + for key, value in props.items(): + setattr(self, key, value) + else: + self.name = obj + self.source = 'core' + def __repr__(self): + return self.name + +class Category: + def __init__(self, name, packages): + self.name = name + self.packages = [Package(pkg) for pkg in packages] + def __repr__(self): + return self.name + ': ' + str(self.packages) + +def parse(file): + f = open(file, 'r') + data = yaml.load(f) + return [Category(name, packages) for name, packages in data.items()] diff --git a/packages.org b/packages.org deleted file mode 100644 index dd23ce0..0000000 --- a/packages.org +++ /dev/null @@ -1,28 +0,0 @@ -* Fonts -core ttf-dejavu -core otf-fira-code -core adobe-source-han-sans-jp-fonts -git https://github.com/domtronn/all-the-icons.el all-the-icons.fish - -* System Tools -core networkmanager - -* Window Manager - -* Desktop Tools -core rofi - -* Editors -core emacs -core neovim - -* Music -core mpd -core mpc -core ncmpcpp -core beets - -* Terminal -core alacritty -core alacritty-terminfo -core fish diff --git a/packages.yml b/packages.yml new file mode 100644 index 0000000..9f23376 --- /dev/null +++ b/packages.yml @@ -0,0 +1,39 @@ +Base: + - fish + - systemd: + source: none + +Terminal: + - alacritty + - alacritty-terminfo + +Editors: + - emacs: + config: .emacs.d + user-units: + - emacs.service + - neovim + +System Tools: + - networkmanager + +Window Manager: + - ppi3-git: + source: aur + +Desktop Tools: + - python-pywal: + script: wal.fish + config: .config/wal + user-units: + - wallpaper.service + - wallpaper.timer + - rofi + +Fonts: + - ttf-dejavu + - otf-fira-code + - adobe-source-han-sans-jp-fonts + - all-the-icons: + source: git + url: https://github.com/domtronn/all-the-icons.el diff --git a/scripts/install/parse.py b/scripts/install/parse.py deleted file mode 100755 index 373ebce..0000000 --- a/scripts/install/parse.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python -import re - -class Package: - def __init__(self, line): - self.type = line[0] - self.name = line[1] - self.script = line[2] if len(line) == 3 else None - @staticmethod - def is_package_line(line): - return re.match(r"^[^*]+", line[0]) - -class Category: - def __init__(self, line): - self.name = ' '.join(line[1:]) - self.packages = [] - @staticmethod - def is_category_line(line): - return re.match(r"^\*+", line[0]) - -def split(lines): - return list(map(lambda line: line.rstrip().split(' '), lines)) - -def parse_package_listing(file): - f = open(file, 'r') - categories = [] - category = None - for line in split(f.readlines()): - if Category.is_category_line(line): - category = Category(line) - categories.append(category) - elif Package.is_package_line(line): - category.packages.append(Package(line)) - return categories diff --git a/scripts/install/test.py b/scripts/install/test.py deleted file mode 100755 index 42fc7cb..0000000 --- a/scripts/install/test.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python - -import parse - -categories = parse.parse_package_listing('packages.org') - -for category in categories: - print(category.name) - for package in category.packages: - print('- ' + package.name)