[Change] Changed documentation after applying dacav's patches.
This commit is contained in:
parent
034d4a58d5
commit
5a59ee60f3
33
README.md
33
README.md
@ -6,6 +6,8 @@ Ideal for quickly sharing screenshots or images in environments like IRC without
|
|||||||
|
|
||||||
**Author:** Ritchie Cunningham <ritchie@ritchiecunningham.co.uk>
|
**Author:** Ritchie Cunningham <ritchie@ritchiecunningham.co.uk>
|
||||||
|
|
||||||
|
**Contributors:** dacav <dacav@fastmail.com>
|
||||||
|
|
||||||
**Version:** 1.0 (as of 22/04/2025)
|
**Version:** 1.0 (as of 22/04/2025)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@ -30,10 +32,11 @@ Make sure you have the following command-line tools installed:
|
|||||||
```bash
|
```bash
|
||||||
sudo apt install jq # Debian.
|
sudo apt install jq # Debian.
|
||||||
```
|
```
|
||||||
* **xclip:** Used for accessing the X11 clipboard. **This script will not work on Wayland sessions.**
|
* **xclip:** Used for accessing the X11 clipboard. **This is for X11. Wayland users, see below..**
|
||||||
```bash
|
```bash
|
||||||
sudo apt install xclip # Debian.
|
sudo apt install xclip # Debian.
|
||||||
```
|
```
|
||||||
|
* **wl-clipboard** Used for accessing the Wayland clipboard. **This is for Wayland. X11 users, see above.**
|
||||||
* **notify-send (Optional):** Used for desktop notifications. The script works without it but won't show popups.
|
* **notify-send (Optional):** Used for desktop notifications. The script works without it but won't show popups.
|
||||||
```bash
|
```bash
|
||||||
sudo apt install notify-send # Debian (often in libnotify-bin).
|
sudo apt install notify-send # Debian (often in libnotify-bin).
|
||||||
@ -55,23 +58,26 @@ Make sure you have the following command-line tools installed:
|
|||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
ln -s "$(pwd)/imgbb" ~/.local/bin/imgbb
|
ln -s "$(pwd)/imgbb" ~/.local/bin/imgbb
|
||||||
```
|
```
|
||||||
Now you can just run `imgbb` from your terminal.
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
This script requires a **free API key** from ImgBB:
|
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.
|
1. Go to [https://api.imgbb.com/](https://api.imgbb.com/) and register or log in to get your key.
|
||||||
2. Store the key in `.config/imgbb/uploader/api_key`.
|
2. Set the API key using *one* of these methods (script checks in this order):
|
||||||
* **File** Create the directory and file, then paste *only* your API key inside:
|
* Store the key in `.config/imgbb/uploader/api_key`.
|
||||||
```bash
|
* **File** Create the config file `~/.config/imgbb_uploader.conf` and add a line like:
|
||||||
mkdir -p ~/.config/imgbb_uploader
|
```bash
|
||||||
nano ~/.config/imgbb_uploader/api_key
|
echo "api_key="YOUR_KEY_HERE" > ~/.config/imgbb_uploader.conf
|
||||||
# Paste your key, save the file.
|
# Set permissions so only you can read it:
|
||||||
# Set permissions so only you can read it:
|
chmod 600 ~/.config/imgbb_uploader.conf
|
||||||
chmod 600 ~/.config/imgbb_uploader/api_key
|
```
|
||||||
```
|
* **Environment Variable:** Set the `IMGBB_API_KEY` variable in your environment
|
||||||
|
```bash
|
||||||
|
export IMGBB_API_KEY="YOUR KEY HERE"
|
||||||
|
```
|
||||||
|
Now you can just run `imgbb` from your terminal.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
**Options:**
|
**Options:**
|
||||||
|
|
||||||
@ -104,7 +110,8 @@ imgbb -h
|
|||||||
|
|
||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
Currently relies on xclip and therefore only works reliably under X11 sessions. Wayland support would require adding logic to use wl-clipboard.
|
- Supports both X11 (using xclip) and Wayland (using wl-clipboard) sessions. It detects the session type using $XDG_SESSION_TYPE.
|
||||||
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
22
imgbb
22
imgbb
@ -5,8 +5,9 @@
|
|||||||
# to ImgBB (imgbb.com) using their V1 API. Retrieves the direct
|
# to ImgBB (imgbb.com) using their V1 API. Retrieves the direct
|
||||||
# image URL, prints it to stdout, and copies it to the X11 clipboard.
|
# image URL, prints it to stdout, and copies it to the X11 clipboard.
|
||||||
# Author: Ritchie Cunningham <ritchie@ritchiecunningham.co.uk>
|
# Author: Ritchie Cunningham <ritchie@ritchiecunningham.co.uk>
|
||||||
# License: GPL License
|
# Contributors: dacav <dacav@fastmail.com>
|
||||||
# Version: 3.0
|
# License: GPL 3.0 License
|
||||||
|
# Version: 1.2
|
||||||
# Date: 22/04/2025
|
# Date: 22/04/2025
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Usage Examples:
|
# Usage Examples:
|
||||||
@ -23,18 +24,23 @@
|
|||||||
# - bash (v4+ required for =~, (( )), BASH_REMATCH)
|
# - bash (v4+ required for =~, (( )), BASH_REMATCH)
|
||||||
# - curl: (e.g., sudo apt install curl)
|
# - curl: (e.g., sudo apt install curl)
|
||||||
# - jq: (e.g., sudo apt install jq)
|
# - jq: (e.g., sudo apt install jq)
|
||||||
# - xclip: (X11 clipboard access) (e.g., sudo apt install xclip)
|
# - Clipboard tool:
|
||||||
|
# - xclip: (X11 clipboard access) (e.g., sudo apt install xclip)
|
||||||
|
# - wl-clipboard (For Wayland clipboard access) (e.g., sudo apt install wl-clipboard)
|
||||||
# - notify-send: (Optional, for desktop notifications) (e.g., sudo apt install notify-send)
|
# - notify-send: (Optional, for desktop notifications) (e.g., sudo apt install notify-send)
|
||||||
# - Coreutils: (mktemp, basename, rm, cat, echo, etc. - usually standard)
|
# - Coreutils: (mktemp, basename, rm, cat, echo, etc. - usually standard)
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Configuration:
|
# Configuration:
|
||||||
# Requires an ImgBB API key (v1). Get one free: https://api.imgbb.com/
|
# Requires an ImgBB API key (v1). Get one free: https://api.imgbb.com/
|
||||||
# Store the key:
|
# Set the API key using ONE of these methods (checked in this order):
|
||||||
# - File: ~/.config/imgbb_uploader/api_key (chmod 600 recommended)
|
# 1. Environment Variable: IMGBB_API_KEY="YOUR KEY HERE"
|
||||||
# (Create directory: mkdir -p ~/.config/imgbb_uploader)
|
# 2. Config File: Create ~/.config/imgbb_uploader.conf and add a line like:
|
||||||
|
# api_key="YOUR_KEY_HERE"
|
||||||
|
# (We'll soon have other defaults to set here).
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Notes:
|
# Notes:
|
||||||
# - Uses 'xclip', works on X11 sessions only. Wayland requires 'wl-clipboard'.
|
# - Supports both X11 (using xclip) and Wayland (using wl-clipboard) sessions.
|
||||||
|
# It detects the session type using $XDG_SESSION_TYPE.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# === Default Configuration & Argument Parsing. ===
|
# === Default Configuration & Argument Parsing. ===
|
||||||
@ -93,7 +99,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
unit="${BASH_REMATCH[2]}" # The unit part.
|
unit="${BASH_REMATCH[2]}" # The unit part.
|
||||||
|
|
||||||
# Default to minutes if no unit was provided.
|
# Default to minutes if no unit was provided.
|
||||||
if [ -z "$unit" ]; then unit="s"; fi
|
if [ -z "$unit" ]; then unit="m"; fi
|
||||||
|
|
||||||
# Calculate total seconds based on the unit.
|
# Calculate total seconds based on the unit.
|
||||||
case "$unit" in
|
case "$unit" in
|
||||||
|
Loading…
Reference in New Issue
Block a user