2021-01-04 18:27:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
LOGFILE=$HOME/log/sway.log
|
|
|
|
|
|
|
|
## helpers
|
|
|
|
function _log() {
|
|
|
|
mkdir -p $(dirname $LOGFILE)
|
|
|
|
echo $(date) $* | tee -a $LOGFILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function _check_app() {
|
|
|
|
which $1 &> /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
_log _check_app: ERROR missing app \"$1\"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _check_inhibit() {
|
|
|
|
if [ -e $1 ]; then
|
|
|
|
_log _check_inhibit: INFO found inhibit file $1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _set_inhibit() {
|
|
|
|
file=$1
|
|
|
|
action=$2
|
|
|
|
case "$action" in
|
|
|
|
0|off)
|
|
|
|
rm -f $file
|
|
|
|
_log _set_inhibit: INFO inhibit disabled
|
|
|
|
;;
|
2021-01-04 18:46:33 +01:00
|
|
|
1|on)
|
2021-01-04 18:27:42 +01:00
|
|
|
touch $file
|
|
|
|
_log _set_inhibit: INFO inhibit enabled
|
|
|
|
;;
|
2021-01-04 18:46:33 +01:00
|
|
|
*)
|
|
|
|
status=0
|
|
|
|
if [ -f $file ]; then
|
|
|
|
status=1
|
|
|
|
fi
|
|
|
|
_log _set_inhibit: INFO inhibit status: $status
|
|
|
|
;;
|
2021-01-04 18:27:42 +01:00
|
|
|
esac
|
|
|
|
}
|