Skip to content

Instantly share code, notes, and snippets.

@hac
Forked from nothingmuch/keywurl_to_chrome.pl
Created January 9, 2011 04:46
Show Gist options
  • Save hac/771425 to your computer and use it in GitHub Desktop.
Save hac/771425 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Mac::PropertyList qw(parse_plist_file);
use DBI;
my $app_support = "$ENV{HOME}/Library/Application Support";
my $dbh = DBI->connect("dbi:SQLite:dbname=$app_support/Google/Chrome/Default/Web Data");
my $plist = parse_plist_file("$app_support/Keywurl/Keywords.plist");
my $keywords = $plist->{keywords};
$dbh->begin_work;
my $t = time;
my $sth = $dbh->prepare(qq{
INSERT INTO keywords VALUES (
NULL, -- id
?, -- name
?, -- keyword
"", -- favicon url
?, -- url
0, -- show in default list
0, -- safe for auto replace
"", -- originating URL
$t, -- date created
0, -- usage count
"", -- input encodings
"", -- suggest url
0, -- prepopulate id
0, -- autogenerate keyword
0, -- logo id
0, -- created by policy
"" -- instant URL
)
});
foreach my $link ( keys %$keywords ) {
my $data = $keywords->{$link};
my $url = $data->{expansion}->value;
$url =~ s/\{query\}/{searchTerms}/g;
$sth->execute(
$link, # name
$link, # keyword
$url,
);
}
$dbh->commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment