-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env vrsctl | ||
# safari_history.ll - Access Safari History | ||
# | ||
|
||
# TODO: Timeout block? (timeout DURATION PROC) - would be nice to cap (exec ...) time | ||
|
||
(def safari_history '()) | ||
|
||
(bind_srv :os_notify) | ||
|
||
(defn get_safari_history () | ||
"(get_safari_history) - Get the list of items from Safari History" | ||
safari_history) | ||
|
||
(defn refresh_safari_history () | ||
"(refresh_safari_history) - Refresh in-memory Safari History" | ||
(def (:ok res) (exec "./scripts/safari_history_shim.tcl")) | ||
(set safari_history (read res))) | ||
|
||
(spawn_srv :safari_history :interface '(get_safari_history refresh_safari_history)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env tclsh | ||
# safari_history_shim.tcl - Shim for Safari History SQLite and VRS | ||
# | ||
# TODO: Embed sqlite bindings in VRS? | ||
# TODO: Ergonomics for embedded scripts within lyric lang? | ||
|
||
package require sqlite3 | ||
|
||
set output "(\n" | ||
|
||
catch { | ||
sqlite3 historydb "$env(HOME)/Library/Safari/History.db" | ||
historydb eval { | ||
SELECT datetime(visit_time + 978307200, 'unixepoch', 'localtime') as local_visit_time, TRIM(title) as trim_title, url, domain_expansion | ||
FROM history_visits | ||
JOIN history_items ON history_visits.history_item = history_items.id | ||
WHERE LENGTH(TRIM(COALESCE(title, ''))) > 0 | ||
AND LENGTH(TRIM(COALESCE(url, ''))) > 0 | ||
AND LENGTH(url) < 500 | ||
AND url NOT LIKE "%/search%" | ||
AND url NOT LIKE "%read.amazon.co.jp%" | ||
GROUP BY history_item | ||
ORDER BY visit_time DESC, visit_count_score DESC | ||
LIMIT 250 | ||
} { | ||
append output "(:safari_history_item :title \"$trim_title\" :url \"$url\" :domain_expansion \"$domain_expansion\")" | ||
} | ||
} | ||
|
||
append output ")" | ||
|
||
historydb close | ||
|
||
puts "$output" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters