选择浏览器脚本

心之所在 | 2011/01/29

一台机子装3个浏览器是起码的吧(Firefox、Opera、Chromium、Konqueror……),系统设置-默认应用程序-网页浏览器设定为其中的 chromium。

然后点击一个链接,KDE 就启动了 Chromium,可是如果我当时没开Chromium,开了Firefox了哪?为什么不直接在Firefox里打开链接。能否有个脚本检测,如果当前已经有开浏览器,直接新标签打开链接,如果没开浏览器,用那个默认的浏览器打开链接。

脚本来了:

#!/bin/sh
CHROME_BIN="/usr/bin/chromium"
FIREFOX_BIN="/usr/bin/firefox"
KONQUEROR_BIN="/usr/bin/konqueror"
OPERA_BIN="/usr/bin/opera"
FLOCK_BIN="/usr/bin/flock"

FAVORITE=$CHROME_BIN

if [ "`pidof $OPERA_BIN`" != "" ]; then
        FAVORITE=$OPERA_BIN
fi

if [ "`pidof $KONQUEROR_BIN`" != "" ]; then
        FAVORITE=$KONQUEROR_BIN
fi

if [ "`pidof $FLOCK_BIN`" != "" ]; then
        FAVORITE=$FLOCK_BIN-browser
fi

if [ "`pidof $FIREFOX_BIN`" != "" ]; then
        FAVORITE=$FIREFOX_BIN
fi

if [ "`pidof $CHROME_BIN`" != "" ]; then
        FAVORITE=$CHROME_BIN
fi

$FAVORITE "$1"

不同发行版对chromium/chrme的命名不一样,Kubuntu就是管chromium叫chromium-browser,还有一些进程名是带firefox-bin,有的又是firefox 的,你自己照葫芦画瓢改改,之后改为可执行。

然后系统设置-默认应用程序-网页浏览器

browser1.jpeg (699×457)

choqok这类估计得单独改浏览器设定。

我这边试过能用,要是没效果估计是脚本中进程名之类的有误。

via kde-look

———————————–我是分割线—————————-

想用gmail做默认电子邮件客户端的可以用这:

kioclient exec https://mail.google.com/mail/?extsrc=mailto&url=%u

设置到默认应用程序中的电子邮件客户端便成。

    泰达希尔-德鲁伊
    Tags:

    6 FEEDBACKS

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).

    This site uses Akismet to reduce spam. Learn how your comment data is processed.