Hi All! Rainmeter n00b here. I am trying to write an application that rotates the wallpaper of a specific monitor in my three screen Windows 10 monitor configuration. I can change the wallpaper through Rainmeter, but when I run the command it changes ALL the monitors. Is there a way to isolate it to just one monitor?
thanks!
It is currently October 14th, 2024, 9:29 pm
Assign Wallpaper to Specific Monitor
-
- Posts: 2
- Joined: July 10th, 2019, 5:25 am
-
- Developer
- Posts: 22856
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Assign Wallpaper to Specific Monitor
I don't know of a way. Certainly not with the built-in !SetWallpaper bang in Rainmeter. Perhaps there is some external utility that can set a distinct wallpaper on each monitor using the command line, which you might be able to do with Rainmeter, but I don't know of any such off the top of my head.
-
- Posts: 2
- Joined: July 10th, 2019, 5:25 am
Re: Assign Wallpaper to Specific Monitor
Would there be a way to fake it by creating a skin module that covered the entire screen of said monitor and just changing out the image of that? If i did that i assume if anything got put on the desktop I wouldn't be able to see it because it would cover it?
-
- Developer
- Posts: 22856
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Assign Wallpaper to Specific Monitor
Yeah, Rainmeter skins would always be in front of any icons or shortcuts on the desktop.DryLightning wrote: ↑July 10th, 2019, 2:52 pm Would there be a way to fake it by creating a skin module that covered the entire screen of said monitor and just changing out the image of that? If i did that i assume if anything got put on the desktop I wouldn't be able to see it because it would cover it?
-
- Posts: 1
- Joined: June 6th, 2024, 2:27 pm
Re: Assign Wallpaper to Specific Monitor
If you don't mind installing PS module FP.SetWallpaper , here is a simple approach:
In Powershell:
If the above does the desired effect for you then implement with something like the following .ini:
And this would be the SwitchWallpaper.lua script :
In Powershell:
Code: Select all
Install-Module -Name FP.SetWallpaper
# Print monitors
Get-Monitor
# 3 monitors and I wanted to set wallpaper only on 3rd so it was last in the list
Get-Monitor | Select-Object -Last 1 | Set-WallPaper -Path C:\MyGallery\img_01.jpg
Code: Select all
[Rainmeter]
BackgroundMode=0
Update=10000
OnRefreshAction=[!CommandMeasure MeasureScript "Initialize()"]
[Variables]
height=500
myWidth=(#height#*2 + 10)
myHeight=(#height#*2 + 10)
[MeasureScript]
Measure=Script
ScriptFile="#CURRENTPATH#SwitchWallpaper.lua"
[MeasureRunPowerShell]
Measure=Plugin
Plugin=RunCommand
Program=powershell.exe
Parameter=-Command "Get-Monitor | Select-Object -Last 1 | Set-WallPaper -Path 'C:\MyGallery\img_01.jpg'"
State=Hide
; To work properly Rainmeter needs one meter , put whatever you want
[MeterImage]
Meter=Image
ImageName=random.png
x=5
y=5
w=#myWidth#
h=#myHeight#
Greyscale=1
Code: Select all
-- Initialize function, sets up the initial values and reads currentIndex from a file
function Initialize()
currentIndex = 1 -- Initialize the currentIndex to 1
imageCount = 10 -- Total number of images available
-- Open the file 'currentIndex.txt' in read mode
local file = io.open(SKIN:MakePathAbsolute("currentIndex.txt"), "r")
if file then
-- If the file exists, read the content and convert it to a number
currentIndex = tonumber(file:read("*all"))
file:close() -- Close the file after reading
else
-- If the file does not exist, set currentIndex to 1
currentIndex = 1
end
end
-- Update function, increments the currentIndex and updates the desktop background wallpaper
function Update()
-- Increment currentIndex and loop back to 1 if it exceeds imageCount
currentIndex = (currentIndex % imageCount) + 1
-- Generate the new image path based on the updated currentIndex
local newImagePath = SKIN:ReplaceVariables("#CURRENTPATH#img_" .. string.format("%02d", currentIndex) .. ".jpg")
SetDesktopBackground(newImagePath) -- Set the new desktop background
-- Open the file 'currentIndex.txt' in write mode to save the updated currentIndex
local file = io.open(SKIN:MakePathAbsolute("currentIndex.txt"), "w")
file:write(tostring(currentIndex)) -- Write the currentIndex to the file
file:close() -- Close the file after writing
end
-- Function to set the desktop background using a PowerShell command
function SetDesktopBackground(imagePath)
-- Prepare the PowerShell command to set the desktop background
local psCommand = 'Get-Monitor | Select-Object -Last 1 | Set-WallPaper -Path \'' .. imagePath .. '\''
-- Execute the PowerShell command using SKIN:Bang
SKIN:Bang('!SetOption', 'MeasureRunPowerShell', 'Parameter', '-Command "' .. psCommand .. '"')
SKIN:Bang('!CommandMeasure', 'MeasureRunPowerShell', 'Run')
end
Last edited by Yincognito on June 6th, 2024, 4:13 pm, edited 1 time in total.
Reason: To post code, select it and click the </> button above the message box.
Reason: To post code, select it and click the </> button above the message box.