Skip to content

Commit

Permalink
docs: adding regex docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Dec 23, 2023
1 parent d3bfdc0 commit 0ef2336
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is my first/only project in Swift, so feel to submit PRs to fix obvious thi

## Why do this?

Time is the most valuable + scarce asset. Consumer companies are incentivized to steal your time. Fight back.
Time is the most valuable + scarce asset. Companies are incentivized to steal your time. Fight back.

- https://marco.org/2015/10/30/automatic-social-discipline
- http://mikebian.co/tag/digital-minimalism/
Expand Down Expand Up @@ -122,7 +122,7 @@ If you are running as root, you'll want to specify the full path to any shell sc

- Fast, CLI-oriented tool
- [UI via Raycast](https://www.raycast.com/iloveitaly/hyper-focus)
- Configuration in a simple JSON file ([here's an example](https://github.com/iloveitaly/dotfiles/blob/master/.config/focus/config.json))
- Configuration in a simple JSON file ([here's an example](https://github.com/iloveitaly/dotfiles/blob/master/.config/focus/config.json)). You can [add comments to this JSON](https://json5.org)!
- Very memory efficient, even over long periods of time
- No weird hangs or freezes (Focus app had this issue)
- Run scripts on sleep events (you don't need to rely on the abandoned sleepwatcher tool)
Expand All @@ -131,10 +131,10 @@ If you are running as root, you'll want to specify the full path to any shell sc

### Sleepwatching

- Run a script on first wake of the day
- Run a script on first wake of the day (custom algorithm to determine first wake)
- Treat long periods of no activity as sleep
- Run a script on each wake
- Run script as privileged in order to edit key system files like `/etc/hosts`
- Treat long periods of no activity as sleep

#### What is 'first wake'?

Expand All @@ -152,8 +152,26 @@ Having a first wake script allows you to tie into something like [clean browsers

- Block macOS applications without quitting them. This is implemented by hiding them when you switch to them.
- "Block" websites by redirecting Chrome and Safari browsers to a page of your choosing when a banned URL is encountered.
- Block hosts
- Block hosts. Automatically adds `www.` variants to non-regex block hosts.
- Block specific URLs, ignoring anchors, and allowing a partial/subset match on query strings.
- Regex support

#### Regex

Regex support is a bit weird: add trailing and leading `/` to the block entry to indicate it's a regex. Think `sed`-style.

Example:

```json
{
"block_hosts": [
// normal
"google.com",
// regex!
"/.*google..*/"
]
}
```

## Non-Features

Expand All @@ -166,8 +184,9 @@ Having a first wake script allows you to tie into something like [clean browsers

Instead of UI, I've opted to a simple HTTP API that can be used to power a [Raycast](https://www.raycast.com/iloveitaly/hyper-focus)-based UI.

- `/reload` reload the configuration file
- `/reload` reload the configuration file without restarting the process
- `/pause` pause the currently running schedule
- `/resume` resume the currently running schedule
- `/override` force a blocking profile to run for a period of time
- `/ping` is this thing on?
- `/configurations` array of names of all blocking profiles. To change the order of the results, change the order of the inputs in your config file.
Expand All @@ -182,9 +201,7 @@ You can hit the API locally for testing using: `http localhost:9029/status`

## Tests

Haha! Nope.

This is a fun personal tool. Tests are boring, so I didn't write them.
This is a fun personal tool. Tests are boring, so I didn't write many of them.

Plus, writing tests in Swift seems to be a massive pain (no dynamic mocks!).

Expand Down
7 changes: 3 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
## Next

- [ ] swiftformat needs to be updated to play well with swiftlint
- [ ] Would be cool to have a regex match option, not sure how this would fit into the config schema
- [ ] custom redirect page for browsers, could be a fun way to redirect to quotes or something
- [ ] YouTube video about how it works
- [ ] https://github.com/tingraldi/SwiftScripting/pull/24#pullrequestreview-1173211472
- [ ] File watching for config changes
- [ ] Allow different schedules on different days
- [ ] Allow schedules to specify pause increments to limit the pauses available on specific schedules
- [ ] all block/allow config should be optional, but something should be required!
- [ ] rate limit pauses

## Future

- [ ] support json config with comments
- [ ] I wonder if there is a tool out there to generate a ui based off a json schema?
- [ ] make a logo with AI? https://www.shopify.com/tools/logo-maker/onboarding/brand-values
- [ ] If there are no events in a certain period of time, we should trigger an action anyway
- [ ] swift verison in the repo
- [ ] maybe build a nice little webpage like https://www.homerow.app
- [ ] rate limit pauses
- [ ] maybe build a nice little webpage like https://www.homerow.app

0 comments on commit 0ef2336

Please sign in to comment.