#!/usr/bin/perl ############################################################################## # opera-bookmarks-pipe Version 1.0 # # Copyright 2008 Brendan Johan Lee brendan.johan.lee@gmail.com # # Created 05.08.2008 Last Modified 06.08.2008 # # Latest version available from www.gsmblog.net and www.vanntett.net # ############################################################################## # Copyright (C) 2008 Brendan Johan Lee # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program; if not, write to the Free Software # # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # or see http://www.gnu.org/ # # # ############################################################################## ############################################################################## # Instructions and more information can be found at: # # http://www.gsmblog.net/lang-en/linux-howtos/41/87 # ############################################################################## use File::HomeDir; open bmfile, "$~{''}/.opera/opera6.adr" or die ("Couldn't open bookmark file: $!"); @bookmarks = ; close bmfile; $folder = 0; $bookmark = 0; $cnt = 0; $skiptrash = 0; $trashcnt = 0; print ''; foreach $line (@bookmarks) { if ($line =~ /#FOLDER/) { $folder = 1; } elsif ($line =~ /#URL/) { $bookmark = 1; } elsif ($line =~ /^-$/) { if (!$skiptrash) { print ''; } else { $trashcnt--; $skiptrash=0 if ($trashcnt==0); } } elsif ($line =~ /NAME=(.+)$/) { $name = $1; $name =~ s/&/&/g; $skiptrash=1 if ($name eq "Trash"); if ($folder) { if (!$skiptrash) { print ''; $cnt++; } else { $trashcnt++; } $folder=0; } } elsif ($line =~ /URL=(.+)$/) { $url = $1; $url =~ s/&/&/gi; print 'opera '.$url.'' if (!$skiptrash); $bookmark=0; } } print '';