Files
custum-hyprpanel/src/scss/optionsTrackers.ts
davfsa e9df5eb230 Fix resolving paths for .face.icon in dashboard and add home ('~') path support (#606)
* Fix resolving paths for .face.icon in dashboard and add home ('~') path support

* Fix ESLint issues

* Update src/lib/utils.ts

Co-authored-by: davfsa <davfsa@gmail.com>

* Update src/lib/utils.ts

* Rename `resolvePath` to `normalizePath`

* Rename missing reference

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
2024-12-24 02:56:11 -08:00

44 lines
1.5 KiB
TypeScript

import icons from '../lib/icons/icons';
import { bash, dependencies, Notify, isAnImage, normalizePath } from '../lib/utils';
import options from '../options';
import Wallpaper from 'src/services/Wallpaper';
const { matugen } = options.theme;
const ensureMatugenWallpaper = (): void => {
const wallpaperPath = options.wallpaper.image.get();
if (matugen.get() && (!wallpaperPath.length || !isAnImage(normalizePath(wallpaperPath)))) {
Notify({
summary: 'Matugen Failed',
body: "Please select a wallpaper in 'Theming > General' first.",
iconName: icons.ui.warning,
});
matugen.set(false);
}
};
export const initializeTrackers = (resetCssFunc: () => void): void => {
matugen.subscribe(() => {
ensureMatugenWallpaper();
});
Wallpaper.connect('changed', () => {
console.info('Wallpaper changed, regenerating Matugen colors...');
if (options.theme.matugen.get()) {
resetCssFunc();
}
});
options.wallpaper.image.subscribe(() => {
if ((!Wallpaper.isRunning() && options.theme.matugen.get()) || !options.wallpaper.enable.get()) {
console.info('Wallpaper path changed, regenerating Matugen colors...');
resetCssFunc();
}
if (options.wallpaper.pywal.get() && dependencies('wal')) {
const wallpaperPath = options.wallpaper.image.get();
bash(`wal -i ${wallpaperPath}`);
}
});
};