How to ensure that windows opened from the Dock open in the current Space/Desktop
A Mail window was in the Dock, and I clicked on it to restore it to my current Desktop. Instead of opening where I can see it, it went to some other Desktop, presumably the one it was in when it was minimized.
I use different Desktops for different projects, where one Desktop may have multiple browser windows, multiple text editors, etc., so I've disabled the default setting of "When switching to an application, switch to a Space with open windows for the application", because that seems to only make sense if you use an approach of one Space per Application, which makes no sense for me. As far as I can tell this is the only setting I'm using that may be relevant to this problem, but I really really don't want to have OS X forcing me to constantly switch spaces and force me into a one-space-per-app model.
Is there some way to make the window I restore (de-minimize) appear in my current Space/Desktop? It could be
- a hidden preference that I set with
defaults write
; - an AppleScript that I have to trigger after restoring the window, to move it to my current Space/Desktop;
- some utility application meant to handle this problem
- some other workaround or solution I hadn't thought of.
(An AppleScript would probably be the least desirable approach, but it could be triggered with Alfred, QuicKeys, or BetterTouchTool, etc.)
It might also be worth mentioning that I'm using Yosemite because of problems between El Capitan and TotalSpaces2, but I'd like to know if upgrading solves this problem.
⌘ Command "click" on the minimized window in the dock, and it will restore (de-minimize) in the current workspace, regardless of which space it was on when it was minimized.
Possibly this helps your situation:
defaults write com.apple.Dock workspaces-auto-swoosh -bool NO; killall Dock
I managed to get this working with some help from koekeishiya's yabai.
First we disable the workspaces swoosh as @mahal tertin mentioned:
defaults write com.apple.Dock workspaces-auto-swoosh -bool NO; killall Dock
Then we add this bit of code to our .yabairc
file:
yabai_query_current_space="\$(yabai -m query --spaces --space | jq '.index' )"
yabai -m signal --add event=window_deminimized action="yabai -m window $YABAI_WINDOW_ID --space $yabai_query_current_space"
Effectively, this instructs yabai to send a deminimizing window to the current space when it receives a deminimize event.
Depends on having yabai
and jq
installed.
ref: https://github.com/koekeishiya/yabai/blob/master/doc/yabai.asciidoc#signal