aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-10-25 12:29:48 -0300
committerEuAndreh <eu@euandre.org>2023-10-25 12:29:48 -0300
commit1d7a95e19c7cb75883838148ef30d78dffb9adb3 (patch)
treef8c44d36fcf35248523e65e814563f6b749df7d5 /bin
parentetc/guix/home.scm: Remove duplicate rust packages (diff)
downloaddotfiles-1d7a95e19c7cb75883838148ef30d78dffb9adb3.tar.gz
dotfiles-1d7a95e19c7cb75883838148ef30d78dffb9adb3.tar.xz
bin/nicely: Add new working utility
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nicely67
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/nicely b/bin/nicely
new file mode 100755
index 0000000..d062f02
--- /dev/null
+++ b/bin/nicely
@@ -0,0 +1,67 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ nicely COMMAND...
+ nicely -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+
+ Options:
+ -h, --help show this message
+
+ COMMAND the command to be wrapped
+
+
+ Wrap COMMAND in nice(1) and ionice(1) calls, so that it gets low
+ priority from the OS scheduler and has low disturbance regarding
+ CPU usage and disk IO bandwidth.
+
+
+ Examples:
+
+ Make the backup low priority:
+
+ $ nicely backup
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ (--)
+ break
+ ;;
+ (--help)
+ usage
+ help
+ exit
+ ;;
+ (*)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ (h)
+ usage
+ help
+ exit
+ ;;
+ (*)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+ionice -c3 nice -n19 "$@"