~robertgzr/bluedesk

422a8924609fc3c5ebbd5cb93ed58dc591835a8b — Robert Günzler 1 year, 8 months ago e1eaf6a
simplify contrib/desk script

Signed-off-by: Robert Günzler <r@gnzler.io>
1 files changed, 6 insertions(+), 18 deletions(-)

M contrib/desk
M contrib/desk => contrib/desk +6 -18
@@ 12,21 12,9 @@ esac
printf "ensure bluetoothd is started...\n"
{ rc-service bluetooth status || doas rc-service bluetooth start; } >/dev/null

trap '{ exit 3; }' INT
retries=3
while true; do
	printf "running bluedesk...\n"
	err=$(bluedesk "${pos}" 2>&1 1>/dev/stdout)
	# shellcheck disable=SC2181
	if [ $? -ne 0 ]; then
		notify-send -u critical "desk $1" "${err}"
		sleep 1
		retries=$((retries - 1))
		if [ "${#retries}" -eq 0 ]; then
			notify-send -u critical "desk $1" "giving up"
			exit 1
		fi
	else
		exit 0
	fi
done
bluedesk "${pos}"

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
	notify-send -i /usr/share/icons/mdi/scalable/desk.svg -u critical "desk" "failed to change position to $1"
fi