blob: ce4aa549d138281ed0471ec447201703f394ad2b (
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
|
#!/bin/sh
CMD=firefox
UNIT=$CMD
DIR=~/.mozilla
MEMORY_MAX=50%
READ_OPS=1G
WRITE_OPS=$READ_OPS
if systemctl --user is-active "$UNIT" >/dev/null
then
exec "$CMD" "$@"
exit
fi
DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n))
[ "$DEV" ] || exit
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 IOWriteIOPSMax="$DEV $WRITE_OPS" \
--property Restart="on-failure" \
-- \
"$CMD" "$@"
|