daemon that reads keystrokes from /dev/input/event* and acts on the "multimedia keys"
[soepkiptng.git] / soepkiptng_update7.pl
blob42c9406bb6e626d1980e16d82b39c0b6b9931388
1 #!/usr/bin/perl
2 ############################################################################
3 # soepkiptng (c) copyright 2000 Eric Lammerts <eric@lammerts.org>.
4 # $Id$
5 ############################################################################
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # A copy of the GNU General Public License is available on the World Wide Web
16 # at `http://www.gnu.org/copyleft/gpl.html'. You can also obtain it by
17 # writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
19 ############################################################################
21 use integer;
22 use Cwd 'abs_path';
23 use DBI;
24 use Socket;
25 use Getopt::Std;
27 # find program directory
28 $_ = $0;
29 while(-l) {
30 my $l = readlink or die "readlink $_: $!\n";
31 if($l =~ m|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
33 m|(.*)/|;
34 my $progdir = abs_path($1);
36 require "$progdir/soepkiptng.lib";
38 getopts('c:');
40 read_configfile(\%conf, $opt_c);
42 $dbh = DBI->connect("DBI:$conf{db_type}:$conf{db_name}:$conf{db_host}",
43 $conf{db_user}, $conf{db_pass}) or die "can't connect to database";
45 $files = $dbh->selectcol_arrayref("SELECT filename FROM song WHERE present AND filesize IS NULL AND filename LIKE '/%'");
46 $num = 0;
47 foreach(@$files) {
48 defined($size = -s $_) or next;
49 $dbh->do("UPDATE song SET filesize=? WHERE filename=?", undef, $size, $_)
50 or die "can't do sql command: " . $dbh->errstr . "\n";
51 $num++;
53 END {
54 print "$num records updated\n";