programatically disconnect or change monitor settings on mac - swift

so - I have a bunch of different machines that I switch between using a usb switcher, and have a bunch of things like mouse, keyboard, camera, other monitors etc hanging off the USB - but the computers are all directly plugged into the big main monitor in various different ways.
I've written stuff in swift and c# for the various machines that detects the usb disconnection and turns off the main screen, and that works great, so it automatically flips to whatever new machine I've moved to - but with my mac laptop I've decided I want to keep the laptop screen as like a second machine and keyboard. The problem is - there's a hdmi connection to the big monitor - and I need the mac to stop sending hdmi, because the screen is now owned by someone else - so I suddenly want the mac limited to the laptop.
On windows it would be easy - you just disable the device, then re-enable it when the docking usb comes back - but I don't know how to do the same thing on the mac. Even from the display settings ui, I can't seem to say "don't use this monitor" - I can say "mirror the laptop display" - which may be good enough, but even that I don't know how to do from code.
so the actual question:
how do I programatically "remove" and then later "attach" a hdmi monitor
and set it as the main display
if that's not possible, how do I
programatically switch a monitor between mirroring and not mirroring
Ideally in swift, but python is also viable.
At the moment I literally have to pull out the HDMI from the laptop and then plug it in each time... which is not ideal.

Related

Ghost network adapters

Get-NetAdapter returns a bunch of adapters (about 15) which are not visible anywhere else in the system.
Looks like this:
HP hs3210 HSPA+ Mobile Broadband Device 37 Not Present
What are these, and how to remove them ?
Net adapaters are physical or virtual network devices in your system (not WIFi devices in you area as suggested by #jdweng). Unless you know what your doing, or have a clear goal in mind i would just leave the devices as they are or you risk breaking Windows.
Items returned by get-NetAdapter were detected/installed at some point. Things like HyperV, VMWare, Docker, VPN's etc as well as physical hardware like network cards, or bluetooth can all install devices like this. If you have physically removed or disabled a device in the BIOS of your PC you will still see traces of them - but honestly theres little advantage to removing them, but there is a risk of seriously breaking your Windows installation in weird ways (you have been warned :-).
If you really want to peruse deleting these devices take a look in the registry - HKLM:\SYSTEM\CurrentControlSet and its subkeys - this is ultimately where those devices are stored. Again, deleting stuff from the registry can have unintended as well as catastrophic consequences. (so backup your data, have a boot USB to hand etc before you start). good luck!
If they are genuinely physical devices that have been removed, there are several powershell scripts available that will remove "ghost" devices on your system that were once installed but now no longer have associated hardware. Just Google "powershell remove ghost devices".
I've adapted this one for use in my particular environment:
https://github.com/istvans/scripts/blob/master/removeGhosts.ps1
Take care, understand what the script is doing and test thoroughly. Only remove what is definitely not required.

Physical computer mouse, that can be controlled from anywhere in the world

Is there any smart device that can do the following:
It connects to PC like "normal mouse" via USB. And computer detects it like normal mouse.
It can directly connect via the Internet to another mouse and receive signals from it and control the PC like a normal mouse. And it would be great if no apps needs to be installed to PC.
Team viewer, hamachi and similar apps is not a solution because this apps are not allowed to use in my PC for work. This apps can be detected by security apps like Mobi Control/ Forcepoint Dlp etc. And they need system settings to be changed.
And i have the same question for keyboard.

Connect(control) Kodi Between Rooms?

Hello I am trying to work out how to set kodi up on my smart TV. My main problem lies with the TV being on the wall in another room too far away from power sources. She has sky installed and that was situated in the other room and with a HDMI lead fed under to floorboards to the other room by a professional someone or other. I am unable to feed another HDMI lead along the line.
Is there a way I could connect kodi by some other means to the TV? I am not really up on these things.
At the moment I have the kodi box in another room and I have to switch the sky lead to the kodi box to use. Also this means you have to be in the other room.
Can anyone suggest a way for me to get kodi working on the tv and be able to operate it via remote control?
I use Kodi on all of my TVs through an amazon fire stick. Most smart TVs have a USB on the back of the TV that can power the fire stick while its plugged into the HDMI so you wouldn't have to worry about power. I have a Sony bravia that will control the fire stick as long as I am on the input the fire stick is plugged into so no need for an additional remote.
To start off this is the wrong place to ask. This is a Q and A platform for programming questions and coding related questions.
To give you an answer though because I'm not a dick the best way to do it would be using a NAS. You would have two Kodi boxes but one media store.
I'm not sure which device do you use.
In my case, I installed Kodi on my Raspberry Pi(RPi) and TV and RPi are connected with HDMI. My TV is Samsung SmartTV, which supports HDMI-CEC. So, RPI can get RCU Key input from TV.
(HDMI-CEC allows devices connected to your TV through HDMI ports to communicate back and forth with your TV. )
In addition, you can customize keymaps for remotes in GUI by using the community Keymap Editor add-on.
https://kodi.wiki/view/Keymap
Check your TV supports HDMI-CEC, first.

Can I store a program on my mouse that runs when i connect it?

So various people around my house have been stealing my mouse and I was wondering if I could store a program on the mouse which runs whenever it's plugged in, asking you for a password. I know you can run a program stored on a computer when a device is inserted into a USB slot but that means I can't stop people using my mouse if the specific laptop he's using hasn't got the program installed.
Also, if this was possible, what language would use? I would like it to work on windows, linux and OSX to cover all bases.
Thanks for any help!

Debugging battery warning

I have an app that connects to an external accessory via Bluetooth. Testers have reported that the connection gets dropped when "Low Battery" alert is displayed. This was reported on iPod touch 2nd gen., so it may be peculiar to that device.
I am wondering if there is a way to run my app in debugger (connected to my computer) without charging the device. In other words, is there a way to disable USB charging of a device whose battery is not fully charged?
I have not tried it, but it is possible / likely you can do this by cutting the power cable within the usb cable.
I would buy a cheap usb extension cable (male <-> female), and carefully cut it open (remove the outer plastic in the middle of the cable without damaging the wires inside).
If you are lucky, there'll be a red cable, and that red cable will be the +5V line - if not, you'll have to use a multimeter to test which cable is pin 1 / +5V / VCC (pinout here: http://pinouts.ws/usb-pinout.html ). Once you identify it, cut that cable (and only that cable!).
Then plug your iphone/ipod into your PC using your new cable, and the iphone will hopefully still work with the debugger but will no longer charge.
As an aside, I could imagine the possibility that bluetooth is automatically disabled (or switched to a lower power mode) when the battery gets low - in which case losing the connection may be inevitable. You could try asking apple support if they are aware of anything like that.
Nope. The debugger only works when the dock cable is connected via USB to the development system, and that automatically causes the device to charge. You will have to find another way to monitor what your app is doing.
No, but you should have your user turn on logging on their test device and then send you the logs. (Or if you are that tester, turn on logging in the Settings app, under "Developer".)
Perhaps you can log the low battery message and the Bluetooth status as well.