noobscan.blogg.se

Brew hammerspoon
Brew hammerspoon






brew hammerspoon
  1. #Brew hammerspoon full
  2. #Brew hammerspoon code
  3. #Brew hammerspoon download

The ‘aMode’ parameter is either “w” for write(over) or “a” for write(append). The first function, ‘writeStringToFileWithMode’ is just a convenience function. "/Library/LaunchAgents/", myFolderWatch):start() Local aWatcher = hs.pathwatcher.new(os.getenv("HOME"). Hs.alert.show("Launch Agents folder was modified.") WriteStringToFileWithMode(str, this_path, "a") Local str = "Launch Agents folder was modified on ".

#Brew hammerspoon code

A code walkthrough follows.įunction writeStringToFileWithMode(aString, aPath, aMode) Here’s the code, also available from my pastebin here. Although there are, of course, many legitimate reasons for apps placing items in here, this folder is prime real estate for attackers as it is one of the locations that can launch processes at log in time without the user’s interaction (or knowledge).

#Brew hammerspoon download

In this example, the folder being watched is ~/Library/LaunchAgents since we want to be aware of any adware, malware or other unsavoury processes being surreptitiously added by, for example, apps we download from the internet. This way, even if you miss the alert, you’ll always have a record of what files have been added, deleted or modified in your watched folder. The write is an append: if the file doesn’t exist it will create it before writing if it does exist, it will append the latest changes and date to the file. In this updated function, it now also writes a list of the file changes to a (by default) file on the Desktop. The problem with the simple alert I demonstrated last time is that it only hangs around for a second or two (much less than a Folder Action alert, which takes a couple of minutes to time out). For two minutes work, you just added a very useful window switcher to macOS!įor anyone using Hammerspoon and folder ‘watchers’ to alert them to changes to a given folder, I’ve updated the watcher function I wrote about here Hs.hotkey.bind("alt-shift","tab",function()switcher:previous()end)Īdjust values such as shortcut bindings as you please, and that’s it. Hs.hotkey.bind("alt","tab",function()switcher:next()end) bind to hotkeys WARNING: at least one modifier key is required! Switcher = hs.() - default windowfilter: only visible windows, all Spaces

brew hammerspoon

As ever, the Hammerspoon docs are wonderfully clear and easy to follow (take a lesson, Apple!).

brew hammerspoon

Instead, I use the code below, which sets up the switcher’s ui as seen in the screenshots here with option tab and option-shift tab for shortcuts, but you can modify the appearance to suit your taste. The default code is a bit ugly for my liking. You can use the default code in hs.window.switcher docs or use mine below. With Hammerspoon up and running, adding the window switcher is just a case of cutting and pasting some code into your config file, saving it then reloading. But if you’re a regular reader of this blog, you’ll already have installed Hammerspoon after reading my earlier posts on it here and here and here.

#Brew hammerspoon full

Another advantage here is that the window switcher will include full screen and non-full screen windows in multiple spaces, which command backtick typically does not handle well, something I find particularly frustrating when using Xcode.Īdding a window switcher is easy and doesn’t require any hacking. This is particularly useful if you have a couple of windows open in several applications, and it is much faster and neater than first using command tab and then command backtick to cycle through an app’s windows. The window switcher allows you to jump between different windows, both those of other apps and the same app with a hotkey like option tab, which sits nicely next to command tab in my muscle memory! If you’re a big fan of the command tab Application switcher, you might enjoy adding a window switcher to your list of keyboard hotkeys.








Brew hammerspoon