blob: 5f388b5e1ea7189fa136c2976d6b837c89810d23 (
plain)
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
|
#!/bin/sh
die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
CMD=firefox
UNIT=$CMD
DIR=~/.mozilla
MEMORY_MAX=50%
READ_OPS=1G
WRITE_OPS=$READ_OPS
CONFDIR=$HOME/.config/firestart/conf
if [ -e "$CONFDIR" ]
then
. "$CONFDIR"
fi
if systemctl --user is-active "$UNIT" >/dev/null
then
exec "$CMD" "$@" # Asks existing firefox to open a new window.
exit
fi
[ -e "$DIR" ] || die "does not exist: $DIR"
[ -d "$DIR" ] || die "not a directory: $DIR"
DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n))
[ "$DEV" ] || die "could not determine backing device for $DIR"
ioslay-mgr.sh launch-unit
systemctl --user reset-failed "$UNIT" 2>/dev/null
systemd-run --user \
--unit "$UNIT" \
--setenv DISPLAY="$DISPLAY" \
--setenv XAUTHORITY="$XAUTHORITY" \
--property MemoryMax="$MEMORY_MAX" \
--property IOReadIOPSMax="$DEV $READ_OPS" \
--property IOWriteIOPSMax="$DEV $WRITE_OPS" \
--property Restart="on-failure" \
-- \
"$CMD" "$@"
|