make it work on cinnamon

This commit is contained in:
andrzej 2024-11-04 16:47:46 +01:00
parent c46ab056f5
commit 9b4acc1dca
2 changed files with 18 additions and 2 deletions

BIN
gopaper Executable file

Binary file not shown.

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"os"
"time"
"github.com/xyproto/wallutils"
@ -10,7 +11,7 @@ import (
func slideshow(ch <-chan string) {
dir := <-ch
ticker := time.NewTicker(time.Duration(config.Duration) * time.Second)
ticker := time.NewTicker(time.Duration(config.Duration) * time.Minute)
go func() {
for {
@ -35,5 +36,20 @@ func setRandomWallpaper(dir string) error {
if err != nil {
return err
}
return wallutils.SetWallpaperCustom(img, "fit", false)
desktopEnv, bool := os.LookupEnv("DESKTOP_SESSION")
if !bool {
panic("cannot determine desktop environment")
}
var mode string
switch desktopEnv {
case "cinnamon":
mode = "span"
case "hyprland":
mode = "fit"
default:
mode = ""
}
return wallutils.SetWallpaperCustom(img, mode, false)
}