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

Use processIdentifier to allow multiple screens #27

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 29, 2024

Closes #20

You can have multiple screens by either copying the app or by using open -n /Applications/DeskPad.app

But brings in a new set of problems..

  • Because the display is no longer the same on each run, macOS probably won't save the screen arrangement anymore (and you'll probably trash your hidden macOS config as it sees a new display on each run, so you accumulate more displays than normally possible).
    • A temporary solution might be to look for the number of application instances and only attach the PID if there is already another instance.
  • The index of each display is likely similar, but quite long; so it's hard to differentiate windows easily.
    • A temporary solution might be to include the bundle filename, so users can have their own names for virtual displays.

I also barely tested this (due to macOS permissions being problematic when running from xcode), but I'll probably have a couple of real-world use-cases in the next couple of months where I'll actually test this.


I'm not a swift coder, so this is just the bare minimum to get the ball rolling.

I've also tried or thought about other strategies for display-names / serial numbers:

  • Start at serial-number 1, then iterated over NSScreens.screens to find a free name, incrementing the serial-number on collisions: this would likely lead to race-conditions; it also needs more changes for communication between AppDelegate and ScreenViewController.
  • Use the bundle path as identifier, so users can have named displays and hash the bundle-path to get a unique serial number. Unfortunately, this would still break for multiple instances.

I think the best option would be to allow configuring the amount of displays the user wants for a single instance.
However, I don't know enough swift to actually work on this myself.

Hopefully someone is being nerd-sniped here to actually work on a proper implementation.

@agreenbhm
Copy link

I made a similar mod, though it has a static number of screens (4) rather than dynamic. I originally used a random number for the serial number which resulted in the arrangement not being stored since MacOS viewed each screen as different than it had previously seen. I ended up statically assigning serial numbers (1, 2, 3 ,4) so that they all go back to the previous arrangement.

Your setup is similar to my original problem with the arrangement due to the serial number being based on PID. I'd suggest instead of doing it on PID that you instead identify which instance number you have open, something along the lines of (pseudocode):

$serialNumber = $(listProcesses | find Deskpad | count) + 1

This way the serial numbers will be the same each time and you will retain your screen arrangement.

If you'd prefer a static number of screens, see my fork (which you can tweak to be +/- the 4 I have currently set. https://github.com/agreenbhm/DeskPad

@ghost ghost closed this by deleting the head repository Oct 28, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Allow opening multiple new displays
1 participant