NickelMenu icon indicating copy to clipboard operation
NickelMenu copied to clipboard

Feature request: easily switch api_endpoint

Open barrymossel opened this issue 2 years ago • 2 comments

Currently I use calibre-web as my api_endpoint, but that's hosted locally and on vacation I rather use the bol/kobo store. Would it be possible to have a switch in NickelMenu to change the api_endpoint (and reboot), so I can choose where to download books from?

barrymossel avatar Jun 15 '23 12:06 barrymossel

What I did is this:

  1. Edit your configuration file Kobo eReader.conf to include an additional key api_endpoint_backup=....
  2. Next to this file, create a file switch.sh with the content below:
#/bin/bash
set -e
SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )")
cd "${SCRIPT_DIR}"

INPUT="Kobo eReader.conf"

# Extract the values into variables
api_endpoint_value=$(sed -n 's/^api_endpoint=//p' "$INPUT")
api_endpoint_backup_value=$(sed -n 's/^api_endpoint_backup=//p' "$INPUT")
# Replace values
sed -i.bak \
    -e "s|^api_endpoint=.*|api_endpoint=$api_endpoint_backup_value|" \
    -e "s|^api_endpoint_backup=.*|api_endpoint_backup=$api_endpoint_value|" "$INPUT"

# Output result
cat "${INPUT}" | grep "api_endpoint\="
  1. Make sure to chmod +x switch.sh
  2. Edit your config file /mnt/onboard/.adds/nm/config and add the line below: menu_item :main :SwitchEndpoint :cmd_output :500:/mnt/onboard/.kobo/Kobo/switch.sh

You can then run this action from the NickelMenu and reboot your Kobo to apply it.

ragusa87 avatar Aug 11 '24 22:08 ragusa87

@ragusa87 Thank you sir! It's working!

Regarding the first point, please remember to add the following two lines to your Kobo eReader.conf:

api_endpoint=https://yourdomain/kobo/........... api_endpoint_backup=https://storeapi.kobo.com/

This ensures that your Kobo device will have the correct main and backup API endpoints configured.

eric09230 avatar Sep 10 '24 09:09 eric09230