Skip to content

Instantly share code, notes, and snippets.

@ephemient
Created March 27, 2018 05:15
Show Gist options
  • Save ephemient/a82d74a244c545e6de4c295ab38e45f2 to your computer and use it in GitHub Desktop.
Save ephemient/a82d74a244c545e6de4c295ab38e45f2 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
inhibit() {
while { read -n1 -r -s -t30 || [[ $? -gt 128 ]]; } && [[ -z ${REPLY} ]]; do
dbus-send --session --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity
done
}
if [[ $# -gt 0 ]]; then
coproc inhibit >&2
command "$@" {COPROC[0]}<&- {COPROC[1]}>&-
else
inhibit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment