From 9bd06b04e42049151984fbbd22ea88592220f9ff Mon Sep 17 00:00:00 2001 From: 3ri4nG0ld Date: Mon, 29 Jun 2026 01:33:55 +0100 Subject: [PATCH] mpvpaper: add support for setting video thumbnails as static wallpaper with configurable option --- mpvpaper/mpvpaper_service.luau | 10 ++++++++-- mpvpaper/panel.luau | 9 +++++---- mpvpaper/plugin.toml | 7 +++++++ mpvpaper/translations/en.json | 4 +++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/mpvpaper/mpvpaper_service.luau b/mpvpaper/mpvpaper_service.luau index 3937f98..1060ae9 100644 --- a/mpvpaper/mpvpaper_service.luau +++ b/mpvpaper/mpvpaper_service.luau @@ -102,13 +102,19 @@ end -- ── Commands ────────────────────────────────────────────────────────────── -local function setVideo(connector, path) +local function setVideo(connector, path, thumb) if not available or type(connector) ~= "string" or connector == "" or type(path) ~= "string" or path == "" then return end assignments[connector] = path persist() noctalia.setWallpaperEnabled(connector, false) + -- If the user wants to use the video as a static wallpaper, set it. + if cfg("set_static_wallpaper") and type(thumb) == "string" and thumb ~= "" then + if noctalia.fileExists(thumb) then + noctalia.setWallpaper(connector, thumb) + end + end fifo("set " .. connector .. " " .. path) publish() end @@ -181,7 +187,7 @@ noctalia.state.watch("command", function(cmd) return end if cmd.action == "set" then - setVideo(cmd.connector, cmd.path) + setVideo(cmd.connector, cmd.path, cmd.thumb) elseif cmd.action == "clear" then clearVideo(cmd.connector) end diff --git a/mpvpaper/panel.luau b/mpvpaper/panel.luau index dc3737e..2b3050b 100644 --- a/mpvpaper/panel.luau +++ b/mpvpaper/panel.luau @@ -72,18 +72,19 @@ local function selectedConnector() return selectedConnectorName end -local function sendCommand(action, connector, path) +local function sendCommand(action, connector, path, thumb) cmdNonce += 1 - noctalia.state.set("command", { action = action, connector = connector, path = path, nonce = cmdNonce }) + noctalia.state.set("command", { action = action, connector = connector, path = path, thumb = thumb, nonce = cmdNonce }) end local function applyVideo(path) + local thumb = thumbPaths[path] if selectedConnectorName == "" then for _, output in ipairs(outputsList) do - sendCommand("set", output.name, path) + sendCommand("set", output.name, path, thumb) end else - sendCommand("set", selectedConnectorName, path) + sendCommand("set", selectedConnectorName, path, thumb) end render() end diff --git a/mpvpaper/plugin.toml b/mpvpaper/plugin.toml index c1d0fc5..9142e8d 100644 --- a/mpvpaper/plugin.toml +++ b/mpvpaper/plugin.toml @@ -53,6 +53,13 @@ label_key = "settings.mpv_options.label" description_key = "settings.mpv_options.description" default = "" +[[setting]] +key = "set_static_wallpaper" +type = "bool" +label_key = "settings.set_static_wallpaper.label" +description_key = "settings.set_static_wallpaper.description" +default = true + # Headless background service: owns the mpvpaper supervisor and per-output assignments. [[service]] id = "service" diff --git a/mpvpaper/translations/en.json b/mpvpaper/translations/en.json index 7c9afe6..ea6e5ba 100644 --- a/mpvpaper/translations/en.json +++ b/mpvpaper/translations/en.json @@ -14,5 +14,7 @@ "settings.auto_pause.description": "Pause playback while a fullscreen window covers the wallpaper (mpvpaper --auto-pause).", "settings.mpv_options.label": "Extra mpv options", "settings.mpv_options.description": "Additional space-separated mpv options, e.g. panscan=1.0 video-zoom=0.1", + "settings.set_static_wallpaper.label": "Set static wallpaper", + "settings.set_static_wallpaper.description": "Set the video thumbnail as static wallpaper when selected.", "settings.glyph.label": "Glyph" -} +} \ No newline at end of file