1
0
mirror of https://github.com/Foltik/dotfiles synced 2025-01-23 07:10:26 -05:00

Add property inference based on files present

This commit is contained in:
Jack Foltz 2018-12-05 16:50:49 -05:00
parent 97843dbbf3
commit 8d2657ac8f
Signed by: foltik
GPG Key ID: D1F0331758D1F29A
2 changed files with 38 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import yaml import yaml
from pathlib import Path
class Package: class Package:
def __init__(self, obj): def __init__(self, obj):
@ -10,9 +11,40 @@ class Package:
else: else:
self.name = obj self.name = obj
self.source = 'core' self.source = 'core'
self.update_from_files()
def __repr__(self): def __repr__(self):
return self.name return self.name
def update_from_files(self):
if self.source == 'none':
self.source = None
default_config = Path('lain/.config/' + self.name)
if hasattr(self, 'config'):
self.config = Path('lain/' + self.config)
elif default_config.is_dir():
self.config = default_config
else:
self.config = None
default_script = Path('scripts/' + self.name + '.fish')
if hasattr(self, 'script'):
self.script = Path('scripts/' + self.script)
elif default_script.is_file():
self.script = default_script
else:
self.script = None
default_unit = Path('lain/.config/systemd/user/' + self.name + '.service')
if hasattr(self, 'userunits'):
self.userunits = list(map(lambda unit: Path('lain/.config/systemd/user/' + unit), self.userunits))
elif default_unit.is_file():
self.userunits = [default_unit]
else:
self.userunits = None
class Category: class Category:
def __init__(self, name, packages): def __init__(self, name, packages):
self.name = name self.name = name

View File

@ -2,10 +2,10 @@ Base:
- fish - fish
- systemd: - systemd:
source: none source: none
user-units: userunits:
- i3@0 - i3@0.service
- xmodmap@0 - xmodmap@0.service
- xresources@0 - xresources@0.service
Terminal: Terminal:
- alacritty - alacritty
@ -23,13 +23,13 @@ System Tools:
Window Manager: Window Manager:
- ppi3-git: - ppi3-git:
source: aur source: aur
- compton: - compton
Desktop Tools: Desktop Tools:
- python-pywal: - python-pywal:
script: wal.fish script: wal.fish
config: .config/wal config: .config/wal
user-units: userunits:
- wallpaper.service - wallpaper.service
- wallpaper.timer - wallpaper.timer
- rofi - rofi