It is currently October 24th, 2021, 9:16 am

How to create a workspace switcher in Rainmeter?

Get help with installing and using Rainmeter.
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am
Location: Norway, Tromoy

How to create a workspace switcher in Rainmeter?

Post by BlueJive »

Hi all,

I'm currently trying to code a theme based on a Unix creation, through Rainmeter. All going well! But I'd like to know how to set up a simple workspace switcher in Rainmeter. The code I'm going for is not to slide backwards and forwards between desktops but instead to switch to either 1,2,3 or 4. It's not necessary to create the virtual desktops, only to switch to them (however on a side note, that could be a nice feature).

See below for a pic of what I'm getting at:

Image

Each pacman ghost icon would preferably take me to a set virtual desktop in ascending order.

Whether this is possible through the autohotkey plugin, or an .ahk/.exe file I don't know. What I'm requesting is some help with the code, and how to code it. I appreciate that there have been other forums dedicated to thsi subject, but none of them describe how to do something like this. And with two of them, their code didn't work for some reason...

Thanks, and stay safe :welcome:
Last edited by BlueJive on February 25th, 2021, 9:27 am, edited 1 time in total.
User avatar
deflore08
Posts: 189
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: How to create a workspace switcher in Rainmeter?

Post by deflore08 »

I never though about this feature, but i guess it could be reached with RunCommand plugin and PowerShell virtual desktop commandlets combo. :)
Image * Image * Image
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am
Location: Norway, Tromoy

Re: How to create a workspace switcher in Rainmeter?

Post by BlueJive »

Right... Sorry. How do I use PowerShell virtual desktop commandlets tool? The page was rather unclear. Thanks :thumbup:

Edit: Sorry to be pedantic but wouldn't an autohotkeys plugin be better? Or even something like https://github.com/pmb6tz/windows-desktop-switcher? Only because they seem to be more widely used.
User avatar
deflore08
Posts: 189
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: How to create a workspace switcher in Rainmeter?

Post by deflore08 »

:)))

This thing looks like a solution.

Open PowerSHell with admin previlegies (Win+X combo) then type:

Code: Select all

Install-Module VirtualDesktop
After that you able to use VD cmdlets. Example of using could be.. something like..

Code: Select all

[switcher]
 Measure                          = PLUGIN
 Plugin                           = RunCommand
 Program                          = PowerShell
 Parameter                        = Switch-Desktop #NUMBER#
 State                            = Hide
In my case i have 2 VD - 0 and 1. :) So i can switch between them by Switch-Desktop 0 and Switch-Desktop 1. Hope it will help. ))

Good idea, by the way.. Thank you. :) :oops:
Image * Image * Image
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am
Location: Norway, Tromoy

Re: How to create a workspace switcher in Rainmeter?

Post by BlueJive »

So here's what I got, obviously this won't work, I just wanted to figure it out

Code: Select all

[ghost1]
MeasureName=switcher
Meter=Image
ImageName=#@#Icons\ghost.png
H=13
LeftMouseUpAction=["something something"]

[switcher]
Measure=PLUGIN
Plugin=RunCommand
Program=PowerShell
Parameter=Switch-Desktop 2
State=Hide

[Rainmeter]
Update=1000
Group=Widgets
What do I need to add/change? And what's the hide state for?

(Oh, and thanks for being so helpful btw. I appreciate it)
User avatar
deflore08
Posts: 189
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: How to create a workspace switcher in Rainmeter?

Post by deflore08 »

You must send command to the measure. :)

LeftMouseUpAction=[!CommandMeasure switcher "Run"]

Hide state needed to run shell in background, it hiding annoying shell window. :)

Correct code under spoiler:

Code: Select all

[Rainmeter]
Update=1000

[ghost1]
Meter=Image
ImageName=#@#Icons\ghost.png
H=13
Group=Widgets
LeftMouseUpAction=[!CommandMeasure switcher "Run"]

[switcher]
Measure=PLUGIN
Plugin=RunCommand
Program=PowerShell
Parameter=Switch-Desktop 2
State=Hide
Last edited by deflore08 on February 25th, 2021, 8:23 am, edited 2 times in total.
Image * Image * Image
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am
Location: Norway, Tromoy

Re: How to create a workspace switcher in Rainmeter?

Post by BlueJive »

Okay, so when I launched the skin, it hides. I also disabled the hide state just to test it, but even just having the plugin enabled hides it. Is this right? But how do I click it if it's hidden. :confused:
User avatar
deflore08
Posts: 189
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: How to create a workspace switcher in Rainmeter?

Post by deflore08 »

BlueJive wrote: February 25th, 2021, 8:19 am Okay, so when I launched the skin, it hides. I also disabled the hide state just to test it, but even just having the plugin enabled hides it. Is this right? But how do I click it if it's hidden. :confused:
It hides, because you used "switcher" as MeasureName in your ghost1 meter. My opinion, you'll see an error in Raimeter's log. Try the code above, should work correctly.
Image * Image * Image
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am
Location: Norway, Tromoy

Re: How to create a workspace switcher in Rainmeter?

Post by BlueJive »

Great! Thanks so much, it's not hiding now. But it's not switching the desktop... I am on desktop number 1 and I'm assuming it should take me to number 2... But nada
User avatar
deflore08
Posts: 189
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: How to create a workspace switcher in Rainmeter?

Post by deflore08 »

BlueJive wrote: February 25th, 2021, 8:25 am Great! Thanks so much, it's not hiding now. But it's not switching the desktop... I am on desktop number 1 and I'm assuming it should take me to number 2... But nada
Try to open PowerShell window and type manually first.

Switch-Desktop 0, Switch-Desktop 1, Switch-Desktop 2 etc. Look where it will lead you. :)) I guess i'll lead you to 0 and 1 desktops, because.. Arrays begins from 0. :)))))
Image * Image * Image