From 7c17d07ac3c9213565345c6cf75cced5b592c318 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 3 Apr 2022 15:53:28 -0400 Subject: new firefox launcher: firestart --- Makefile | 2 +- firestart | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 firestart diff --git a/Makefile b/Makefile index d67b257..7cb92ae 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BINDIR = /usr/local/bin -BINARIES = sliceweasel sliceweasel.lib.sh sliceuser fireslay ioslay-firefox cgroup-show-each-new-process ioslay-mgr.sh +BINARIES = sliceweasel sliceweasel.lib.sh sliceuser fireslay ioslay-firefox cgroup-show-each-new-process ioslay-mgr.sh firestart SUDO != [ "$$(id -u)" = 0 ] || echo sudo .PHONY: install install-bin diff --git a/firestart b/firestart new file mode 100755 index 0000000..5be6d02 --- /dev/null +++ b/firestart @@ -0,0 +1,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" "$@" -- cgit v1.2.3