#!/bin/sh cfpid="${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/caffeine.pid" usage() { cat <<- EOF Usage: ${0##*/} [ -s ] [ -t timeout ] Keep your computer awake Options: -s silent or quiet mode -t EOF } note() { command -v notify-send > /dev/null && notify-send " caffeine" "$1" } die() { note "err: $1" printf "\033[31;1merr: %b\033[0m\n" "$1" 1>&2 exit "${2:-1}" } dep_check() { : "${1:?}" for dep; do command -v "$dep" > /dev/null || die "${dep} not installed" done unset dep } set_menu() { if [ -n "$WAYLAND_DISPLAY" ]; then menu="wmenu" elif [ -n "$DISPLAY" ]; then menu="dmenu" else die "can't be ran from tty, setup xorg or wayland" fi } caf_time() { dep_check "$menu" printf "1m\n3m\n5m\n10m\n15m\n30m" | "$menu" -p " sleep after " } drink() { # usage: drink