RadAd / RMVirtualDesktop

Virtual desktop functionality for Rainmeter
MIT License
19 stars 3 forks source link

[request] expose path to VD's wallpaper #3

Closed 2bndy5 closed 1 year ago

2bndy5 commented 1 year ago

I'm opening this here because my rainmeter forums account seems to be locked (🤷🏼 haven't used it in years). I'm sorry if this is the wrong channel for user feedback/suggestions. I would've preferred to send this through the rainmeter post you created, but I can't login for some reason.

I have a skin that takes screen captures of the current VD for thumbnails (see 2bndy5/UbubtuWorkspaces_Rainmeter_Skin). But the screen-capture tactic is a bit flawed (using a run plugin/measure to invoke a compiled C# script).

I was wondering if the API allows for getting the path for a certain VD wallpaper. If not I guess I can hack something together that uses the windows registery (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops\Desktops), but the keys are hashed. The hashed keys (and corresponding values) don't seem to indicate which VD is which, so this hack would be rather complicated (& possibly flawed for other machines).

RadAd commented 1 year ago

Yes, it could be done. Obviously, it would only work on Windows 11. Could have a bang to set the wallpaper also.

2bndy5 commented 1 year ago

Excellent!

I can do testing if you need someone with a Windows 11 machine.

RadAd commented 1 year ago

I have created v1.4.0 with these features: https://github.com/RadAd/RMVirtualDesktop/releases/tag/v1.4.0

I haven't tested it Widows 11, give it a go and let me know.

2bndy5 commented 1 year ago

I'm a little unclear about how the new bangs are supposed to work. I think this plugin's !SetWallpaper might conflict with Rainmeter's builtin !SetWallpaper bang. The following still sets the wallpaper for all desktops (expected behavior):

LeftMouseUpAction=[!SetWallpaper "#CurrentPath#DownloadFile\Cache Image.jpg"]

I was more expecting another !commandMeasure option instead.

LeftMouseUpAction=[!CommandMeasure mVD SetWallpaper("#CurrentPath#DownloadFile\Cache Image.jpg")]

Although, a dedicated bang does seem more appropriate... Maybe change the bang name to something more unique to the plugin like set/getVirtualDesktopWallpaper?

RadAd commented 1 year ago

It has been implemented as a !CommandMeasure. They are called a bang in the plugin documentation.

Use it like this:

LeftMouseUpAction=[!CommandMeasure mVD "SetWallpaper 1 #CurrentPath#DownloadFile\Cache Image.jpg"]

Everything in the quotes is sent as one. The first parameter is the desktop number, you can use -1 for the current desktop. Spaces in the filename are a problem, I'm not sure how you embed quotes in the quoted part.

2bndy5 commented 1 year ago

Thanks, but I still get the following error in the logs:

Invalid Bang "SetWallpaper" (LCARS Door\Player\images.ini - [mVD])

And how can I use the return value from

[!commandMeasure mVD "GetWallpaper"]
RadAd commented 1 year ago

My guess from your first error is that you are not using the latest virtualdesktop.dll.

There is no return from the !CommandMeasure. To get the wallpaper use the measure variable like it is done with the name is demo skin:

ToolTipText=[MeasureVirtualDesktop:Wallpaper(1)]
2bndy5 commented 1 year ago

OK I was using the old DLLs, so I reinstalled the demo rmskin from v1.4.0. image

Now I get the following from the suggested setWallpaper "bang" (its the same if I remove the space in the image's path):

SetDesktopWallpaper 0x80070002 (LCARS Door\Player\images.ini - [mVD])
outdated feedback (see next comment) The suggested get wallpaper tactic does not raise an error in the logs, but the string value for the following measure is the path to the skin itself (`C:\Users\username\Documents\Rainmeter\Skins\LCARS`): ```ini [mVirtualDesktopWallpaper] Measure=string DynamicVariables=1 String=[mVirtualDesktop:Wallpaper(1)] ```

Spaces in the filename are a problem, I'm not sure how you embed quotes in the quoted part.

I don't think this is your problem to solve, rather it might fall to the skin author's responsibility. See the "Magic Quotes" section in this RM doc. However, I'm clearly not familiar with RM's plugin API.

2bndy5 commented 1 year ago

Oh nevermind about the get wallpaper tactic; that works well! I had a bad value set to the OS previously...

RadAd commented 1 year ago

The error 0x80070002 means it can't find the file specified. Are you using a valid file?

The "Magic Quotes" should work:

[!CommandMeasure MeasureVirtualDesktop """SetWallpaper 1 "#CurrentPath#DownloadFile\Cache Image.jpg" """]
2bndy5 commented 1 year ago

The path is valid; I have renamed the file to not use spaces (Cache_image.jpg). If I use magic quotes then the error doesn't show and the wallpaper doesn't change. However, I have another skin reading the wallpaper path (via the new plugin cmd) and that skin shows an error:

ImageName: Unable to open: C:\Users\username\Documents\Rainmeter\Skins\LCARS.png (UbubtuWorkspaces\panel.ini)

Its as if the parameter of the path is getting truncated after the #CurrentPath# var (& Rainmeter assumes any image without an explicit image format is a .png).

Enabling debug mode doesn't seem to show anything helpful.

2bndy5 commented 1 year ago

Application note: If I set the VD wallpaper manually (using Windows file explorer) then the image file is read every time I switch to the specified VD. Meaning, if people are downloading images from a RSS feed (like Bing/NASA Images of the Day) and saving them to the same file that was set as a wallpaper, then the wallpaper will auto-change to (or re-read) the latest image data and display the updated content when the user switches back to the VD.

Windows Photos app (& RM's !setWallpaper) both create a static cached copy of the file and set that cached image's path as the wallpaper's path.

RadAd commented 1 year ago

I updated it with some debugging logs: https://github.com/RadAd/RMVirtualDesktop/releases/tag/v1.4.1

You should be able to see what the plugin set/gets the wallpaper to/from.

2bndy5 commented 1 year ago

It would seem that magic quotes are required. These didn't work. It sets the wallpaper as the value of #CurrentFile#

LeftMouseUpAction=[!CommandMeasure mVD """SetWallpaper 2 "#CurrentPath#\DownloadFile\Cache_Image.jpg""""]
LeftMouseUpAction=[!CommandMeasure mVD "SetWallpaper 2 #CurrentPath#\DownloadFile\Cache_Image.jpg"]

Both of these resulted in just the value of #CurrentPath#

This works though:

LeftMouseUpAction=[!CommandMeasure mVD """SetWallpaper 2 "#CurrentPath#\DownloadFile\Cache_Image.jpg" """]

Notice the [required] space at the end of the path between the " and """

RadAd commented 1 year ago

Thats what I expected parsing """" would confuse it when you mean " """.

This also works:

LeftMouseUpAction=[!CommandMeasure mVD """SetWallpaper 2 "#CurrentPath#\DownloadFile\Cache_Image.jpg"""]

Note its just three quotes at the end.

2bndy5 commented 1 year ago

It may also have something to do with #CurrentPath#\ which resolves to path\to\skin\\

I now have the following working as well

LeftMouseUpAction=[!CommandMeasure mVD """SetWallpaper 2 "#CurrentPath#DownloadFile\Cache_Image.jpg""""]

Note the #CurrentPath#DownloadFile.

RadAd commented 1 year ago

Is everything working now? Can you set and get the wallpaper for each desktop?

2bndy5 commented 1 year ago

Yep! 🥇 So, I think that resolves this issue, unless there's something else you want me to test on Windows 11. Thank you so much for your hard work and patience!

RadAd commented 1 year ago

Glad its working.

2bndy5 commented 1 year ago

Oh I didn't realize that the space in the skin name ("LCARS door") was why I needed to use magic quotes.