-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathfirefox
executable file
·74 lines (65 loc) · 1.97 KB
/
firefox
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
# Automatically use a firefox/thunderbird profile based on $MY_X_SESSION_NAME.
# See also ./thunderbird.
program="$(basename "$0")"
# XXX: get $program bin from after removing ourself from PATH.
target_program="/usr/bin/$program"
if [ "$program" = thunderbird ]; then
profile_root=~/.$program/
# Start thunderbird with German date format.
# 'en_DK' would allow for ISO 8601 format.
# See: http://kb.mozillazine.org/Date_display_format#Configuring_the_date.2Ftime_system_settings_on_your_computer
export LC_TIME=de_DE.UTF-8
[ "$LC_ALL" != "$LC_TIME" ] && unset LC_ALL
elif [ "$program" = firefox ]; then
profile_root=~/.mozilla/$program/
# Indicate to awesome that the client window should get raised and jumped to.
echo "Firefox $(date +%s)" > /tmp/.awesome-raise-next-client
else
echo "$0: unexpected program basename: $program" >&2
fi
auto_use_profile=1
for i; do
case $i in
-P|--profile|--ProfileManager)
auto_use_profile=0
break ;;
esac
done
# Send SIGCONT to main PID(s) of program.
# This is necessary for it to receive the open-url request etc.
# Once it gets focused also its childs will be continued.
continue_program() {
this_tty=$(get-tty)
for pid in $(pgrep "$program"); do
pid_tty=$(get-tty "$pid")
if [ "$pid_tty" = "$this_tty" ]; then
if [ "$(ps -o state= "$pid")" = T ]; then
echo "$0: continuing $pid" >&2
kill -CONT "$pid"
fi
fi
done
}
start_profile() {
profile_dir="$(find "$profile_root" -name "*.$1")"
shift
if [ -z "$profile_dir" ]; then
echo "$0: could not find profile dir for $session_name." >&2
return 1
else
continue_program
exec "$target_program" --profile "$profile_dir" "$@"
fi
}
if [ "$auto_use_profile" = 1 ]; then
session_name=$MY_X_SESSION_NAME
if [ -n "$session_name" ]; then
start_profile "$session_name" "$@"
if [ "$session_name" = personal ]; then
start_profile private "$@"
fi
fi
fi
continue_program
exec "$target_program" "$@"