Squash merge wallutils into main
This commit is contained in:
parent
bba3a43bb8
commit
568dc2b8d4
15
go.mod
15
go.mod
|
@ -12,4 +12,17 @@ require (
|
||||||
github.com/crazy3lf/colorconv v1.2.0
|
github.com/crazy3lf/colorconv v1.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require github.com/swaywm/swaybg v1.2.1 // indirect
|
require (
|
||||||
|
github.com/anthonynsimon/bild v0.14.0 // indirect
|
||||||
|
github.com/fatih/color v1.18.0 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/stretchr/powerwalk v0.0.0-20151124150408-bceb9d014549 // indirect
|
||||||
|
github.com/xyproto/env/v2 v2.5.1 // indirect
|
||||||
|
golang.org/x/sys v0.26.0 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/swaywm/swaybg v1.2.1 // indirect
|
||||||
|
github.com/xyproto/wallutils v0.0.0-20241029150533-f105e9c53323
|
||||||
|
)
|
||||||
|
|
19
go.sum
19
go.sum
|
@ -1,10 +1,29 @@
|
||||||
github.com/adhocore/jsonc v0.10.0 h1:YjNX9TojBfxQJ4kuoiNqVR5SFqu1YBEMsm+HxWnxbOI=
|
github.com/adhocore/jsonc v0.10.0 h1:YjNX9TojBfxQJ4kuoiNqVR5SFqu1YBEMsm+HxWnxbOI=
|
||||||
github.com/adhocore/jsonc v0.10.0/go.mod h1:Ar4gd3i83+1Z+5M5SG6Vrfw9q3TO544OwLXH4+ZhWTE=
|
github.com/adhocore/jsonc v0.10.0/go.mod h1:Ar4gd3i83+1Z+5M5SG6Vrfw9q3TO544OwLXH4+ZhWTE=
|
||||||
|
github.com/anthonynsimon/bild v0.14.0 h1:IFRkmKdNdqmexXHfEU7rPlAmdUZ8BDZEGtGHDnGWync=
|
||||||
|
github.com/anthonynsimon/bild v0.14.0/go.mod h1:hcvEAyBjTW69qkKJTfpcDQ83sSZHxwOunsseDfeQhUs=
|
||||||
github.com/crazy3lf/colorconv v1.2.0 h1:UM7kSZWnwFMGiC+PpYrjxQSOd6sEyWb+dRKKTd3KslA=
|
github.com/crazy3lf/colorconv v1.2.0 h1:UM7kSZWnwFMGiC+PpYrjxQSOd6sEyWb+dRKKTd3KslA=
|
||||||
github.com/crazy3lf/colorconv v1.2.0/go.mod h1:2jTJ7QCWCj2sSLOhF4Gzi0J5/hoX8/VY8VzNvXAlD1I=
|
github.com/crazy3lf/colorconv v1.2.0/go.mod h1:2jTJ7QCWCj2sSLOhF4Gzi0J5/hoX8/VY8VzNvXAlD1I=
|
||||||
github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc=
|
github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc=
|
||||||
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
|
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
|
||||||
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||||
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/stretchr/powerwalk v0.0.0-20151124150408-bceb9d014549 h1:zjTKDjwZy1IVyLos+s70iYMwL/ZVojUbIDX5kghHa1Q=
|
||||||
|
github.com/stretchr/powerwalk v0.0.0-20151124150408-bceb9d014549/go.mod h1:RhJzAYfVBD/ULOCeUUaTn0CHDRQBYHjDY7yYpSt6+4M=
|
||||||
github.com/swaywm/swaybg v1.2.1 h1:TvQYiifR9JW4dANxxb7HMbEaZdGnZ4CWynevENocIWU=
|
github.com/swaywm/swaybg v1.2.1 h1:TvQYiifR9JW4dANxxb7HMbEaZdGnZ4CWynevENocIWU=
|
||||||
github.com/swaywm/swaybg v1.2.1/go.mod h1:Og8Sb6ebG/J9hqY2nL3xnhKY5sL30mQL+JOrY9owcJM=
|
github.com/swaywm/swaybg v1.2.1/go.mod h1:Og8Sb6ebG/J9hqY2nL3xnhKY5sL30mQL+JOrY9owcJM=
|
||||||
|
github.com/xyproto/env/v2 v2.5.1 h1:vu8A+z5VGp9TGgg7HQlAZPjbnk/Nvzt3gKzUtbt9kbQ=
|
||||||
|
github.com/xyproto/env/v2 v2.5.1/go.mod h1:F81ZEzu15s3TWUZJ1uzBl9iNeq9zcfHvxMkQJaLZUl0=
|
||||||
|
github.com/xyproto/wallutils v0.0.0-20241029150533-f105e9c53323 h1:N2G2i6IZsYEaXkkgn6NqaDBG7RoJanybfwHP98VTOs8=
|
||||||
|
github.com/xyproto/wallutils v0.0.0-20241029150533-f105e9c53323/go.mod h1:YneBbR00nKKlWx+pqDTyvWNwINDfPxiakTxDOvjTIcI=
|
||||||
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
|
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
|
||||||
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
|
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||||
|
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
|
58
slideshow.go
58
slideshow.go
|
@ -1,54 +1,24 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/xyproto/wallutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func slideshow(ch <-chan string) {
|
func slideshow(ch <-chan string) {
|
||||||
dir := <-ch
|
dir := <-ch
|
||||||
ticker := time.NewTicker(time.Duration(config.Duration) * time.Minute)
|
ticker := time.NewTicker(time.Duration(config.Duration) * time.Second)
|
||||||
|
|
||||||
//set a flat background color based on config defaults
|
|
||||||
fillCmd := exec.Command("swaybg", "-c", "#232136")
|
|
||||||
// stdout, _ := fillCmd.StdoutPipe()
|
|
||||||
// scanner := bufio.NewScanner(stdout)
|
|
||||||
// out := make(chan string)
|
|
||||||
// go func() {
|
|
||||||
// for scanner.Scan() {
|
|
||||||
// fmt.Println("scanner: ", scanner.Text())
|
|
||||||
// out <- scanner.Text()
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
|
|
||||||
ready := make(chan bool)
|
|
||||||
go func() {
|
|
||||||
err := fillCmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("could not set background color", err)
|
|
||||||
}
|
|
||||||
//NOTE: this is *very* hacky, but it is difficult to know when swaybg has initiated
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
ready <- true
|
|
||||||
fmt.Println("bg color set!")
|
|
||||||
fillCmd.Wait()
|
|
||||||
}()
|
|
||||||
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
<-ready
|
err := setRandomWallpaper(dir)
|
||||||
newCmd := setRandomWallpaper(dir)
|
if err != nil {
|
||||||
if cmd != nil {
|
fmt.Printf("Failed to set random wallpaper from directory %v.", dir)
|
||||||
err := cmd.Process.Kill()
|
panic(err)
|
||||||
if err != nil {
|
|
||||||
log.Fatal("could not kill process", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cmd = newCmd
|
|
||||||
select {
|
select {
|
||||||
case dir = <-ch:
|
case dir = <-ch:
|
||||||
log.Println("directory set!")
|
log.Println("directory set!")
|
||||||
|
@ -60,18 +30,10 @@ func slideshow(ch <-chan string) {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRandomWallpaper(dir string) *exec.Cmd {
|
func setRandomWallpaper(dir string) error {
|
||||||
img, err := pickRandomImage(dir)
|
img, err := pickRandomImage(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
|
return wallutils.SetWallpaperCustom(img, "fit", false)
|
||||||
cmd := exec.Command("swaybg", "-i", img, "--mode", "fit")
|
|
||||||
fmt.Printf("setting wallpaper: %v\n", img)
|
|
||||||
err = cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("failed to set wallpaper!", err)
|
|
||||||
}
|
|
||||||
go cmd.Wait()
|
|
||||||
return cmd
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue