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 getSystrayItems: () => string;
|
||||||
var isWindowVisible: (windowName: string) => boolean;
|
var isWindowVisible: (windowName: string) => boolean;
|
||||||
var clearAllNotifications: () => Promise<void>;
|
var clearAllNotifications: () => Promise<void>;
|
||||||
|
var setWallpaper: (filePath: string) => void;
|
||||||
|
|
||||||
var globalWeatherVar: VariableType<Weather>;
|
var globalWeatherVar: VariableType<Weather>;
|
||||||
var options: Options;
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
1
main.ts
1
main.ts
@@ -1,6 +1,7 @@
|
|||||||
import 'lib/session';
|
import 'lib/session';
|
||||||
import 'scss/style';
|
import 'scss/style';
|
||||||
import 'globals/useTheme';
|
import 'globals/useTheme';
|
||||||
|
import 'globals/wallpaper';
|
||||||
import 'globals/systray';
|
import 'globals/systray';
|
||||||
import 'globals/dropdown.js';
|
import 'globals/dropdown.js';
|
||||||
import 'globals/utilities';
|
import 'globals/utilities';
|
||||||
|
|||||||
Reference in New Issue
Block a user