MScholtes / VirtualDesktop

C# command line tool to manage virtual desktops in Windows 10
MIT License
595 stars 59 forks source link

Provide "Toggle" option, to toggle between 2 virtual Desktops #41

Closed ruggi99 closed 1 year ago

ruggi99 commented 2 years ago

Great project this. Actually found because I needed to switch quickly between two virtual desktop with the same shortcut. But this feature seems to be lacking.

So my feature request is to add an option (maybe call it "Toggle") to actually toggle between 2 Virtual Desktops. So if the current desktop is the first, then the second will be selected and vice-versa. Unsure what to do if there are 3 or more desktops.

I implemented this myself (in less than 10 lines) and it works great. Implemented this in pipeline mode, changing rc variable. So in order to use this feature: VirtualDesktop /gcd /toggle /s

What do you think?

MScholtes commented 2 years ago

Hello @ruggi99,

this is a nice idea, but does not justify a new version of VirtualDesktop. In the next version I will implement this.

Greetings

Markus

ruggi99 commented 2 years ago

Thanks

widavies commented 1 year ago

@ruggi99

@MScholtes If you don't mind me posting this here, I created a keyboard shortcut wrapper around VirtualDesktop that does this. You could easily modify the keyboard shortcut to a toggle @ruggi99 . Right now it maps WINKEY+Number to desktops 1-10.

ruggi99 commented 1 year ago

Actually WINKEY + Number does trigger applications on application bar, so I don't really like your proposed solution. At the moment I've added a shortcut to the application bar that points To VirtualDesktop and it's shortcut is WINKEY + 9. And I've mapped the custom button on my mouse to WINKEY + 9.

widavies commented 1 year ago

That works too, you can pretty easily configure it to work with whatever keyboard shortcut you want. I don't use the trigger applications feature, so I went with remapping it, but in your case you could easily map just WINKEY + 9 to toggle it. Sounds like you already have it working through.

MScholtes commented 1 year ago

Hello @ruggi99,

I am currently thinking about the "toogle" switch. At the moment it is not clear to me how it differs from the "SwapDesktop" switch. Can you explain this?

Greetings

Markus

ruggi99 commented 1 year ago

I see what you mean but it has two drawbacks in my mind. First: is that it swaps desktop, when doing WIN + TAB I don't get the same order as before (not wanted in my feature request) Second: the command is not stable. So I cannot repeatedly give the same command to toggle desktops. Should be stable because you can make associate it with an hotkey and no matter is the current state (current desktop), it will toggle desktops

What I'm looking for is a switch and not a swap (swap might break something)

This is what I've done in your program:

case "TOGGLE":
case "T":
if (rc > 0) rc = 0;
else rc = 1;
Console.WriteLine("Toggled Virtual Desktop. New number is: " + rc.ToString());
break;

So if not zero, then set to zero, otherwise set to 1 in pipeline. Hope code explains better than my words. This is the minimun and basic code to create the feature I'm requesting.

VirtualDesktop /gcd /t /s

and this is the command line that I've associated with the hotkey. Always stable

EDIT: It works of course with only the first and second virtual desktop, but it's intented behavior

ruggi99 commented 1 year ago

@MScholtes what are your thoughts on this?

MScholtes commented 1 year ago

Hello @ruggi99,

this is a very specific requirement and I am considering whether it can be generalised. I don't have a clear idea about it yet, maybe an alternation between even and odd numbers or desktops? Or a number as an optional parameter to TOGGLE that specifies the desktop number to swap with 0?

What do you think about this?

Greetings

Markus

ruggi99 commented 1 year ago

I like the last idea. Maybe with a default, and so optional, argument of 1. So the command can be stable across multiple calls

ruggi99 commented 1 year ago

Hi @MScholtes, I just read your README again and noticed Wrap option that I didn't notice before. With Wrap and Left (or Right) I can achieve what I'm looking for, if I have only 2 desktops. Maybe my feature request has become useless?

MScholtes commented 1 year ago

Hello @ruggi99,

I suggest dropping the toggle option if you found another way. I then think about whether I can extend the calc option so that special requirements can also be met.

Greetings

Markus

widavies commented 1 year ago

@ruggi99

I added an update to my solution here https://github.com/widavies/WinJump that allows you to customize the shortcut and also adds in a toggle feature.

I think I agree with @MScholtes here that the toggle function doesn't necessarily belong in the VirtualDesktop library, it belongs more in the calling utility. In any case, you can give me library a shot and see what you think.