Implemented a callable function that sets the wallpaper. (#463)

* Implemented a callable function that sets the wallpaper.

* Remove log
This commit is contained in:
Jas Singh
2024-11-08 20:56:47 -08:00
committed by GitHub
parent 2e64f7738f
commit 51581b198f
3 changed files with 24 additions and 0 deletions

1
globals.d.ts vendored
View File

@@ -8,6 +8,7 @@ declare global {
var getSystrayItems: () => string;
var isWindowVisible: (windowName: string) => boolean;
var clearAllNotifications: () => Promise<void>;
var setWallpaper: (filePath: string) => void;
var globalWeatherVar: VariableType<Weather>;
var options: Options;

22
globals/wallpaper.ts Normal file
View File

@@ -0,0 +1,22 @@
import GLib from 'gi://GLib?version=2.0';
import { Notify } from 'lib/utils';
import options from 'options';
import Wallpaper from 'services/Wallpaper';
const { EXISTS, IS_REGULAR } = GLib.FileTest;
const { enable: enableWallpaper, image } = options.wallpaper;
globalThis.setWallpaper = (filePath: string): void => {
if (!(GLib.file_test(filePath, EXISTS) && GLib.file_test(filePath, IS_REGULAR))) {
Notify({
summary: 'Failed to set Wallpaper',
body: 'The input file is not a valid wallpaper.',
});
}
image.value = filePath;
if (enableWallpaper.value) {
Wallpaper.set(filePath);
}
};

View File

@@ -1,6 +1,7 @@
import 'lib/session';
import 'scss/style';
import 'globals/useTheme';
import 'globals/wallpaper';
import 'globals/systray';
import 'globals/dropdown.js';
import 'globals/utilities';