Skip to content

Instantly share code, notes, and snippets.

@seraphyn seraphyn/browserselect
Last active Dec 31, 2015

Embed
What would you like to do?
Browserselect ist ein Script welches die ProzessID (PID) des momentan laufenden Browsers sucht und allen Programmen, welche eine Seite öffnen wollen, den laufenden Browser zuweist.
#!/bin/bash
# GNU GPL v3
# the order in which to execute the commands
# breaks on success
# available are the following commands:
#
# firefox_new_tab
# opera_new_tab
#
# firefox_new_win
# opera_new_win
#
order=(
dwb_new_tab
opera_new_tab
firefox_new_tab
qupzilla_new_tab
google_chrome_new_tab
chrome_new_tab
chrome_new_win
opera_new_win
qupzilla_new_win
)
# helper function for firefox_new_tab and swiftfox_new_tab
function mozlike_new_tab {
if [ "`pidof $2`" ]; then
$2 -new-tab "$1"&
else
return 1
fi
}
# new firefox tab
function firefox_new_tab {
mozlike_new_tab $1 firefox
}
# helper function for firefox_new_win and swiftfox_new_win
function mozlike_new_win {
$2 -new-tab "$1"&
}
# new firefox window
function firefox_new_win {
mozlike_new_win $1 firefox
}
function opera_new_tab {
if [ "`pidof opera`" == "" ]; then
return 1
fi
opera -newtab $1
}
#dwb new win
function dwb_new_tab {
if [ "`pidof dwb`" == "" ]; then
return 1
fi
dwb $1
}
function qupzilla_new_tab {
if [ "`pidof qupzilla`" == "" ]; then
return 1
fi
qupzilla $1
}
# new opera win
function opera_new_win {
opera -newwindow $1
}
function chrome_new_tab {
if [ "`pidof chromium-browser`" == "" ]; then
return 1
fi
chromium-browser --new-tab $1
}
function google_chrome_new_tab {
if [ "`pidof chrome`" == "" ]; then
return 1
fi
google-chrome --new-tab $1
}
function chrome_new_win {
chromium-browser --new-window $1
}
function qupzilla_new_win {
qupzilla --new-window $1
}
# call functions based on order defined above
for i in `seq 1 ${#order[@]}`;
do
${order[$i-1]} $1 && exit
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.