1
0
mirror of https://github.com/Foltik/dotfiles synced 2025-01-07 08:42:47 -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
from pathlib import Path
class Package:
def __init__(self, obj):
@ -10,8 +11,39 @@ class Package:
else:
self.name = obj
self.source = 'core'
self.update_from_files()
def __repr__(self):
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:
def __init__(self, name, packages):

View File

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