Skip to content

Commit

Permalink
basic check if other profiles are running
Browse files Browse the repository at this point in the history
tinfoil needs to use -no-remote on mozilla browsers in order to start
a different profile in parallel if an instance of the browser is
already running.
  • Loading branch information
jaromil committed Feb 28, 2017
1 parent 192c03d commit c034b1a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tinfoil
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,18 @@ EOF
# TODO: interesting to add preference locking functionality
# see: http://kb.mozillazine.org/Locking_preferences

browser_is_running "${browser}" || browser_opts+=(-no-remote)

(sleep 5; rm "$familypath"/profiles.ini) &

option.is_set -e && {
cmd=$(option.value -e)
act "executable: $cmd"
$cmd
$cmd ${browser_opts}
return $?
}

$browser
$browser ${browser_opts}
return $?

}
Expand All @@ -189,21 +191,19 @@ function help_usage() {
act "Usage: tinfoil browser profile_name"
}


## TODO: fix this using pidof and locking inside dirs
# TODO: check if running from the locks in profile dirs
function browser_is_running() {
fn browser_is_running
req=(browser)
local arg="$1"
req=(arg)
ckreq || return $?

local brgrep="[${browser[1]}]$(print $browser | cut -c2-)"
func "checking ps ax for '$brgrep'"

pgrep $browser
[[ $? = 0 ]] && {
act "$browser found already running, using -no-remote"
browser_opts+=(-no-remote)
}
local res
func "pgrep: $arg"
pgrep "$arg" > /dev/null
res=$?
[[ $res = 0 ]] && act "$arg is already running"
return $res
}

# }}}
Expand Down

0 comments on commit c034b1a

Please sign in to comment.