Files
dotfiles/.config/WallRizz/hyprpaper@5hubham5ingh.js

30 lines
1.2 KiB
JavaScript

/*
For: hyprpaper, https://github.com/hyprwm/hyprpaper
Author: https://github.com/5hubham5ingh
Prerequisite: hyprpaper daemon should be running
Changes: Set to change wallpaper on all screens
*/
export function setWallpaper(wallpaperPath) {
OS.exec(["hyprctl", "-q", "hyprpaper unload all"]);
OS.exec(["hyprctl", "-q", `hyprpaper preload ${wallpaperPath}`]);
OS.exec(["hyprctl", "-q", `hyprpaper wallpaper ,${wallpaperPath}`]);
// SYMLINK
// Extract directory and extension
const lastSlashIndex = wallpaperPath.lastIndexOf('/');
const directory = wallpaperPath.substring(0, lastSlashIndex + 1);
const lastDotIndex = wallpaperPath.lastIndexOf('.');
const extension = lastDotIndex > lastSlashIndex ? wallpaperPath.substring(lastDotIndex) : '';
// Create lockpaper path with same extension
const lockpaperPath = `${directory}lockpaper${extension}`;
// DELETE ANY OLD IMAGES
OS.exec(["zsh", "-c", `rm ${directory}lockpaper*`]);
// Create symlink from wallpaper to lockpaper
OS.exec(["zsh", "-c", `ln -s ${wallpaperPath} ${lockpaperPath}`]);
OS.exec(["zsh", "-c", `ln -sf ${wallpaperPath} /home/nathan/.config/lockpaper`]);
}