print STDERR "TODO $NAME usage\n";
     exit $rv;
 }
-usage(1) unless GetOptions(\%CONFIG, qw/debug help|h quiet|q oneshot|1/);
+usage(1) unless GetOptions(\%CONFIG, qw/debug help|h config=s quiet|q oneshot|1/);
 usage(0) if $CONFIG{help};
 
 
-my $CONFFILE = 'sync.ini';
+my $CONFFILE = delete $CONFIG{config} // 'imapsync';
 my $CACHEDIR = './imapsync.cache'; # XXX use a config option
 my $DBFILE = "$CACHEDIR/imap.guilhem.org.db";
 my $LOCKFILE = "$CACHEDIR/.imap.guilhem.org.lck";
 
     my $section = shift;
     my %opts = (%OPTIONS, @_);
 
+    $conffile = ($ENV{XDG_CONFIG_HOME} // "$ENV{HOME}/.config") .'/'. $conffile
+        unless $conffile =~ /\A\//; # relative path
+
     die "No such config file $conffile\n"
         unless defined $conffile and -f $conffile and -r $conffile;