mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-11-06 06:13:57 +03:00
Improved version of wallpaper installation
This commit is contained in:
parent
aa8930c07e
commit
178a8c4770
1 changed files with 26 additions and 0 deletions
26
api/controllers/set_wallpaper.go
Normal file
26
api/controllers/set_wallpaper.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/Redume/EveryNASA/api/utils"
|
||||||
|
utils2 "github.com/Redume/EveryNASA/utils"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/reujab/wallpaper"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SetWallpaper = func(c *fiber.Ctx) error {
|
||||||
|
url := c.FormValue("url")
|
||||||
|
if url == "" {
|
||||||
|
utils.Respond(c, utils.Message(false, "URL`s required."))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := wallpaper.SetFromURL(url)
|
||||||
|
if err != nil {
|
||||||
|
utils2.Log(err.Error())
|
||||||
|
utils.Respond(c, utils.Message(false, "An error occurred while setting the wallpaper."))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.Respond(c, utils.Message(true, "The wallpaper was successfully installed."))
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in a new issue