![]() ![]() This submodule allows hs.axuielement to support using AXTextMarker and AXTextMarkerRange objects as parameters for parameterized Accessibility attributes with applications that support them. This module allows you to access the accessibility objects of running applications, their windows, menus, and other user interface elements that support the OS X accessibility API. Watch for system level audio hardware events Inspect/manipulate the data sources of an audio device Watch for application launch/terminate events I’ve commented the code as much as I could, so hopefully it makes sense.Easily find hs.application and hs.window objects Reload hammerspoon config from its menu.Update ~/.hammerspoon/a to add this line: local gb = require('git-backup').If you face perf issues with pathwatcher, comment out above 2 lines - and uncomment below lines to use a timed sync instead - Time interval is set to 5 minutes (300 seconds) here but can be changed - as per need - notes_timer = hs.timer.doEvery(300, notes_sync) - dotfiles_timer = hs.timer.doEvery(300, dotfiles_sync) If not status then - Something went wrong! No internet? Didn't add ssh keys? hs.notify.show( "Notes Sync", "Git Push Error", output)Įnd end else - Check if the path exists, just in case something goes wrong or you move to a new machine etc hs.notify.show( "Notes Sync", "Cannot change Path", notes_path)Įnd - Use pathwatcher to instantly sync whenever a change is made notes_watcher = hs.pathwatcher.new(notes_path, notes_sync):start()ĭotfiles_watcher = hs.pathwatcher.new(dotfiles_path, dotfiles_sync):start() If status then output, status = hs.execute( "git push -u origin master", true) If hs.fs.chdir(path) then output, status = hs.execute( "git add. Paths to the directories we want to backup local notes_path = "/Users/shantanugoel/.config/joplin-desktop" local dotfiles_path = "/Users/shantanugoel/dotfiles" - The primary sync function local function sync(path) Save the below lua script to ~/.hammerspoon/a.Add my ssh keys to the ssh-agent using the ssh-add command.Add the upstream repositories to your local git repositories as remotes ( git remote add ).In my case, my dotfiles are public but my notes are private. You can create them as private if you want to. Create repositories on GitHub (and other servers as needed) to backup them to.Setup the directories of my dotfiles ( ~/dotfiles/) and notes ( ~/.config/Joplin-desktop/) as git repositories (by running git init inside them).What gives Hammerspoon its power is a set of extensions that expose specific pieces of system functionality, to the user. In its own words:Īt its core, Hammerspoon is just a bridge between the operating system and a Lua scripting engine. Hammerspoon is an extremely powerful tool for macOS. But I wanted to try out some more capabilities of Hammerspoon, so I chose that as my weapon of choice for this, especially because I already use it for few other automations so that’s one (or more) less things to install/maintain/update. I came across a tool called gitwatch, which can help do this. So, essentially I wanted to commit and push changes to my notes, dotfiles and few other things automatically whenever I make changes. Apart from being all kinds of nerds, I’m an automation nerd too, which is a fancy way of saying that I am lazy, but I digress. The only issue though is that every time I change something, which is pretty often (since I’m a tinkering nerd too) I’ve to manually commit the changes and push them upstream. Prime targets for this are my dotfiles that I edit in spacemacs and my notes that I take in Joplin. git serves as a good tool for me for versioning wherever small data/text files etc are concerned and then I back this up with remote git servers like my own git server on a raspberry pi at home, a gitlab server and a github server. Not just that, I like to version them too so I can go back in time to any point. I’m a backup nerd and like to back-up everything I do. ![]()
0 Comments
Leave a Reply. |