Implemented Wallpaper Selector and Matugen's Wallpaper based auto-theming. (#73)
* Implement matugen - WIP * Added matugen * Add types and cleanup code * Matugen implementation updates and added more options such as scheme and contrast. * Code cleanup and matugen settings renamed for clarity. * Makon maroon a primary matugen color. * Updates to handle variations of matugen colors * Finalizing matugen and wrapping up variations. * Minor styling updates of the settings dialog. * Do a swww dependency check. * Dependency logic update * Switch shouldn't double trigger notifications now when checking dependency. * Logic was inverted * Add matugen to dependency checker. * Fixed dependency checking conditional * Update dependency list in readme and check for matugen before doing matugen operations * Styling fixes * OSD Fix * Remove unused code from wallpaper service. * Color fixes for matugen. * Nix updates for new dependencies * Change default wallpaper to empty. * Added custom notification service for startup, cleaned up code and updated readme.
This commit is contained in:
64
services/Wallpaper.ts
Normal file
64
services/Wallpaper.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { dependencies, sh } from "lib/utils"
|
||||
const hyprland = await Service.import("hyprland");
|
||||
|
||||
const WP = `${Utils.HOME}/.config/background`
|
||||
|
||||
class Wallpaper extends Service {
|
||||
static {
|
||||
Service.register(this, {}, {
|
||||
"wallpaper": ["string"],
|
||||
})
|
||||
}
|
||||
|
||||
#blockMonitor = false
|
||||
|
||||
#wallpaper() {
|
||||
if (!dependencies("swww"))
|
||||
return
|
||||
|
||||
hyprland.monitors.map(m => m.name);
|
||||
sh("hyprctl cursorpos").then(pos => {
|
||||
sh([
|
||||
"swww", "img",
|
||||
"--invert-y",
|
||||
"--transition-type", "grow",
|
||||
"--transition-duration", "1.5",
|
||||
"--transition-fps", "30",
|
||||
"--transition-pos", pos.replace(" ", ""),
|
||||
WP,
|
||||
]).then(() => {
|
||||
this.changed("wallpaper")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async #setWallpaper(path: string) {
|
||||
this.#blockMonitor = true
|
||||
|
||||
await sh(`cp ${path} ${WP}`)
|
||||
this.#wallpaper()
|
||||
|
||||
this.#blockMonitor = false
|
||||
}
|
||||
|
||||
readonly set = (path: string) => { this.#setWallpaper(path) }
|
||||
get wallpaper() { return WP }
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
if (!dependencies("swww"))
|
||||
return this
|
||||
|
||||
Utils.monitorFile(WP, () => {
|
||||
if (!this.#blockMonitor)
|
||||
this.#wallpaper()
|
||||
})
|
||||
|
||||
Utils.execAsync("swww-daemon")
|
||||
.then(this.#wallpaper)
|
||||
.catch(() => null)
|
||||
}
|
||||
}
|
||||
|
||||
export default new Wallpaper
|
||||
Reference in New Issue
Block a user