diff --git a/README.md b/README.md index 860a87c..2b9420b 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ This script requires a **free API key** from ImgBB: 1. Go to [https://api.imgbb.com/](https://api.imgbb.com/) and register or log in to get your key. 2. Set the API key using *one* of these methods (script checks in this order): * Store the key in `.config/imgbb/uploader/api_key`. - * **File** Create the config file `~/.config/imgbb_uploader.conf` and add a line like: + * **File** Move the `imgbb_uploader.conf` from the root directory of this project into `~/.config`. + * Edit the file to include your API key, and optionally set up your own personal defaults. ```bash - echo "api_key="YOUR_KEY_HERE" > ~/.config/imgbb_uploader.conf # Set permissions so only you can read it: chmod 600 ~/.config/imgbb_uploader.conf ``` diff --git a/imgbb b/imgbb index aeee10f..eb15f78 100755 --- a/imgbb +++ b/imgbb @@ -13,13 +13,17 @@ # === Default Configuration & Argument Parsing. === -api_key="" config_file="$HOME/.config/imgbb_uploader.conf" +# imgbb first reads defaults from ~/.config/imgbb_uploader.conf. +# If defaults not found in the config file, it reads them from the values +# assigned below. +# Optional flags override both config and values below. +api_key="" filepath="" -expire_seconds="7200" # 2h - Set to "" for no expiry. or use flag -e 0, never or none. +expire_seconds="" custom_name="" -markdown_mode="false" -org_mode="false" +markdown_mode="" +org_mode="" clipboard="$XDG_SESSION_TYPE" [ ! -e "$config_file" ] || . "$config_file" @@ -270,6 +274,8 @@ curl_opts+=(--form "image=@$TMP_IMG") if [ -n "$expire_seconds" ]; then curl_opts+=(--form "expiration=$expire_seconds") + # Confirm what value is being sent. + echo "Sending expiration: $expire_seconds seconds." fi if [ -n "$custom_name" ]; then curl_opts+=(--form "name=$custom_name") diff --git a/imgbb_uploader.conf b/imgbb_uploader.conf new file mode 100644 index 0000000..b35f3f4 --- /dev/null +++ b/imgbb_uploader.conf @@ -0,0 +1,17 @@ +# Template Configuration File. Place this under ~/.config/ + +# (REQUIRED) Replace this with your actual key. +api_key="YOUR_API_KEY_FROM_IMG_BB_WEBSITE" + +# Set default expiration time in seconds. +# expire_seconds="3600" # Default to 1 hour. +# expire_seconds="86400" # Default to 1 day. +expire_seconds="" # Default to NO expiration. + +# Set default output format (only set one! Or none for raw URL which is the default). +#markdown_mode="true" +#org_mode="true" + + +# Default custom name (I think this isn't ideal to set as a default). +# custom_name="MyDefaultUploadName"