working random wallpaper
This commit is contained in:
parent
0655e6a1ee
commit
58aba48e3c
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
"colorize":[ 247,40,60 ],
|
||||||
|
"contrast":-35,
|
||||||
|
"gamma":0.8,
|
||||||
|
"root":"/home/andrzej/bgs"
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
module go-img
|
||||||
|
|
||||||
|
go 1.23.2
|
||||||
|
|
||||||
|
require github.com/disintegration/gift v1.2.1
|
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc=
|
||||||
|
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
|
|
@ -0,0 +1,62 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
config := loadConfig()
|
||||||
|
|
||||||
|
//get working directory
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("couldn't find working directory", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
curr := wd + "/curr.png"
|
||||||
|
// apply curr.png if already preloaded
|
||||||
|
err = hyprpaperWallpaper(curr)
|
||||||
|
if err != nil {
|
||||||
|
//preload curr.png if not
|
||||||
|
err = hyprpaperPreload(curr)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("could not preload (this is fine)", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := config.Root + "/chsck"
|
||||||
|
randomImg, _ := getRandomFile(dir)
|
||||||
|
img := loadImage(randomImg)
|
||||||
|
dst := processImage(img, config)
|
||||||
|
|
||||||
|
saveImage("curr.png", dst)
|
||||||
|
|
||||||
|
path := wd + "/curr.png"
|
||||||
|
err = hyprpaperPreload(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("preload failed!", err)
|
||||||
|
}
|
||||||
|
err = hyprpaperWallpaper(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("set wallpaper failed!", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadConfig() Config {
|
||||||
|
configRaw, err := os.ReadFile("./config.json")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Couldn't open config file!", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
err = json.Unmarshal(configRaw, &config)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Couldn't unmarshal config!", err)
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
}
|
Loading…
Reference in New Issue