diff options
Diffstat (limited to 'firestart')
-rwxr-xr-x | firestart | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/firestart b/firestart new file mode 100755 index 0000000..5be6d02 --- /dev/null +++ b/firestart | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | CMD=firefox | ||
4 | UNIT=$CMD | ||
5 | DIR=~/.mozilla | ||
6 | MEMORY_MAX=50% | ||
7 | READ_OPS=1G | ||
8 | WRITE_OPS=$READ_OPS | ||
9 | |||
10 | if systemctl --user is-active "$UNIT" >/dev/null | ||
11 | then | ||
12 | exec "$CMD" "$@" | ||
13 | exit | ||
14 | fi | ||
15 | |||
16 | DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n)) | ||
17 | [ "$DEV" ] || exit | ||
18 | |||
19 | systemctl --user reset-failed "$UNIT" 2>/dev/null | ||
20 | systemd-run --user \ | ||
21 | --unit="$UNIT" \ | ||
22 | --setenv=DISPLAY="$DISPLAY" \ | ||
23 | --setenv=XAUTHORITY="$XAUTHORITY" \ | ||
24 | --property=MemoryMax="$MEMORY_MAX" \ | ||
25 | --property=IOReadIOPSMax="$DEV $READ_OPS" \ | ||
26 | --property=IOWriteIOPSMax="$DEV $WRITE_OPS" \ | ||
27 | --property=IOWriteIOPSMax="$DEV $WRITE_OPS" \ | ||
28 | --property=Restart="on-failure" \ | ||
29 | -- \ | ||
30 | "$CMD" "$@" | ||