aboutsummaryrefslogtreecommitdiff
path: root/bin/web
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-01-11 19:23:52 +0000
committerrsc <devnull@localhost>2005-01-11 19:23:52 +0000
commit5645c4afff3bfd3f1a92d01a4d31b25c6e5b9d89 (patch)
tree7767b48bcb274f480936008fd76eeae41500cc3b /bin/web
parent8bead1099899437fd522244e9ba1c7a287a0cf7a (diff)
downloadplan9port-5645c4afff3bfd3f1a92d01a4d31b25c6e5b9d89.tar.gz
plan9port-5645c4afff3bfd3f1a92d01a4d31b25c6e5b9d89.tar.bz2
plan9port-5645c4afff3bfd3f1a92d01a4d31b25c6e5b9d89.zip
fun with applescript
Diffstat (limited to 'bin/web')
-rwxr-xr-xbin/web71
1 files changed, 67 insertions, 4 deletions
diff --git a/bin/web b/bin/web
index 1745df50..0aafb76a 100755
--- a/bin/web
+++ b/bin/web
@@ -1,8 +1,58 @@
#!/bin/sh
-plumb1()
+plumbfirefox()
+{
+ echo '
+ tell application "Firefox"
+ activate
+ tell application "System Events"
+ tell process "firefox"
+ keystroke "t" using {command down}
+ end tell
+ end tell
+ Get URL "'$1'"
+ end tell
+ ' | osascript
+}
+
+plumbsafari()
+{
+ echo '
+ tell application "Safari"
+ activate
+ tell application "System Events"
+ tell process "safari"
+ keystroke "t" using {command down}
+ end tell
+ end tell
+ open location "'$1'"
+ end tell
+ ' | osascript
+}
+
+plumbapple()
{
- case x-$BROWSER in
+ case ${BROWSER:-none} in
+ firefox)
+ plumbfirefox "$@"
+ ;;
+ safari)
+ plumbsafari "$@"
+ ;;
+ none)
+ if [ -d /Applications/Firefox.app ]
+ then
+ plumbfirefox "$@"
+ else
+ plumbsafari "$@"
+ fi
+ ;;
+ esac
+}
+
+plumbunix()
+{
+ case ${BROWSER:-firefox} in
# Other browsers here
# ...
*opera*)
@@ -15,8 +65,8 @@ plumb1()
$BROWSER -remote 'openURL('$i',new-tab)'
;;
x-)
- # run firefox as default!
- firefox -remote 'openURL('$i',new-tab)'
+ BROWSER=firefox
+ $BROWSER -remote 'openURL('$i',new-tab)'
;;
*mozilla*)
$BROWSER -remote 'openURL('$i',new-tab)'
@@ -27,6 +77,19 @@ plumb1()
esac
}
+plumb1()
+{
+ case `uname` in
+ Darwin)
+ plumbapple "$@"
+ ;;
+ *)
+ plumbunix "$@"
+ ;;
+ esac
+}
+
+
if [ $# = 0 ]
then
plumb1 about:blank