From 2e2e29e43e99cfd647cf37a3bd864f0778118574 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 2 Mar 2020 13:53:12 +0100 Subject: Rewrite wrapper for Signal --- .local/bin/signal | 66 +++++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) (limited to '.local/bin/signal') diff --git a/.local/bin/signal b/.local/bin/signal index 452b556..bf8d198 100755 --- a/.local/bin/signal +++ b/.local/bin/signal @@ -1,53 +1,37 @@ -#! /usr/bin/env sh +#!/bin/sh + +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU Affero General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. + +readonly BINS=" + /usr/bin/signal-desktop +" main() { - # Handle opts - opts "$@" - shift "$OPTS" - unset OPTS - - # Show help - [ "$OPT_HELP_ONLY" ] && usage && exit 0 - - export TMPDIR=${XDG_CACHE_HOME:-$HOME/.local/tmp} + for bin in $BINS + do + [ -x "$bin" ] || continue - mkdir -p -- "/run/user/$UID/doc/by-app/org.signal.Signal" + export TMPDIR="${XDG_CACHE_HOME:-$HOME/.local/tmp}" + mkdir -p -- "/run/user/$UID/doc/by-app/org.signal.Signal" - exec signal-desktop -} + exec "$bin" "$@" + done -opts() -{ - OPTS=0 + printf "No underlying executable found for %s:\n" "${0##*/}" >&2 - while getopts ":h" opt + for bin in $BINS do - case "$opt" in - h) OPT_HELP_ONLY=1 ;; - *) - printf "Invalid option passed: %s\n" "$OPTARG" >&2 - ;; - esac + printf "\t%s\n" "$bin" >&2 done - - unset opt -} - -usage() -{ - cat <