commit 4a6050b93074cc88d8232827ab78e22ebe056297 Author: UniverseBow Date: Fri Feb 20 21:15:08 2026 -0800 initial commit diff --git a/eww/cava.sh b/eww/cava.sh new file mode 100755 index 0000000..4d3fb23 --- /dev/null +++ b/eww/cava.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cava -p <(cat < 1 ? "${round(EWW_NET["eno1"].NET_DOWN / 1048576, 1)}M" : "${round(EWW_NET["eno1"].NET_DOWN / 1024, 0)}Kb"})) +(defwidget netup [] + (system-progress + :class "netup" + :tip "Up ${round(EWW_NET["eno1"].NET_UP / 1048576, 1)} MB/s" + :value {min(max(log(EWW_NET["eno1"].NET_UP / 1024 + 1, 10000) * 100, 0), 100)} + :icon "󰕒" + :pct {EWW_NET["eno1"].NET_UP / 1048576 > 1 ? "${round(EWW_NET["eno1"].NET_UP / 1048576, 1)}M" : "${round(EWW_NET["eno1"].NET_UP / 1024, 0)}Kb"})) +(defwidget disk [] + (system-progress + :class "disk" + :tip "SSD ${round(EWW_DISK["/"].used_perc, 1)}%" + :value {round(EWW_DISK["/"].used_perc, 0)} + :icon "" + :pct "${round(EWW_DISK["/"].used_perc, 1)}%")) + +;;-------------------------------------------------------------------------------------------- + +(defwidget systemwidget [] + (box + :class "system box" + :orientation "h" + :spacing 10 + :space-evenly false + (box :orientation "v" :spacing 8 :space-evenly false :hexpand false + (image :path "/home/lorkan/cpu.svg" :image-width 40 :image-height 40) + (box :orientation "h" :spacing 8 :space-evenly true :hexpand true + (cpu) + (cput))) + (box :class "spacer" :orientation "v" :hexpand false) + (box :orientation "v" :spacing 8 :space-evenly false :hexpand false + (image :path "/home/lorkan/gpu.svg" :image-width 40 :image-height 40) + (box :orientation "h" :spacing 8 :space-evenly true :hexpand true + (gpu) + (gput))) + (box :class "spacer" :orientation "v" :hexpand false) + (box :orientation "v" :spacing 8 :space-evenly false :hexpand false + (image :class "svg" :path "/home/lorkan/ram.png" :image-width 40 :image-height 40) + (box :orientation "h" :spacing 8 :space-evenly true :hexpand true + (ram) + (swap))) + (box :class "spacer" :orientation "v" :hexpand false) + (box :orientation "h" :spacing 8 :space-evenly true :hexpand true + (netdown) + (netup) + (disk)))) +(defwidget system-progress [class value icon pct tip] + (box + :class "progress" + :orientation "v" + :spacing 0 + (progress + :orientation "v" + :flipped true + :class class + :value value + :halign "center" + :tooltip tip) + (box + :orientation "v" + (label :class "label" :text icon :halign "center") + (label :class "label2" :text pct :halign "center")))) + +(defwindow status + :monitor 1 + :geometry (geometry :x "10px" :y "10px" :width "80px" :height "30px" + :anchor "top l") + :stacking "bottom" + (systemwidget)) diff --git a/eww/get-cover.sh b/eww/get-cover.sh new file mode 100755 index 0000000..dbd1fc7 --- /dev/null +++ b/eww/get-cover.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# This script fetches and caches album art for the current song. +# It's designed to be called by EWW and is optimized to minimize +# network and disk I/O. + +WIDGET_DIR=$(dirname "$0") +DEFAULT_COVER="$WIDGET_DIR/assets/DEFAULTImage.jpeg" +CACHE_DIR="$HOME/.cache/eww/music-widget" +mkdir -p "$CACHE_DIR" + +# Function to safely exit with the default cover +show_default_cover() { + echo "$DEFAULT_COVER" + exit 0 +} + +# Get the art URL. Exit if player is not running or no URL is available. +COVER_URL=$(playerctl metadata mpris:artUrl 2>/dev/null) +if [[ -z "$COVER_URL" ]]; then + show_default_cover +fi + +# If it's a local file (file://), decode the path and use it directly. +if [[ "$COVER_URL" == file://* ]]; then + # URL-decode the path to handle special characters like spaces + LOCAL_PATH=$(printf '%b' "${COVER_URL#file://}") + if [[ -f "$LOCAL_PATH" ]]; then + echo "$LOCAL_PATH" + exit 0 + else + show_default_cover + fi +fi + +# For web URLs, we hash the URL to create a unique filename for caching. +URL_HASH=$(echo -n "$COVER_URL" | md5sum | awk '{print $1}') +# Try to get a file extension from the URL, default to .jpg if it's weird. +EXTENSION="${COVER_URL##*.}" +if [[ "$EXTENSION" == "$COVER_URL" ]] || [[ ${#EXTENSION} -gt 5 ]]; then + EXTENSION="jpg" +fi +CACHED_COVER="$CACHE_DIR/$URL_HASH.$EXTENSION" + +# If the cover is not already cached, download it. +if [ ! -f "$CACHED_COVER" ]; then + # Download with a 5-second timeout. If it fails or the downloaded file is empty, + # clean up and show the default cover. + curl -s -L --max-time 5 "$COVER_URL" -o "$CACHED_COVER" + if [[ $? -ne 0 ]] || [[ ! -s "$CACHED_COVER" ]]; then + rm -f "$CACHED_COVER" + show_default_cover + fi +fi + +# As a final sanity check, ensure the cached file is a valid image. +# If not, remove the junk file and show the default cover. +if file "$CACHED_COVER" | grep -qE 'image|jpeg|png|jpg|gif'; then + echo "$CACHED_COVER" +else + rm -f "$CACHED_COVER" + show_default_cover +fi + +exit 0 diff --git a/eww/scripts/weather_info b/eww/scripts/weather_info new file mode 100755 index 0000000..4f6b5e3 --- /dev/null +++ b/eww/scripts/weather_info @@ -0,0 +1,147 @@ +#!/bin/bash + +## Collect data +cache_dir="$HOME/.cache/eww/weather" +cache_weather_stat=${cache_dir}/weather-stat +cache_weather_degree=${cache_dir}/weather-degree +cache_weather_quote=${cache_dir}/weather-quote +cache_weather_hex=${cache_dir}/weather-hex +cache_weather_icon=${cache_dir}/weather-icon + +## Weather data +KEY="527ef08abfd3b851a188de297cbae02c" +ID="5342992" +UNIT="imperial" # Available options : 'metric' or 'imperial' + +## Make cache dir +if [[ ! -d "$cache_dir" ]]; then + mkdir -p ${cache_dir} +fi + +## Get data +get_weather_data() { + weather=`curl -sf "http://api.openweathermap.org/data/2.5/weather?APPID="$KEY"&id="$ID"&units="$UNIT""` + echo ${weather} + + if [ ! -z "$weather" ]; then + weather_temp=`echo "$weather" | jq ".main.temp" | cut -d "." -f 1` + weather_icon_code=`echo "$weather" | jq -r ".weather[].icon" | head -1` + weather_description=`echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g"` + + #Big long if statement of doom + if [ "$weather_icon_code" == "50d" ]; then + weather_icon=" " + weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..." + weather_hex="#84afdb" + elif [ "$weather_icon_code" == "50n" ]; then + weather_icon=" " + weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..." + weather_hex="#84afdb" + elif [ "$weather_icon_code" == "01d" ]; then + weather_icon=" " + weather_quote="It's a sunny day, gonna be fun! \nDon't go wandering all by yourself though..." + weather_hex="#ffd86b" + elif [ "$weather_icon_code" == "01n" ]; then + weather_icon=" " + weather_quote="It's a clear night \nYou might want to take a evening stroll to relax..." + weather_hex="#fcdcf6" + elif [ "$weather_icon_code" == "02d" ]; then + weather_icon=" " + weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." + weather_hex="#adadff" + elif [ "$weather_icon_code" == "02n" ]; then + weather_icon=" " + weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" + weather_hex="#adadff" + elif [ "$weather_icon_code" == "03d" ]; then + weather_icon=" " + weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." + weather_hex="#adadff" + elif [ "$weather_icon_code" == "03n" ]; then + weather_icon=" " + weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" + weather_hex="#adadff" + elif [ "$weather_icon_code" == "04d" ]; then + weather_icon=" " + weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." + weather_hex="#adadff" + elif [ "$weather_icon_code" == "04n" ]; then + weather_icon=" " + weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" + weather_hex="#adadff" + elif [ "$weather_icon_code" == "09d" ]; then + weather_icon=" " + weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..." + weather_hex="#6b95ff" + elif [ "$weather_icon_code" == "09n" ]; then + weather_icon=" " + weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..." + weather_hex="#6b95ff" + elif [ "$weather_icon_code" == "10d" ]; then + weather_icon=" " + weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..." + weather_hex="#6b95ff" + elif [ "$weather_icon_code" == "10n" ]; then + weather_icon=" " + weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..." + weather_hex="#6b95ff" + elif [ "$weather_icon_code" == "11d" ]; then + weather_icon="" + weather_quote="There's storm for forecast today \nMake sure you don't get blown away..." + weather_hex="#ffeb57" + elif [ "$weather_icon_code" == "11n" ]; then + weather_icon="" + weather_quote="There's gonna be storms tonight \nMake sure you're warm in bed and the windows are shut..." + weather_hex="#ffeb57" + elif [ "$weather_icon_code" == "13d" ]; then + weather_icon=" " + weather_quote="It's gonna snow today \nYou'd better wear thick clothes and make a snowman as well!" + weather_hex="#e3e6fc" + elif [ "$weather_icon_code" == "13n" ]; then + weather_icon=" " + weather_quote="It's gonna snow tonight \nMake sure you get up early tomorrow to see the sights..." + weather_hex="#e3e6fc" + elif [ "$weather_icon_code" == "40d" ]; then + weather_icon=" " + weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..." + weather_hex="#84afdb" + elif [ "$weather_icon_code" == "40n" ]; then + weather_icon=" " + weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..." + weather_hex="#84afdb" + else + weather_icon=" " + weather_quote="Sort of odd, I don't know what to forecast \nMake sure you have a good time!" + weather_hex="#adadff" + fi + echo "$weather_icon" > ${cache_weather_icon} + echo "$weather_description" > ${cache_weather_stat} + echo "$weather_temp""°F" > ${cache_weather_degree} + echo -e "$weather_quote" > ${cache_weather_quote} + echo "$weather_hex" > ${cache_weather_hex} + else + echo "Weather Unavailable" > ${cache_weather_stat} + echo " " > ${cache_weather_icon} + echo -e "Ah well, no weather huh? \nEven if there's no weather, it's gonna be a great day!" > ${cache_weather_quote} + echo "-" > ${cache_weather_degree} + echo "#adadff" > ${tcache_weather_hex} + fi +} + +## Execute +if [[ "$1" == "--getdata" ]]; then + get_weather_data +elif [[ "$1" == "--icon" ]]; then + cat ${cache_weather_icon} +elif [[ "$1" == "--temp" ]]; then + cat ${cache_weather_degree} +elif [[ "$1" == "--hex" ]]; then + cat ${cache_weather_hex} +elif [[ "$1" == "--stat" ]]; then + cat ${cache_weather_stat} +elif [[ "$1" == "--quote" ]]; then + cat ${cache_weather_quote} | head -n1 +elif [[ "$1" == "--quote2" ]]; then + cat ${cache_weather_quote} | tail -n1 +fi + diff --git a/eww/volumecontroller.sh b/eww/volumecontroller.sh new file mode 100755 index 0000000..9339182 --- /dev/null +++ b/eww/volumecontroller.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# A script to control volume using pamixer. +# +# Usage: +# volumecontroller.sh [value] +# +# Commands: +# up - Increase volume by 'step' +# down - Decrease volume by 'step' +# mute - Toggle mute +# get - Get current volume percentage +# set - Set volume to a specific percentage [value] + +set -e # Exit immediately if a command exits with a non-zero status. + +COMMAND="$1" +VALUE="$2" +STEP=5 + +case $COMMAND in + up) + pamixer -i "${VALUE:-$STEP}" + ;; + down) + pamixer -d "${VALUE:-$STEP}" + ;; + mute) + pamixer -t + ;; + get) + pamixer --get-volume + ;; + set) + if [ -z "$VALUE" ]; then + echo "Usage: $0 set <0-100>" >&2 + exit 1 + fi + pamixer --set-volume "$VALUE" + ;; + *) + echo "Usage: $0 [value]" >&2 + exit 1 + ;; +esac \ No newline at end of file