From 3b3d7d7f9a1d607241ba5b8e1cb7f36fbf710575 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 19 Oct 2021 08:50:58 -0400 Subject: 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. --- Makefile | 2 +- ioslay-firefox | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 ioslay-firefox diff --git a/Makefile b/Makefile index 3d6a476..498afa8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BINDIR = /usr/local/bin -BINARIES = sliceweasel fireslay +BINARIES = sliceweasel fireslay ioslay-firefox SUDO != [ "$$(id -u)" = 0 ] || echo sudo .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 @@ +#!/bin/sh + +if [ "$1" = -q ] +then + exec 2>/dev/null + shift +fi + +web_content_pids() +{ + top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | { + while read line + do set -- $line + [ "${12} ${13}" = "Web Content" ] || continue + echo $1 + done + } +} + +set -- $(web_content_pids | tac) + +set -- $(printf "\055\055pid=%s " $*) + +over_count=0 +sudo -- iotop -qq -b "$@" | + while read line + do + case "$line" in + "Total DISK"*) + if [ "$OVER" ] + then + over_count=$((over_count + 1)) + if [ "$over_count" -gt 3 ] + then + fireslay + fi + over= + else + over_count=0 + fi + ;; + "Current DISK"*) continue ;; + *) + set -- $line + pct=${10%.*} + if [ $pct -gt 90 ] + then + printf '[%d] %s%% %s\n' "$over_count" "${10}" "${12}" >&2 + over=y + fi + ;; + esac + done -- cgit v1.2.3