UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

is it possible to make an app open on display 2 in full screen mode?

Forums > macOS

I have a SwiftUI app that we are using as a full screen display in a kiosk. The mac mini running the kiosk has two displays. the kiosk display is set as display 2. The management display is display number 1. Is it possible in code to make the app always launch full screen, and to always launch on display #2? It would be nice if we could reduce the launching instructions for the person driving the kiosk to one double-click instead of double-click the icon, drag the title bar to display 2, click on the green button to go full screen...

so far the best work around I've found is using an applescript that always stays open and moves and resizes the window whenever the kiosk app launches. but that's kind of tenuous.

3      

@TimD  

I'm not sure how to do this in SwiftUI but in macOS to make an app open in a specific desktop or space, right-click on the Kiosk app in the Dock and choose Options and assign it to the desktop you want to use. In Mission Control settings you need to make sure your secondary display has its own space.

I used to force apps to open in fullscreen by editing the Info.plist and setting NSApplicationPresentationMode to 4.

3      

To ensure your SwiftUI app always launches full screen on display #2, follow these steps:

  • Create an AppleScript that positions and sizes the window on display #2.
  • Use the do shell script command in AppleScript to execute a shell command, adjusting the window's position and size as needed.
  • Launch this AppleScript at startup to automate the process.

This approach reduces launching instructions for the kiosk operator to a single double-click on your app's icon.

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.