Turn On macOS Screen Remotely - macos

Is there a way to turn on the monitor remotely on macOS? I'm trying to write an app that will do this.
I've tried a couple of things but can't seem to find a way of triggering the screen to turn on after it has been turned off for power saving.
I've got a macOS app that advertises itself on the network via Bonjour. I can communicate to it via sockets, even when the computer is sleeping. However, I'm not sure what I can do from this macOS app that would trigger the screen to come on. I've tried sending a WoL packet and I've tried using Caffiene.
The macOS app doesn't need to pass Apple Review so I'm fine with using private APIs if necessary.

Related

Stay connected to code-server even when Mac is asleep or I move away from the PWA on iPad

VS Code has this new feature they’re rolling out where you can spin up a code server on your local machine. Essentially you just enter code-server into the terminal on Mac and you can connect via vscode.dev and you can add this URL as a Progressive Web App (PWA) to your iPad Home Screen.
My issues are:
Every time my Mac sleeps it shuts down the server
Every time I switch apps on my iPad I’m forced to reconnect
Is there any way to keep this server running even while my Mac is sleeping? Any way to maintain the connection even when I’m not in the web app?
I know this is a new product so any help is appreciated.

On macOS how can I open a gui .app hidden or off screen?

I have a cross platform need to open a gui application programmatically, but keep it hidden from the user. Effectively, I want a command line driven interface to act as a wrapper over this gui app, and insulate the end user from seeing or interacting with it. The program is from a third party, I did not write it, and I can't edit it.
I can do this one way or another on Windows, on Linux, and (in theory) on older versions of Mac, but not the most recent ones. On Windows, I can use the native api ShellEx with a hide window parameter. It's very easy and straight forward. In Linux, I can can render a gui app to a virtual frame buffer (using xvfb).
On macOS, the open command has a --hide and --background option, but they don't have any effect (at least on this app...)
I tried changing the plist file and found that LSUIElement will hide the app from the docker, but it still shows up on the screen. LSUIPresentationMode=4 or 3 OUGHT to work for exactly this, but apparently that doesn't do anything anymore as of a few os versions ago...
I tried the approach of moving the .app off of the screen with AppleScript. That works, but you have to manually grant permissions for such a thing to occur via System Preferences. In prior versions of Mac, those permissions could be twiddled on the fly via sqlLite (so long as you had sudo rights), but now they blocked that too. You can only pull that off apparently through a process of disabling "SIP" and forcing a reboot. That is totally outside the realm of what I want.
I've tried using the xvfb approach on Mac (jumping through hoops to acquire the binary they use to include stock, and now dropped), but I'm not having luck with that. I don't think it's possible to direct a mac .app to another display is it? A .app does not render on X11 by it's nature right?
What other clever ways might there be to hide a third party app on a mac? (and that still works in most recent os versions!)

Prevent disconnected display from merging windows into the active one

I've got a personal laptop (running Windows 10) which I use at work where I connect it to an external display using extended display mode. I keep all my personal icons and windows on my laptop display and store all the work-related windows on the external display. Whenever I unplug it, all the windows and icons from that display are merged into my laptop screen. I want to programmatically prevent changing anything on my primary screen when the secondary is disconnected. I'm currently writing a utility app for a variety of small productivity improving features and would like to add such feature in it. I can think of two ways to achieve this:
by tricking the system to think that the external display hasn't been
disconnected;
or take all the opened windows and icons on disconnected screen and put them on separate virtual desktop.
I was looking into Windows GDI Device Context Functions but haven't found anything about display connection/disconnection events. How can I detect display disconnection (and get that display's opened windows and icons)? Anything that can be done using C#, C++ or PowerShell scripts would be much appreciated!

Is it possible to get an app to open up when entering a beacon region / within range of a beacon/ibeacon

I'm exploring the end user experience for a beacon prototype but I'm struggling to find any end-user scenarios that involve the app becoming active / opening up on the screen when within range.
I can get the app to send a notification and this is the most likely experience on both Android and iOS but does anyone know if it is possible to get the app to open up?
It's unlikely that I'd want real customers to have their experience interfered with in this way, I think it's ok if the app is already running and is open but not if it's running but not open.
Thanks
On Android this is possible. The reference app for the Android Beacon Library demonstrates how to do exactly this.
On iOS, it is not possible due to OS security restrictions. See here for details. The best you can do is send a local notification to the user when the beacon is detected, then if the user gestures to it, bring up the app.

Way to Programmatically Reboot iOS Device?

Basically, I'm looking for any way to go about this at all, no matter how cumbersome or unintuitive, so long as it can be done on iOS 7 (which the third party SBSettings framework currently cannot), and can be done on a non-jailbroken device.
This is for an app which will be loaded into iPads in a physical enclosure so the power button is inaccessible. The device itself will be in single app mode, which cannot be enabled or disabled except through our network-accessed MDM solution. The issue I'm trying to find a way around is that every now and then, the network connection stops functioning and the only way to re-establish it is to restart the device, which can't be done without an internet connection other than to physically press the inaccessible buttons. The reboot action would be password-locked in a hidden event handler and so inaccessible to normal users. This is not an app that will ever see the app store, so Apple's user interface guidelines don't necessarily apply.
Alternatively, is there any way to enable/disable assistive touch programmatically or any other possible method that will enable rebooting the device while in single app mode without physically touching the power button?
This is not a real answer (just thinking aloud).
Obviously, you can't do this through public API.
I believe, API's like SBReset can't do this either, because they are protected by entitlement.
I believe your simplest option to find some reasonably low level API which crashes and use it to crash a device.
I had exactly the same question some time ago:A way to reboot iOS device or restart Springboard using private API?
P.S. I don't have a way to find these crashes. I would recommnd to talk to jailbreak community (people who come up with jailbreaks for iOS devices). They collect all kinds of crashes. Most of these crashes aren't exploitable. However, you don't need an exploit, you just need a OS crash.

Resources