Implemented a callable function that sets the wallpaper. (#463)
* Implemented a callable function that sets the wallpaper. * Remove log
This commit is contained in:
1
globals.d.ts
vendored
1
globals.d.ts
vendored
@@ -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
22
globals/wallpaper.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user