-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfirefox-profile
executable file
·50 lines (45 loc) · 1.02 KB
/
firefox-profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Copyright 2014 haxwithaxe
# License: CC0
# Launch firefox under the profile named after firefox-<profile name>
today=`date --date='Today 00:00:00' +%s`
script=$(basename $0)
profile="${script/*-/}"
app_exec="firefox"
app="$app_exec-$profile"
# arguments for the initial launching of this profile of firefox
first_args="-P $profile \
-new-instance \
--class=$(basename $app_exec)-$profile \
$*"
# arguments for subsequent launches
subseq_args="-P $profile --class=$(basename $app_exec)-$profile $*"
# getto pid file
pid_file=/tmp/run/$app/pid
if ! [ -d `dirname $pid_file` ] ;then
mkdir -p `dirname $pid_file`
fi
touch $pid_file
is_running(){
running=1
pid_list=''
while read p ;do
if ( ps $p | grep -qo $p ) ;then
running=0
pid_list=${pid_list}\n$p
fi
done < $pid_file
echo -ne $pid_list > $pid_file
return $running
}
if is_running ;then
echo already running
$app_exec $subseq_args &
pid=$!
echo $pid >> $pid_file
else
echo first instance
$app_exec $first_args &
pid=$!
echo $pid >> $pid_file
fi