Skip to content. | Skip to navigation

FreeSMUG

Sections
Personal tools
You are here: Home OS X Portable Apps Source Code Portable RSSOwl source code
Document Actions

Portable RSSOwl source code

by Gand last modified 2006-04-29 10:59 PM
Portable RSSOwl OS X script code:

Shell Script (Release 1.0)


Portable RSSOwl.app is packaged using the Platypus script wrapper from
http://sveinbjorn.sytes.net/platypus

#!/bin/sh

# Portable RSSOwl.app
# Copyright (c) 2006
# Carlo Gandolfi - http://www.freesmug.org
# Paolo Portaluri - http://plus2.it/~paolo/
#
# 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

appid=RSSOwl

here="`dirname \"$0\"`"
cd "$here"

# ========================================================
# quitapp
# Check if local app is open and quit it
# ========================================================

function quitapp {
if ps cx | grep '[0-9] 'java_swt'$'; then
message1="A copy $appid is already running. Do you want to quit the running application and open Portable $appid instead?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message1" buttons {"Cancel", "Continue"} with title "Qiut Running $appid" with icon caution default button "Continue"
set result to button returned of result
end tell
EOT`
if test "$button" == "Continue"; then # Quit local application
osascript -e 'tell app "'$appid'" to quit'
# killall -9 $appid
else
exit 0
fi
fi
}

# ========================================================
# copy_local_pref
# Copy local preferences to Portable Application
# ========================================================

# copy Preferences Folder
function copy_pf {
PFpath=~/Library/Preferences/rssowl
PFsize=`du -hc $PFpath | cut -f1 | tail -1`
message4="Your $appid Preferences folder is $PFsize. Copy it to Portable $appid?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message4" buttons {"Copy", "Cancel"} with title "Copy $appid Preferences Folder" with icon note default button "Cancel"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
cp -fR ~/Library/Preferences/rssowl "$here/app/Library/Preferences/"
defaults write "$here/../../../Portable $appid.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
fi
}

function copy_local_pref {
if defaults read "$here/../../../Portable $appid.app/Contents/info" "LSEnvironment" | grep Yes && test -d ~/Library/Preferences/rssowl; then
message="Copy the existing $appid preferences on this system to Portable $appid?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message" buttons {"Never", "Copy", "Don't Copy"} with title "Copy Preferences" with icon note default button "Don't Copy"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
copy_pf
elif test "$button" == "Never"; then
defaults write "$here/../../../Portable $appid.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
# elif test "$button" == "Don't Copy" # Old preferences are overwritten.
fi
fi
}

# ========================================================
# run
# Open Portable Application
# ========================================================

function run_app {
# Running '$appid' from '$here'."
cd "$here/app/RSSOwl.app/Contents/Resources/Java"
java -XstartOnFirstThread -Duser.home="$here/app/" -Djava.library.path=. -jar rssowl.jar
}

quitapp
copy_local_pref
run_app

.

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: