Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to create a number of empty desktops on launch #69

Closed
Aran-Fey opened this issue Feb 26, 2021 · 5 comments
Closed

Add ability to create a number of empty desktops on launch #69

Aran-Fey opened this issue Feb 26, 2021 · 5 comments

Comments

@Aran-Fey
Copy link

I don't like to create desktops on demand, so I would like the script to create 9 empty desktops when it's launched.

I've achieved this with the following code:

createInitialDesktops()
{
    global DesktopCount, CurrentDesktop, NumInitialDesktops

    OutputDebug, Creating %NumInitialDesktops% initial desktops

    Current := CurrentDesktop

    Loop, % NumInitialDesktops - DesktopCount
    {
        createVirtualDesktop()
    }

    OutputDebug, Switching back to desktop %Current%
    _switchDesktopToTarget(Current)
}

The problem with this solution is that NumInitialDesktops must be hard-coded inside the main script, and can't be imported from user_config.ahk. A potential solution could be to introduce a new script user_variables.ahk. (And rename user_config.ahk to user_hotkeys.ahk?)

@Elijas
Copy link
Collaborator

Elijas commented Feb 27, 2021

Hi! Thanks for reaching out.

Add this to user_config.ahk

global NumInitialDesktops = 9
createInitialDesktops()

Add this to desktop_switcher.ahk

createInitialDesktops()
{
    global DesktopCount, CurrentDesktop, NumInitialDesktops

    OutputDebug, Creating %NumInitialDesktops% initial desktops

    Current := CurrentDesktop

    Loop, % NumInitialDesktops - DesktopCount
    {
        createVirtualDesktop()
    }

    OutputDebug, Switching back to desktop %Current%
    _switchDesktopToTarget(Current)
}

It should work, I haven't checked it. Please let us know if it solves it for you.

P.S.
It could be argued that having it like this in the user_config.ahk:

createInitialDesktops(9)

would be a nicer implementation

@Aran-Fey
Copy link
Author

Oh, I like the createInitialDesktops(9) idea.

Will you include the createInitialDesktops functions in the script, or will users be required to copy/paste it from here if they want this feature?

@Elijas
Copy link
Collaborator

Elijas commented Feb 27, 2021

Thanks for your suggestion!

We try to keep the codebase as minimal as possible to keep the usage and modification of the script usable and accessible. However, I add all these suggestions and solutions as optional modifications in the README.md, I've added your suggestion with the link as well if anyone would like to modify it this way.

Let me know if you'll have any more questions/suggestions and thanks for being part of the community 👍

@Elijas Elijas closed this as completed Feb 27, 2021
@Elijas Elijas reopened this Feb 27, 2021
@Aran-Fey
Copy link
Author

Okay, in that case, for the people who can't program, here's a piece of code that can be pasted into user_config.ahk (make sure to put it at the top of the script):

createInitialDesktops(NumInitialDesktops)
{
    global DesktopCount, CurrentDesktop

    OutputDebug, Creating %NumInitialDesktops% initial desktops

    Current := CurrentDesktop

    Loop, % NumInitialDesktops - DesktopCount
    {
        createVirtualDesktop()
    }

    OutputDebug, Switching back to desktop %Current%
    _switchDesktopToTarget(Current)
}

createInitialDesktops(9)

@Elijas
Copy link
Collaborator

Elijas commented Feb 27, 2021

Thanks :) Feel free to close the issue if it has been resolved 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants