View previous topic :: View next topic |
Author |
Message |
teika Apprentice
Joined: 19 Feb 2011 Posts: 155 Location: YYYY-MM-DD, period. Have you ever used the Internet?
|
Posted: Tue Jan 31, 2012 1:36 am Post subject: An enhancement of /usr/bin/firefox-bin; no new win etc. |
|
|
The script below is a replacement /usr/bin/firefox-bin, which is included in www-client/firefox-bin.
1. When you do
$ firefox-bin *
it'll ignore *_files directories, which the original firefox-bin picks up.
2. The original firefox-bin has a defect when you open new urls from the command line, if already firefox is running. If you do
$ firefox-bin foo bar baz
then a new window is created, and these urls are shown there, while
$ firefox-bin one-url
results in a new tab. With my script, they are always opened in new tabs.
Code: | #!/bin/bash
# Based on www-client/firefox-bin-8.0
# Difference from the Gentoo original:
# Suppose firefox is already running. When you do
# $ /usr/bin/firefox foo bar baz
# then a new window is created, and these urls are shown there, while
# $ /usr/bin/firefox one-url
# results in a new tab.
# With this script, they're always opened in new tabs.
unset LD_PRELOAD
LD_LIBRARY_PATH="/opt/firefox/"
GTK_PATH=/usr/lib/gtk-2.0/
# Is already firefox running? Well, simple way doesn't work:
# ( -z $( pgrep -x -u $( whoami ) firefox | grep -v $to_exclude ))
# If this script is run from a symlink "firefox"
# It's probably because $() forks??
for i in $( pgrep -x -u $( whoami ) firefox ) ; do
if [[ `cat /proc/${i}/cmdline` =~ ^/opt/firefox/firefox ]]; then
RUNNING=t
break
fi
done
# filter out *_files
# If you run firefox a*, then you receive a.*_files.
args=()
for i in "$@"; do
if [[ ( -d "$i") && ( "$i" =~ _files$ ) ]]; then
:
else
args=( "${args[@]}" "$i" )
fi
done
if [[ (( -n "$1" ) && ( "$1" =~ ^- )) || -z $RUNNING ]]; then
exec /opt/firefox/firefox "${args[@]}"
else
newArgs=()
for i in "${args[@]}"; do
if [[ ( -e "$i" ) || ( "$i" =~ ^file:// ) || ( "$i" =~ ^http ) ]]; then
newArgs=( "${newArgs[@]}" -new-tab "$i" )
else
newArgs=( "${newArgs[@]}" "$i" )
fi
done
/opt/firefox/firefox "${newArgs[@]}" &
fi
|
I think it can be improved; I'm not good at bash.
/usr/bin/firefox-bin is created by the ebuild, not distributed by mozilla.com. If this script is refined enough, then I may send it to Gentoo bugzilla. Enjoy. _________________ Hack of easy Shift / Ctrl / AltGr etc; save your pinkies, type without drudgery: topic 865313
XPAT - Xi, Putin, Abe and Trump - are security holes of their own nations.
Last edited by teika on Thu Mar 22, 2012 10:46 pm; edited 2 times in total |
|
Back to top |
|
|
teika Apprentice
Joined: 19 Feb 2011 Posts: 155 Location: YYYY-MM-DD, period. Have you ever used the Internet?
|
Posted: Thu Mar 01, 2012 11:12 am Post subject: |
|
|
[Now obsolete]
The above script doesn't work any more. It seems that it can be fixed by prefixing each url with "-new-tab". The code which mostly works is easy to write, but wait a bit for a fairly good one. Or someone can contribute one, I'll be grateful. =) |
|
Back to top |
|
|
teika Apprentice
Joined: 19 Feb 2011 Posts: 155 Location: YYYY-MM-DD, period. Have you ever used the Internet?
|
Posted: Thu Mar 22, 2012 10:56 pm Post subject: |
|
|
Updated. Now it seems to work again.
Without any comments, it'll never be sent to Gentoo bugzilla. I can't judge the quality of my own code. (If it's to be merged to the official ebuild, this feature should be optional, but it's a minor issue.)
Regards. _________________ Hack of easy Shift / Ctrl / AltGr etc; save your pinkies, type without drudgery: topic 865313
XPAT - Xi, Putin, Abe and Trump - are security holes of their own nations. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|