window-manager/scripts/volume-root.sh

33 lines
No EOL
792 B
Bash
Executable file

#!/bin/sh
# I forgot that dirname exists while writing this.
if [ -z "$1" ]; then
DIR="$HOME/.config/hypr/scripts"
SELF="$(realpath "$DIR/$(basename "$0")")"
if [ "$SELF" != "$(realpath "$0")" ]; then
echo "This script must exist inside of $DIR";
exit 1;
fi
else
if [ "root" != "$USER" ]; then
echo "Only root are allowed to arbitrarily specify the directory.";
exit 1;
fi
DIR=$1
SELF="Something went horribly wrong! You were assumed to be root in one check, but non-root by the next one.";
fi
if [ "root" != "$USER" ]; then
if [ "$SELF" != "$(realpath "$0")" ]; then
echo "This script must exist inside of $DIR";
exit 1;
fi
exec sudo "$SELF" "$DIR";
echo "NOTE: You should never see this message!"
exit 1;
fi
"$DIR/volume-bin" | grep -Eo "115 press|114 press"