keepassxc-flatpak-wrapper.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. #
  3. # Flatpak Multiple Commands Wrapper
  4. # Copyright (C) 2022 KeePassXC team <https://keepassxc.org/>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 2 or (at your option)
  9. # version 3 of the License.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # This script is a workaround to the limitation of one command per Flatpak
  19. # manifest. It solves this by redirecting stdio to keepassxc-proxy, as
  20. # necessary, based upon matching command line arguments.
  21. # For format of parsed arguments, see "Connection-based messaging" at:
  22. # https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
  23. # Chromium, Google Chrome, Vivaldi & Brave
  24. readonly arg1='chrome-extension://oboonakemofpalcgghocfoadofidjkkk'
  25. # Firefox & Tor Browser
  26. readonly arg2='keepassxc-browser@keepassxc.org'
  27. # Check arguments to see if this was a proxy launch from the browser
  28. # Use =~ to account for minor variations in the chrome extension
  29. if [[ "$1" =~ "$arg1" || "$2" == "$arg2" ]]; then
  30. exec keepassxc-proxy "$@"
  31. elif [[ "$1" == "cli" ]]; then
  32. exec keepassxc-cli "${@:2}"
  33. else
  34. # If no arguments are matched or browser integration is off, execute keepassxc
  35. exec keepassxc "$@"
  36. fi