waybar-lazycrypto
v0.0.5
Published
A lightweight cryptocurrency price tracker with ASCII candle charts for Waybar status bar. Get real-time crypto prices and visual trend indicators right in your status bar.
Maintainers
Readme
waybar-lazycrypto
A lightweight cryptocurrency price tracker with ASCII candle charts for Waybar status bar. Get real-time crypto prices and visual trend indicators right in your status bar.
Features
- 📊 ASCII Candle Charts - Visual price trends using ASCII characters
- 💰 Real-time Prices - Live cryptocurrency prices from KuCoin API
- 🎨 Color Support - Optional color-coded price changes and indicators
- ⏱️ Multiple Timeframes - Support for 1min to 1week intervals
- 🚀 Lightweight - Minimal dependencies, fast execution
- 🔧 Waybar Integration - Designed specifically for Waybar status bar
Installation
npm install -g waybar-lazycryptoOr use directly with npx:
npx waybar-lazycrypto BTC color 1hourUsage
Command Line
waybar-lazycrypto <symbol> [color] [timeframe]Parameters:
symbol- Cryptocurrency symbol (BTC, ETH, ADA, DOT, SOL, etc.)color- Optional. Add "color" to enable colored outputtimeframe- Optional. Default: "1hour"
Examples:
# Basic usage
waybar-lazycrypto BTC
# With color support
waybar-lazycrypto BTC color
# With custom timeframe
waybar-lazycrypto ETH color 4hour
# Without color, custom timeframe
waybar-lazycrypto SOL 15minSupported Timeframes
- Minutes: 1min, 3min, 5min, 15min, 30min
- Hours: 1hour, 2hour, 4hour, 6hour, 8hour, 12hour
- Days/Weeks: 1day, 1week
Waybar Configuration
Add this to your Waybar config file (~/.config/waybar/config):
"custom/lazycrypto": {
"exec": "npx waybar-lazycrypto BTC color 1hour",
"interval": 300,
"format": "{}",
"return-type": "json",
"on-click": "$TERMINAL -e npx lazycrypto-cli",
"signal": 8,
"on-click-right": "~/.config/waybar/cycle-timeframe.sh && pkill -RTMIN+8 waybar"
}Dynamic Timeframe Configuration
For dynamic timeframe switching, you can read from a file:
"exec": "npx waybar-lazycrypto BTC color $(cat ~/.crypto-timeframe 2>/dev/null || echo '1hour')"Create a script to cycle through timeframes (~/.config/waybar/cycle-timeframe.sh):
#!/bin/bash
TIMEFRAMES=("15min" "30min" "1hour" "4hour" "1day")
CURRENT=$(cat ~/.crypto-timeframe 2>/dev/null || echo "1hour")
for i in "${!TIMEFRAMES[@]}"; do
if [[ "${TIMEFRAMES[$i]}" == "$CURRENT" ]]; then
NEXT_INDEX=$(( (i + 1) % ${#TIMEFRAMES[@]} ))
echo "${TIMEFRAMES[$NEXT_INDEX]}" > ~/.crypto-timeframe
break
fi
doneOutput Format
Standard Output
BTC $45,234 +2.45% /\|C\//\\ 1hourJSON Output (with color flag)
{
"text": "<span>BTC</span> <span color=\"#ADD777\">$45,234</span> <span color=\"#ADD777\">+2.45%</span> /\\|C\\//\\\\ 1hour",
"tooltip": "Candle Chart Legend:\nC = Highest close price\nc = Lowest close price\nh = Highest high price\nl = Lowest low price\nT = Highest close and high\nB = Lowest close and low"
}Candle Chart Indicators
The ASCII candle visualization shows the last 12 candles with special indicators:
/- Price increased from previous candle\- Price decreased from previous candle|- Price unchangedC- Highest closing price in the windowc- Lowest closing price in the windowh- Highest high price in the windowl- Lowest low price in the windowT- Combined highest close and high (peak)B- Combined lowest close and low (bottom)
Color Scheme
When color mode is enabled:
- 🟢 Green (
#ADD777) - Price increases, highs - 🔴 Red (
#F96D7F) - Price decreases, lows - ⚪ Gray (
#94a3b8) - Neutral/unchanged
API
Programmatic Usage
import { waybarLazyCrypto } from 'waybar-lazycrypto';
await waybarLazyCrypto({
symbol: 'BTC',
selectedTimeframe: '1hour',
color: true
});Error Handling
The package handles various error scenarios gracefully:
- Connection errors - Shows "₿ Connection Error"
- Rate limiting - Shows "₿ Rate Limited"
- No data - Shows "Bitcoin No Data"
- General errors - Shows "₿ Error"
Dependencies
axios- HTTP client for API requestsdotenv- Environment variable management
Requirements
- Node.js >= 14.0.0
- Waybar (for status bar integration)
- Internet connection for real-time data
Data Source
Price data is fetched from the KuCoin Public API. No API key required.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT © A1GoKn8t
Support
For issues, questions, or suggestions, please open an issue on the GitHub repository.
Changelog
v0.0.2
- Added color support for Waybar JSON output
- Improved candle chart visualization
- Enhanced error handling
v0.0.1
- Initial release
- Basic price tracking functionality
- ASCII candle charts
