Rename blob_claude_key to generic blob_key for storing multiple secrets

This commit is contained in:
2026-07-27 11:41:14 -04:00
parent fb57093a75
commit c68e8c38cb
4 changed files with 61 additions and 42 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ The installer automatically exposes scripts from the `scripts/` directory as glo
- **`blob_glass [on|off|toggle]`**: A quick toggle to enable or disable window transparency on the fly.
- **`blob_boot [path]`**: Safely updates your Plymouth boot splash image (defaults to `branding/boot_flash.png`) and rebuilds the `initramfs` (GRUB compatible via `mkinitcpio`).
- **`blob_wifi`**: A streamlined script to connect to the GMU Eduroam Wi-Fi network using `iwd` and `systemd-resolved` (replaces NetworkManager).
- **`blob_claude_key <set|show|clear>`**: Stores your Claude Console Admin API key (`sk-ant-admin01-...`), used by the Claude Code Usage card in the quick settings panel to pull daily token and cost stats.
- **`blob_key <set|show|clear|list> [NAME] [VALUE]`**: Stores secrets/env values for widgets and services, e.g. `blob_key set ANTHROPIC_ADMIN_KEY sk-ant-admin01-...` for the Claude Code Usage card in the quick settings panel.
## Installation
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
KEY_FILE="$HOME/.config/ags/secrets/anthropic_admin_key"
KEY_FILE="$HOME/.config/ags/secrets/ANTHROPIC_ADMIN_KEY"
if [ ! -f "$KEY_FILE" ]; then
echo '{"available":false,"tokens":0,"costUsd":0}'
-40
View File
@@ -1,40 +0,0 @@
#!/bin/bash
KEY_FILE="$HOME/.config/ags/secrets/anthropic_admin_key"
usage() {
echo "Usage: blob_claude_key <set|show|clear>"
echo " set <key> Store your Anthropic Admin API key (sk-ant-admin01-...)"
echo " show Print the stored key, masked"
echo " clear Remove the stored key"
exit 1
}
case "$1" in
set)
key="$2"
if [ -z "$key" ]; then
echo "Usage: blob_claude_key set <key>"
exit 1
fi
mkdir -p "$(dirname "$KEY_FILE")"
printf '%s' "$key" > "$KEY_FILE"
chmod 600 "$KEY_FILE"
echo "Admin key saved to $KEY_FILE"
;;
show)
if [ -f "$KEY_FILE" ]; then
key=$(cat "$KEY_FILE")
echo "${key:0:14}...${key: -4}"
else
echo "No admin key stored"
fi
;;
clear)
rm -f "$KEY_FILE"
echo "Admin key removed"
;;
*)
usage
;;
esac
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
SECRETS_DIR="$HOME/.config/ags/secrets"
usage() {
echo "Usage: blob_key <set|show|clear|list> [NAME] [VALUE]"
echo " set <NAME> <VALUE> Store a secret (e.g. ANTHROPIC_ADMIN_KEY)"
echo " show <NAME> Print a stored secret, masked"
echo " clear <NAME> Remove a stored secret"
echo " list List the names of stored secrets"
exit 1
}
case "$1" in
set)
name="$2"
value="$3"
if [ -z "$name" ] || [ -z "$value" ]; then
echo "Usage: blob_key set <NAME> <VALUE>"
exit 1
fi
mkdir -p "$SECRETS_DIR"
printf '%s' "$value" > "$SECRETS_DIR/$name"
chmod 600 "$SECRETS_DIR/$name"
echo "Saved $name to $SECRETS_DIR/$name"
;;
show)
name="$2"
if [ -z "$name" ]; then
echo "Usage: blob_key show <NAME>"
exit 1
fi
if [ -f "$SECRETS_DIR/$name" ]; then
value=$(cat "$SECRETS_DIR/$name")
echo "${value:0:6}...${value: -4}"
else
echo "No key stored for $name"
fi
;;
clear)
name="$2"
if [ -z "$name" ]; then
echo "Usage: blob_key clear <NAME>"
exit 1
fi
rm -f "$SECRETS_DIR/$name"
echo "Removed $name"
;;
list)
if [ -d "$SECRETS_DIR" ]; then
ls -1 "$SECRETS_DIR"
else
echo "No keys stored"
fi
;;
*)
usage
;;
esac