Comments (1)
It's not ideal, but if you need to, you can control FluffyDisplay by selecting its menu items through the Accessibility API. I tried to write an example of doing this with AppleScript's GUI scripting features, but I couldn't figure out any way to keep the script from hanging for several seconds after opening the menu. However, if you're open to installing Hammerspoon, something like this should work:
Example Hammerspoon code to turn on FluffyDisplay
-- don't create a display if there's already one (e.g. when reloading Hammerspoon config)
if not hs.screen 'FluffyDisplay' then
local fdResolution = {w=1920, h=1200} -- <-- fill this with the resolution of the virtual display to create
local fdBundleID = 'fi.iki.tml.FluffyDisplay'
local fdApp = hs.application.get(fdBundleID) or hs.application.open(fdBundleID)
local fdAxApp = hs.axuielement.applicationElement(fdApp)
-- wait for menu to appear in menubar
local fdExtrasMenuBar
for i = 1, 100 do
fdExtrasMenuBar = fdAxApp.AXExtrasMenuBar
if fdExtrasMenuBar and fdExtrasMenuBar[1] then break end
hs.timer.usleep(10000)
end
if not fdExtrasMenuBar then error "Couldn't get FluffyDisplay's AXExtrasMenuBar" end
local fdMenuBarItem = fdExtrasMenuBar[1]
-- Normally, fdMenuBarItem:doAXPress() below seems to hang until the menu closes again, or the call times out.
-- Make that timeout happen immediately, so we can start messing with the menu inside.
-- This is the part I couldn't figure out how to do from AppleScript.
fdMenuBarItem:setTimeout(0.1)
-- Click the menu icon, because the menu doesn't exist until it's opened.
fdMenuBarItem:doAXPress()
-- Click on 'New' to open the submenu. The submenu already exists by this point, but if I don't
-- open it, selecting the item inside does nothing for some reason.
local fdMenu = fdMenuBarItem[1]
local fdNewMenuItem = fdMenu[1]
fdNewMenuItem:doAXPress()
-- Find the menu item for the desired resolution, and click it.
local fdNewMenu = fdNewMenuItem[1]
local fdNewCommandMenuItemPattern = ('^%d×%d %%('):format(fdResolution.w, fdResolution.h)
-- ^- e.g. '^1920×1200 %(' ^- note: Unicode MULTIPLICATION SIGN, not letter 'x'
local fdNewCommandMenuItem = hs.fnutils.find(fdNewMenu.AXChildren, function(item)
return item.AXTitle:match(fdNewCommandMenuItemPattern)
end)
fdNewCommandMenuItem:doAXPress()
end
Set Hammerspoon to run at login, grant it Accessibility access, and add the code above to ~/.hammerspoon/init.lua
. (Or put it in e.g. ~/.hammerspoon/startFluffyDisplay.lua
, and add require 'startFluffyDisplay'
to ~/.hammerspoon/init.lua
.) It should automatically create a display as soon as you're logged in.
from fluffydisplay.
Related Issues (13)
- It works on macOS 11 HOT 4
- Feature Request: NDI support HOT 1
- "New on peer" - What is the usage of this function? HOT 4
- [Feature Request] Custom resolution HOT 1
- prevent virtual display from becoming the main display
- FluffyDisplay no longer works under macOS Sonoma HOT 4
- Custom resolution requires HOT 3
- How do you "Start FluffyDisplay" HOT 7
- [Feature Request] Custom Resolutions HOT 7
- Add use case description: screen for sharing during video calls HOT 5
- Screen resolution is lower than requested
- Virtual screens just pure yellow
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluffydisplay.