You can use apps to accomplish this. I've used Spectacle (http://apple.stackexchange.com/a/66936) and it works really well for this.
More recently, I started using Hammerspoon (http://www.hammerspoon.org/) as it allows you to make your own shortcuts and macros. Very powerful.
You can do all this with Hammerspoon. It takes relative minor efforts to write and setup your own configuration (written in Lua). You can also look at sample configurations to get a better idea. I basically have one "only mbp" layout and one "mbp + external display" layout. Both are tied to specific hotkeys, so when I get home, I connect the mbp to the monitor, hit the dual screen layout hotkey, and voilà. Handling spaces is less trivial though, but there are ways to do it.
What and how many keys are you trying to remap? Want to just swap the command key and option because you've got an old PC keyboard laying around? Want to turn off Caps-Lock? Go to system preferences -> keyboard - modifier keys and change those there.
Karabiner is free (you are suggested to donate but no one is checking on you, however always contribute something to the software community you use, its good Karma). There's also Keyboard Maestro that works under High Sierra, Hammerspoon...
You can do this via Hammerspoon, http://www.hammerspoon.org
I have some things occurring on battery mode, also when the WiFi is not my home WiFi.
Others have listed some nice options.
Personally, I’m partial to Hammerspoon. You can configure it and script all kinds of things in Lua. I have keyboard shortcuts for pseudo-tiling windows, and window switching, and you can do a whole lot more if you want to.
Here’s my config.
It really is too bad that OS X is non-Free, because it's by far the best Unix desktop environment. It lacks some customizability, but with a few third party utilities, it's fantastic.
I have a bunch of Hammerspoon scripts for keyboard-based window management. I can send a window to my secondary monitor, snap it to predefined size/positions (50% left or right, a 25% quadrant in any corner, a large and centered, or full screen), open a fresh terminal window with a keystroke, and switch windows with Pentadactyl/Vimium style hints (with a custom callback to snap the mouse cursor to the window in question). I even made a "nudge mode" I can activate to bump the window around with HJKL and resize it from the bottom left corner with shift and HJKL, before exiting the mode with escape or return. Coupled with the built-in Exposé and virtual desktop features, it's fantastic.
OS X is 100% Unix, and you can grab just about any utility (GNU or otherwise) you need once you get a package manager like Homebrew installed.
It's great, all around. My only real complaints are the non-Free nature and the fact that if I built a desktop, I couldn't just run it on there without jumping through hoops and having it be ill-supported. For that reason, Linux is my only option for a desktop. Because OS X and Linux are the only platforms I can get things done on. When you're one of those people who practically lives in terminal windows...Windows is just a toy OS.
I haven’t tried anything quite like this, but it seems like you’d be better served by using window filters to filter by the current space?
http://www.hammerspoon.org/docs/hs.window.filter.html
specifically http://www.hammerspoon.org/docs/hs.window.filter.html#defaultCurrentSpace
For the case you speak of, I would recommend an entirely different piece of software, Hammerspoon. Minimal Lua knowledge should get you by just fine, and you can likely even just cobble something together from different parts of their Getting Started Guide. The main reason I suggest this is that it can make use of native macOS notifications, which in my opinion would be better in your situation.
This is a golden opportunity to learn a little bit of useful coding. I googled hammerspoon example and I found a webpage that helps you get started. Lua is often used, not alone, but as a script for controling other programs. So you might want to start by doing a simple example from their page.
I just quickly hacked up a little configuration snippet[0] for Hammerspoon[1] to watch that URL, display the currently supported regions on my desktop background (think GeekTool) and iMessage me when it changes :D
Edit: Had to re-pastebin, for some reason my paste was removed.
For someone willing to get their hands dirty with some scripting, Hammerspoon allows you to do some amazing automation of your window management. You can do things from simple hotkeys to open apps up to automatically laying out windows based on wifi/bluetooth/display connections.
As an alternative on macOS there is Hammerspoon. It’s based on Lua and there are many libraries to interact with aspects of the system. Highly recommended (especially if you like typing window managers). http://www.hammerspoon.org/
> This is a tool for powerful automation of OS X. At its core, Hammerspoon is just a bridge between the operating system and a Lua scripting engine. What gives Hammerspoon its power is a set of extensions that expose specific pieces of system functionality, to the user.
I don’t know if all functionality works on the latest MacOS versions.
You could use the hs.osascript module in Hammerspoon and use AppleScript to inject JavaScript on some hotkey:
lua
hs.hotkey.bind({ "alt", "cmd", "shift" }, "s", function()
hs.osascript.applescript([[
tell application "Safari"
set js to read ("/Users/QualitativeEasing/bookmarklet.js") as text using delimiter linefeed
do JavaScript js in current tab of first window
end tell
]])
end)
The AppleScript for Chrome would look only a little different, you'd tell application "Google Chrome"
and the do JavaScript
line would instead be execute front window's active tab javascript js
.
in system prefs > displays, click the ‘gather windows’ button to bring everything to the active display
however, since window position behavior depends on the app, you can use Stay to force windows into position & display, with automatic or hotkey driven action
if you want a more advanced window manager, try hammerspoon
You can build any otp software yourself. The algorithm is extremely simple. If you have a mac you generate the codes using the Token library in Hammerspoon.
I extracted some open source code into Hammerspoon Spoons that does exactly this. Take a look at:
http://www.hammerspoon.org/Spoons/Token.html
And
Glad you found a solution.
​
Ps. There's actually a hammerspoon module for sending pings, not sure if you'd find it useful: http://www.hammerspoon.org/docs/hs.network.ping.html
​
Another option would be to use a hs.timer to send pings at a specific interval, and you could even use hs.menu to display the last result in the menubar. Let me know if that interests you, I guess it depends on your use case.
I've found that hammerspoon could be used for window management, but didn't tried it yet, I've replaced magnet with chunkwm by now, but I'm willing to find a more solid solution if it's possible
If someone is interested there is /r/hammerspoon/ as well
If you're a mac user you can try hammerspoon. It's perfect for adding a hot key to do something. I've even got one that does this: ¯_(ツ)_/¯
Edit: Looks like I need another hotkey for reddit so it does this: ¯\_(ツ)_/¯
Yeah Karabiner is one of the biggest casualties of updating to Sierra for me. If you're willing to get your hands dirty with some Lua, check out Hammerspoon— you can use it to automate/map/trigger just about anything.
Every 300 seconds i need it it to type #!mine enter, #!chop enter, #!forage enter, #!fish enter.
So for enter it means to press keyboard enter like submit it in a chat bot
The Lua should work for Hammerspoon. http://www.hammerspoon.org/
It is an empty shell (no predefined bindings) so you could still use it with another WM for some features only. Take a look at the Getting Started Guide and the API doc to get an idea of what it can do.
If you want the ultimate programmatic control over OS X, then THE must-have tool is Hammerspoon. An amazing piece of software, incredibly well thought out and impressively well maintained. OS X is almost unbearable without it.
I've been using kwm for a while now, but there's also Hammerspoon, which can do more but takes more configuration. As for the dock, you can just turn hiding on and not use it, but I'm not sure about running apps in the menubar.
Pretty nice, but there are definitely things you could improve. My favourite (and easiest) things to do are to set both the menu bar and dock to auto-hide. Both of these can be done through System Preferences, and it really cleans up the look and gives you more space to work with. Another easy thing is to set the Appearance option (in General) to graphite to get rid of those awful traffic lights. Lastly would be to get iterm2-borderless, it looks much cleaner than the standard iTerm. If you want to get some keybinds set up, check out Hammerspoon!
The official docs on that say it returns one or multiple hs.application objects. If you think you should be getting multiples back, remember Lua can have multiple return values foo, bar, baz = functionWithMultipleReturnObjs()
- which the hs.application.find
uses.
Once you get reference to the all the hs.application
objects - you can manipulate each one with the methods here.
Damn, I guess that means Hammerspoon should have been more explicit about how to select it...Yes! Hammerspoon is only for Mac, it's crazy that I just discovered this (http://www.hammerspoon.org/) the main use for me has been to create custom window layouts for Android Studio in particular so that it arranges all my IDE windows and my emulator window perfectly (especially powerful cause I can program different arrangements based on how many monitors my computer is connected to).
Yeah, use HS for that! :) Look at my function called "ext.utils.spacesDots" - it uses hs.drawing to display little dots at the bottom of every screen, just like on iOS. If you search for hs.drawing around github you'll find people doing other cool stuff with it, and there's better handling of ASCII coming up, so you can run shell scripts which return colors and display them on your desktop. Check out the docs here: http://www.hammerspoon.org/docs/hs.drawing.html I think hammerspoons github issues and google group is best place to ask. Please post there when you develop your bar, I'd love to see it!
I use my 12" rMB for coding and compiling my app (shameless plug, http://www.hammerspoon.org ) and it's fine. It's obviously not as fast at compiling as my 15" rMBP, but compiling something is about more than raw CPU grunt, IO also matters, and the rMB is no slouch at IO.
I run the screen at the 1440x900 mode and it is more cramped than the 1920x1200 mode I run my rMBP in, but this is a portable machine for when I'm not at my desk, so it's fine for me :)
I wouldn't want it as my only machine though, I'd get a 13" rMBP if I had to compromise.
I prefer hammerspoon over Amethyst. Hammerspoon gives you the simpler level of control like Xmonad.
I wish I could use Haskell in Hammerspoon, I find Lua lacking in comparison.
Wow, this app family has really improved over the years. I left because I was not a fan of it, but they have really stepped it up. So far, I am only using it for the Spaces function, for I prefer Hammerspoon, but for non-programmers, this tool is amazing. Thank you so much for solving the issue!
we use "hs" as a namespace for all the modules that ship with Hammerspoon, that expose some kind of functionality for users: http://www.hammerspoon.org/docs/ has the full API docs for what we ship on top of the Lua built-ins.
The x_pos and y_pos values are co-ordinates on the screen where you want the click to happen (specifically, absolute co-ordinates, which in OS X means a co-ordinate space that includes all active monitors, with 0,0 being the top left of the primary display, where the menubar/dock live).
I just picked crazy 1234567890 values to try and suggest a "you need to change these" response :D
(Edit: for clarity, hs.geometry.point() is just a convenience function that takes two parameters and turns them into {["x"]=param1, ["y"]=param2}. We do similar things for rects/sizes just because it's a bit of a pain to type out the table by hand)