diff options
author | Andrew Cady <d@cryptonomic.net> | 2021-10-19 08:50:58 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2021-10-19 08:51:53 -0400 |
commit | 3b3d7d7f9a1d607241ba5b8e1cb7f36fbf710575 (patch) | |
tree | 0b29aa0945b35227bca0902209eb9bdc57eb5cf0 | |
parent | 47c72d59b2fe1234df8fad442f2ad26c2f84fab9 (diff) |
new command ioslay-firefox
it fucking works
it actually fucking works
keep this command running and firefox won't make the system unresponsive
-- AND it won't make itself unresponsive for more than a few seconds.
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | ioslay-firefox | 53 |
2 files changed, 54 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | BINDIR = /usr/local/bin | 1 | BINDIR = /usr/local/bin |
2 | BINARIES = sliceweasel fireslay | 2 | BINARIES = sliceweasel fireslay ioslay-firefox |
3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo | 3 | SUDO != [ "$$(id -u)" = 0 ] || echo sudo |
4 | 4 | ||
5 | .PHONY: install install-bin | 5 | .PHONY: install install-bin |
diff --git a/ioslay-firefox b/ioslay-firefox new file mode 100755 index 0000000..eac3184 --- /dev/null +++ b/ioslay-firefox | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ "$1" = -q ] | ||
4 | then | ||
5 | exec 2>/dev/null | ||
6 | shift | ||
7 | fi | ||
8 | |||
9 | web_content_pids() | ||
10 | { | ||
11 | top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | { | ||
12 | while read line | ||
13 | do set -- $line | ||
14 | [ "${12} ${13}" = "Web Content" ] || continue | ||
15 | echo $1 | ||
16 | done | ||
17 | } | ||
18 | } | ||
19 | |||
20 | set -- $(web_content_pids | tac) | ||
21 | |||
22 | set -- $(printf "\055\055pid=%s " $*) | ||
23 | |||
24 | over_count=0 | ||
25 | sudo -- iotop -qq -b "$@" | | ||
26 | while read line | ||
27 | do | ||
28 | case "$line" in | ||
29 | "Total DISK"*) | ||
30 | if [ "$OVER" ] | ||
31 | then | ||
32 | over_count=$((over_count + 1)) | ||
33 | if [ "$over_count" -gt 3 ] | ||
34 | then | ||
35 | fireslay | ||
36 | fi | ||
37 | over= | ||
38 | else | ||
39 | over_count=0 | ||
40 | fi | ||
41 | ;; | ||
42 | "Current DISK"*) continue ;; | ||
43 | *) | ||
44 | set -- $line | ||
45 | pct=${10%.*} | ||
46 | if [ $pct -gt 90 ] | ||
47 | then | ||
48 | printf '[%d] %s%% %s\n' "$over_count" "${10}" "${12}" >&2 | ||
49 | over=y | ||
50 | fi | ||
51 | ;; | ||
52 | esac | ||
53 | done | ||