#!/usr/local/bin/perl -w use strict; use DBD::SQLite; my( $home ) = glob "~"; my $dbfile = "$home/.local/share/" . "zeitgeist/activity.sqlite"; my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "" ); my $sth = $dbh->prepare( "select uri.value from event,uri where subj_id = uri.id and interpretation = 1 AND date(substr(timestamp,1,10),'unixepoch') >= date('now', '-12 hours')" ); $sth->execute(); my %apps = (); while( my( $uri ) = $sth->fetchrow_array() ) { if( $uri =~ /^application:/ ) { $apps{ $uri }++; } } for my $app ( sort { $apps{ $b } <=> $apps{ $a } } keys %apps ) { print "$app: $apps{ $app }\n"; }