setup-your-mac / Setup-Your-Mac

Setup Your Mac aims to simplify initial device configuration by leveraging swiftDialog and Jamf Pro Policy Custom Events to allow end-users to self-complete Mac setup post-enrollment.
https://snelson.us/sym
MIT License
231 stars 52 forks source link

Dynamic Window Height for Build Dialog #154

Closed sjbarkey closed 3 weeks ago

sjbarkey commented 3 weeks ago

Is your feature request related to a problem? Please describe. When building a VM in VMware Fusion Pro, the build workflow takes place prior to VMware Tools being installed, which forces the VM to run at 1024x768 resolution. Unfortunately, this means that the button at the bottom of the build dialog when when the deployment completes is off-screen and can not be clicked.

Describe the solution you'd like Dynamically detect the screen resolution prior to the start of the build dialog being displayed and use a lower/higher height value based on the resolution.

Describe alternatives you've considered

Additional context I can provide screenshots if that would help.

dan-snelson commented 3 weeks ago

Greetings, @sjbarkey

Search the script for height and change to your liking.

Thanks.

sjbarkey commented 3 weeks ago

@dan-snelson Is it possible to have the script dynamically set the height based on the screen resolution?

dan-snelson commented 3 weeks ago

See Custom Window Sizes

liquidz00 commented 3 weeks ago

@sjbarkey In full transparency, I am not incredibly versed in Swift so there may be a more efficient way of achieving this. For your use cases, you may be able to implement this function into a local clone of SYM on your machine in the event it doesn't make sense to integrate with the full project:

import Foundation
import AppKit

func getScreenResolution() -> (width: Int, height: Int) {
        if let mainScreen = NSScreen.main {
            let resolution = mainScreen.frame
            return (Int(resolution.width), Int(resolution.height))
        } else {
            return (0, 0)
        }
    }

I tested this on a 14" MBP and a M2 Mac Mini and it returned the proper results.

sjbarkey commented 1 week ago

@dan-snelson Thank you! I'm not sure how I missed that as I have read that section several times and somehow glossed over the percentage option entirely! 🤦‍♂️

@liquidz00 Thank you for the script! I will definitely get it a shot if the percentage option doesn't work for our use case during testing.