#!/usr/bin/env bash
# install_keyboard_shortcut=<Control><Alt>C

# Source the script 'common-functions.sh'.
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
source "$ROOT_DIR/common-functions.sh"

_main() {
    local input_files=""

    # Execute initial checks.
    input_files=$(_get_files "par_type=all")

    # Run the main process.
    # shellcheck disable=SC2086
    if _command_exists "file-roller"; then
        file-roller --add -- $input_files &
    elif _command_exists "ark"; then
        ark --add --dialog -- $input_files &
    elif _command_exists "engrampa"; then
        engrampa --add -- $input_files &
    elif _command_exists "lxqt-archiver"; then
        lxqt-archiver --add -- $input_files &
    elif _command_exists "arqiver"; then
        arqiver --sa $input_files &
    elif _command_exists "xarchiver"; then
        xarchiver --compress=$input_files &
    else
        _check_dependencies "command=file-roller"
        file-roller --add -- $input_files &
    fi
}

_main "$@"
