Implemented Wallpaper Selector and Matugen's Wallpaper based auto-theming. (#73)
* Implement matugen - WIP * Added matugen * Add types and cleanup code * Matugen implementation updates and added more options such as scheme and contrast. * Code cleanup and matugen settings renamed for clarity. * Makon maroon a primary matugen color. * Updates to handle variations of matugen colors * Finalizing matugen and wrapping up variations. * Minor styling updates of the settings dialog. * Do a swww dependency check. * Dependency logic update * Switch shouldn't double trigger notifications now when checking dependency. * Logic was inverted * Add matugen to dependency checker. * Fixed dependency checking conditional * Update dependency list in readme and check for matugen before doing matugen operations * Styling fixes * OSD Fix * Remove unused code from wallpaper service. * Color fixes for matugen. * Nix updates for new dependencies * Change default wallpaper to empty. * Added custom notification service for startup, cleaned up code and updated readme.
This commit is contained in:
@@ -37,12 +37,24 @@ export class Opt<T = unknown> extends Variable<T> {
|
||||
|
||||
reset() {
|
||||
if (this.persistent)
|
||||
return
|
||||
return;
|
||||
|
||||
if (JSON.stringify(this.value) !== JSON.stringify(this.initial)) {
|
||||
this.value = this.initial
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
||||
doResetColor() {
|
||||
if (this.persistent)
|
||||
return;
|
||||
|
||||
const isColor = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(`${this.value}`);
|
||||
if ((JSON.stringify(this.value) !== JSON.stringify(this.initial)) && isColor) {
|
||||
this.value = this.initial
|
||||
return this.id
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +77,13 @@ function getOptions(object: object, path = ""): Opt[] {
|
||||
})
|
||||
}
|
||||
|
||||
export function mkOptions<T extends object>(cacheFile: string, object: T) {
|
||||
export function mkOptions<T extends object>(cacheFile: string, object: T, confFile: string = "config.json") {
|
||||
for (const opt of getOptions(object))
|
||||
opt.init(cacheFile)
|
||||
|
||||
Utils.ensureDirectory(cacheFile.split("/").slice(0, -1).join("/"))
|
||||
|
||||
const configFile = `${TMP}/config.json`
|
||||
const configFile = `${TMP}/${confFile}`
|
||||
const values = getOptions(object).reduce((obj, { id, value }) => ({ [id]: value, ...obj }), {})
|
||||
Utils.writeFileSync(JSON.stringify(values, null, 2), configFile)
|
||||
Utils.monitorFile(configFile, () => {
|
||||
@@ -98,12 +110,27 @@ export function mkOptions<T extends object>(cacheFile: string, object: T) {
|
||||
: await sleep().then(() => reset(list))
|
||||
}
|
||||
|
||||
async function resetTheme(
|
||||
[opt, ...list] = getOptions(object),
|
||||
id = opt?.doResetColor(),
|
||||
): Promise<Array<string>> {
|
||||
if (!opt)
|
||||
return sleep().then(() => [])
|
||||
|
||||
return id
|
||||
? [id, ...(await sleep(50).then(() => resetTheme(list)))]
|
||||
: await sleep().then(() => resetTheme(list))
|
||||
}
|
||||
|
||||
return Object.assign(object, {
|
||||
configFile,
|
||||
array: () => getOptions(object),
|
||||
async reset() {
|
||||
return (await reset()).join("\n")
|
||||
},
|
||||
async resetTheme() {
|
||||
return (await resetTheme()).join("\n")
|
||||
},
|
||||
handler(deps: string[], callback: () => void) {
|
||||
for (const opt of getOptions(object)) {
|
||||
if (deps.some(i => opt.id.startsWith(i)))
|
||||
|
||||
Reference in New Issue
Block a user