yubioath-flutter/resources/linux/desktop_integration.sh

69 lines
1.5 KiB
Bash
Raw Normal View History

2022-10-07 10:12:54 +03:00
#!/bin/bash
#
# Copyright (C) 2022 Yubico.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
DESKTOP_FILENAME="com.yubico.authenticator.desktop"
DESKTOP_FILE="${HOME}/.local/share/applications/${DESKTOP_FILENAME}"
2022-10-07 11:18:32 +03:00
EXEC_DIRNAME=$(dirname "$0")
EXEC_PATH=$(cd "$EXEC_DIRNAME" && pwd)
2022-10-07 10:12:54 +03:00
help() {
2022-10-07 11:18:32 +03:00
echo "Integrate Yubico Authenticator with common desktop environments."
2022-10-07 10:12:54 +03:00
echo
echo "Usage: -i | --install -- install desktop file"
echo " -u | --uninstall -- uninstall desktop file"
echo " -h | --help -- show usage"
}
install() {
2022-10-07 11:18:32 +03:00
sed -e "s|@EXEC_PATH|${EXEC_PATH}|g" \
<"${EXEC_PATH}/linux_support/${DESKTOP_FILENAME}" \
>"${DESKTOP_FILE}"
2022-10-07 10:12:54 +03:00
echo "Created file: ${DESKTOP_FILE}"
}
uninstall() {
rm "${DESKTOP_FILE}"
echo "Removed: ${DESKTOP_FILE}"
}
while [[ "$#" -gt 0 ]]; do
case $1 in
-i | --install)
install
exit 0
;;
-u | --uninstall)
uninstall
exit 0
;;
-h | --help)
help
exit 0
;;
*)
echo "Unknown parameter passed: $1"
help
exit 1
;;
esac
shift
done
help