Love Picol, and love this! When I first revisited Tcl, I was a bit miffed about needing [expr] but now really appreciate both it and the normal Tcl syntax.
I was skeptical that I’d find it useful since I can do all of these shell commands and such, but one feature I like is being able to effectively pare the feature set down to just what you need, making for a small but very useful menu.
Though I also have a home chest freezer in the garage, I take this approach to my camper van setup as well. I have a converted (vintage) van, which means it wasn’t intended as a camper, and part of my build-out strategy has been to use removable things that also serve me at home in the event of an emergency or an expansion need, things like a solar panel, LiPo battery, fridge/freezer, cooktop, and space heater.
The fridge is a Dometic CFX 35 which opens at the top and tends to allow for getting at things without losing a lot of cooling. At first, it was also nice to be able to set things on it or use it as a seat (horizontal surfaces are the biggest hard-to-find in a camper van) but that became annoying when needing snacks or other quick access. So I recently built a small cabinet with a pull-out slider on which the fridge lives. Then, I always have the top storage but don’t need to move anything to get at the fridge, but can also briefly use the fridge as a footrest or similar.
Totally resonates with me. I was a kid in the country from a yard sale-scrounging sort of family, and we didn't have money for a computer, but we had a strong ethic of DIY and of education. I had a TI-99/4A (1981) in the late 80s, and an IBM PCjr (1984) in the 90s, but I still stretched them both to the limits of what I could figure out, find in any book I could get my hands on, experiment with $1 shareware I'd find at the mall, or learn about from talking to someone. No net, no meetups, no one else with a computer like mine. I'd come across a Packard Bell at the mall Sears, or a Tandy at Radio Shack, or a 486 setup for Wolfenstein 3D in the university bookstore during a journalism field trip. Figured out how to make a RAM disk to fool a PC game running on my PCjr into thinking there was a C: drive, all kinds of stuff like that. Just kept hacking and pushing and learning.
Hammerspoon is the glue that holds my Mac together. For a starter list of things to do with this app, a partial list of the things that I'm using it for:
- Dumping all open Safari tabs to an Obsidian doc
- Adding 'hyper' (Ctrl-Opt-Cmd) keybinds to pop a new window for:
- Safari
- Finder
- Terminal / Ghostty
- VS Code
- Notes
- Editing Hammerspoon/AeroSpace/Sketchybar config
- Reloading Hammerspoon config
- Reloading Sketchybar
- Quitting all Dock apps except Finder
- Screen lock
- System sleep
- Opening front Finder folder in VS Code
- Opening front Safari URL on Archive.today
- Showing front Safari window tab count
- Showing front app bundle ID
- Posting notification about current Music track
- Controlling my Logi Litra light (various color temps/brightnesses)
- Starting/stopping a client work timer
- Tying it to AeroSpace for:
- Pushing a window to another monitor
- Performing a two-up window layout
- Swapping those two windows
- Closing all other workspace windows
- Gathering all windows to first workspace
- Ensuring some background apps stay running if they crash
- Prompting to unmount disk images if trashed
- Binding into Skim to jump to specific sections of spec PDFs using terse Markdown URLs
I pretty much only use it for two (related) things these days:
- check the list of open Teams windows; if there's a non-standard one, assume I'm in a meeting and webhook to HomeAssistant to select the "active"[2] preset on my meeting light[0].
- download my work ical[1] and, if there's a pending meeting (<~15m), webhook-HASS for the "pending" present on the meeting light.
[0] Just a short strip of WS2812B connected to an ESP32 running WLED.
[1] Originally this was a simple HTTP to my shared link on outlook.com but then they started requiring authentication (because that's exactly what you want on a SHARED link, you gufftarts); had a look at the Azure SDK and ... bag of milky spanners that is; ended up having to import my work ical into Apple Calendar and then use the ical link for that in Hammerspoon. Oh how we laughed. Especially when I realised it only has about 40% of the actual meetings because somehow "my calendar" is actually 4 or 5 bastardised conglomerations of pain and the ical for "my calendar" is actually just for one of those. AND NOT THE USEFUL ONE EITHER.
[2] There's various - "camera" for "the one meeting I'm forced to have my camera on", "active" is "I probably have to talk", "passive" is "I'm not going to be talking", and "silent" for things like company presentations where it's just watching a boring Powerpoint over Teams.
Tossing a couple things out mostly for the people getting ideas from these threads:
I've done something similar, but using the webcam watcher to hook on the webcam being enabled for any reason -- that way when I have that one external meeting on Google Meet or whatever the light still works.
(I also found it useful to have Hammerspoon flip a virtual switch in, well, Hubitat for me, and then automation based on that virtual switch, rather than triggering the light directly. Lets me hang other things off of that virtual switch instead of putting it in Hammerspoon.)
I'll slap it up on my Forgejo when I've got a spare minute (because it depends on my ical->json server as well which I don't believe is currently up there.)
> - Dumping all open Safari tabs to an Obsidian doc
I'd love to do this too. Would you mind sharing how you do it? Or is it trivially easy and not worth explaining? (I haven't looked too deeply into HS yet.)
It's not trivial, but roughly: use AppleScript/osascript to get the URLs, but mostly pass them to a ~50 line Bash script which:
- Brings in the date path components for the dumped-to folder
- Makes a hash of the URL for an Obsidian doc (each tab gets their own doc)
- Uses Chrome command line (--headless --disable-gpu --dump-dom) to save a snapshot of the page contents
- Uses it again with --screenshot to make a thumbnail
- Create an Obsidian doc from a template
- If it's a single tab dump, pass -o to the script, which opens it in Obsidian for review
Lastly, I use the relatively-new Bases feature in Obsidian to make a nice "cards" view of the docs with their thumbnails.
I'm hoping to clean it up at some point and maybe release it, but it's one of those classic one-shot systems that just works for me for now.
> - Uses Chrome command line (--headless --disable-gpu --dump-dom) to save a snapshot of the page contents
> - Uses it again with --screenshot to make a thumbnail
You could combine both of those into "run Archivebox somewhere and pass the URLs into that" (which is what I do for "URLs I save to Instapaper" - they go to my Linkhut, Pinboard, my Archivebox, and once I've fixed my code, to archive.org as well.)
Nice, thanks for the vote on it. Been meaning to look into a personal archiving solution, and now the pendulum is swinging back in the direction of homelab for me so it's on the list.
How does Hammerspoon help with this? Seems like just AppleScript and bash.
Also if I may ask, how do you like Obsidian? I had never heard of it until now. Seems like a competitor to the Notes feature of iOS/macOS, but with its own subscription for syncing independently of iCloud?
I mean, in this case, the Hammerspoon part is really just the hyper keybind and the easy run of AppleScript text inline. But... once you've got some stuff going, it's easier to hook into Hammerspoon as the "frontend" for other things as your systems grow.
Obsidian is good! This use of Bases is really my only "proprietary" use of anything Obsidian-specific. The rest is a combo of personal reference, brainstorms, intricate client work specs or outlines, and the beginnings of a personal wiki. The keybinds are great, everything is in one big folder for now, and the fuzzy search makes it fast. For sync, I just have my vault in a folder that is part of my overall Syncthing, so all my computers can access it. On mobile (iPhone moving to Android, and iPad) it's just read-only for now; not using their sync or doing any writing into the system from mobile.
Somewhat relatedly, I just got Standard Notes going on all systems (Mac/Linux/iPhone/Android/iPad) which is good for reliable capture at all places for me right now. I'm not paying, so I don't have (Markdown or other) formatting like in Apple Notes yet.
Ah. Given the context, I had assumed it relied more on hammerspoon and less on applescript. I'm a bit less excited about it than I was, but I'll still look into doing similar sometime since I'm a habitual tab-opener.
I have no idea how that person is doing it, but I suspect it could be using osascript. Here's how I do it from my homegrown Go bookmark tool:
const fetchTabsScript = `
tell application "Brave Browser"
set output to ""
repeat with w in windows
repeat with t in tabs of w
set output to output & (URL of t) & "|||" & (title of t) & "\n"
end repeat
end repeat
return output
end tell
`
func GetOpenTabs() ([]Tab, error) {
cmd := exec.Command("osascript", "-e", fetchTabsScript)
output, err := cmd.Output()
// ...
}
reply