diff options
| author | Martin Guzman <55927935+brockar@users.noreply.github.com> | 2026-01-21 16:18:43 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-21 16:18:43 -0300 |
| commit | c6198c1bedeffd08ec3f60f7ba3a41e6c5870885 (patch) | |
| tree | 458c030873b4e70ff9eda0baed5df257434871f4 /config/hypr/UserScripts | |
| parent | 7dedbe3d4a4560ac15987fdf8164dbbb1f4701bf (diff) | |
| parent | 88a09344e8cc7cffe69a017eb752e8c6fa17ddcb (diff) | |
Merge pull request #927 from JaKooLit/development
Merge Development to main branch for release
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/RainbowBorders.bak.sh | 89 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/RainbowBorders.sh | 14 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperEffects.sh | 40 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperRandom.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 47 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/Weather.sh | 46 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WeatherWrap.sh | 26 |
7 files changed, 159 insertions, 108 deletions
diff --git a/config/hypr/UserScripts/RainbowBorders.bak.sh b/config/hypr/UserScripts/RainbowBorders.bak.sh new file mode 100755 index 00000000..67269b8a --- /dev/null +++ b/config/hypr/UserScripts/RainbowBorders.bak.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Smooth border cycling effect using Wallust palette or full rainbow + +# Possible values: "wallust_random", "rainbow", "gradient_flow" +EFFECT_TYPE="gradient_flow" + +WALLUST_COLORS_SOURCE="$HOME/.config/hypr/wallust/wallust-hyprland.conf" + +WALLUST_COLORS=() + +# ---------- LOAD WALLUST COLORS ---------- +if [[ "$EFFECT_TYPE" == "wallust_random" || "$EFFECT_TYPE" == "gradient_flow" ]]; then + # Accept either hex (0xffRRGGBB) or rgb(r,g,b) and normalize to 0xffRRGGBB + mapfile -t WALLUST_COLORS < <( + grep -E '^\$color[0-9]+' "$WALLUST_COLORS_SOURCE" | awk ' + function hex2(s){ return (length(s)==6 ? "0xff"s : ""); } + function rgb2(r,g,b){ return sprintf("0xff%02x%02x%02x", r, g, b); } + { + if (match($0, /0x([0-9a-fA-F]{8})/, m)) { print "0x" m[1]; next } + if (match($0, /#([0-9a-fA-F]{6})/, m)) { print hex2(m[1]); next } + if (match($0, /rgb\(([0-9]+),[ ]*([0-9]+),[ ]*([0-9]+)\)/, m)) { + print rgb2(m[1], m[2], m[3]); next + } + }' + ) + + if (( ${#WALLUST_COLORS[@]} == 0 )); then + # If wallust colors can't be loaded, fall back to random_hex + EFFECT_TYPE="rainbow" + fi +fi + +# ---------- RANDOM WALLUST COLORS ---------- +function wallust_random() { + echo "${WALLUST_COLORS[RANDOM % ${#WALLUST_COLORS[@]}]}" +} + +# ---------- RAINBOW COLORS ---------- +function random_hex() { + echo "0xff$(openssl rand -hex 3)" +} + +# ---------- FLOW MODE ---------- +BASE_COLOR="${WALLUST_COLORS[10]}" +GRAD1_COLOR="${WALLUST_COLORS[14]}" +GRAD2_COLOR="${WALLUST_COLORS[13]}" +GLOW_COLOR="${WALLUST_COLORS[15]}" + +MAX_POS=10 +GLOW_POS=0 + +function gradient_flow_color() { + local pos=$1 + local d=$(( pos - GLOW_POS )) + + # wrap distance (-9..9) + if (( d > MAX_POS/2 )); then d=$((d - MAX_POS)); fi + if (( d < -MAX_POS/2 )); then d=$((d + MAX_POS)); fi + + case "${d#-}" in + 0) echo "$GLOW_COLOR" ;; + 1) echo "$GRAD1_COLOR" ;; + 2) echo "$GRAD2_COLOR" ;; + *) echo "$BASE_COLOR" ;; + esac + + if (( pos == MAX_POS - 1 )); then + GLOW_POS=$(( (GLOW_POS + 1) % MAX_POS )) + fi +} + +# ---------- Main function ---------- + +function get_color() { + if [[ "$EFFECT_TYPE" == "wallust_random" && ${#WALLUST_COLORS[@]} -gt 0 ]]; then + wallust_random + elif [[ "$EFFECT_TYPE" == "gradient_flow" && ${#WALLUST_COLORS[@]} -ge 16 ]]; then + gradient_flow_color "$1" + else + random_hex + fi +} + +# border effect for ACTIVE window +hyprctl keyword general:col.active_border $(get_color 0) $(get_color 1) $(get_color 2) $(get_color 3) $(get_color 4) $(get_color 5) $(get_color 6) $(get_color 7) $(get_color 8) $(get_color 9) 270deg + +# border effect for INACTIVE windows +#hyprctl keyword general:col.inactive_border $(get_color 0) $(get_color 1) $(get_color 2) $(get_color 3) $(get_color 4) $(get_color 5) $(get_color 6) $(get_color 7) $(get_color 8) $(get_color 9) 270deg
\ No newline at end of file diff --git a/config/hypr/UserScripts/RainbowBorders.sh b/config/hypr/UserScripts/RainbowBorders.sh deleted file mode 100755 index 0a7fd721..00000000 --- a/config/hypr/UserScripts/RainbowBorders.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## -# for rainbow borders animation - -function random_hex() { - random_hex=("0xff$(openssl rand -hex 3)") - echo $random_hex -} - -# rainbow colors only for active window -hyprctl keyword general:col.active_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg - -# rainbow colors for inactive window (uncomment to take effect) -#hyprctl keyword general:col.inactive_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg
\ No newline at end of file diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index 89577efa..475969d6 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -106,43 +106,3 @@ fi main sleep 1 - -if [[ -n "$choice" ]]; then - # Resolve SDDM themes directory (standard and NixOS path) - sddm_themes_dir="" - if [ -d "/usr/share/sddm/themes" ]; then - sddm_themes_dir="/usr/share/sddm/themes" - elif [ -d "/run/current-system/sw/share/sddm/themes" ]; then - sddm_themes_dir="/run/current-system/sw/share/sddm/themes" - fi - - if [ -n "$sddm_themes_dir" ]; then - sddm_simple="$sddm_themes_dir/simple_sddm_2" - - # Only prompt if theme exists and its Backgrounds directory is writable - if [ -d "$sddm_simple" ] && [ -w "$sddm_simple/Backgrounds" ]; then - # Check if yad is running to avoid multiple yad notification - if pidof yad > /dev/null; then - killall yad - fi - - if yad --info --text="Set current wallpaper as SDDM background?\n\nNOTE: This only applies to SIMPLE SDDM v2 Theme" \ - --text-align=left \ - --title="SDDM Background" \ - --timeout=5 \ - --timeout-indicator=right \ - --button="yad-yes:0" \ - --button="yad-no:1" \ - ; then - - # Check if terminal exists - if ! command -v "$terminal" &>/dev/null; then - notify-send -i "$iDIR/ja.png" "Missing $terminal" "Install $terminal to enable setting of wallpaper background" - exit 1 - fi - - exec "$SCRIPTSDIR/sddm_wallpaper.sh" --effects - fi - fi - fi -fi diff --git a/config/hypr/UserScripts/WallpaperRandom.sh b/config/hypr/UserScripts/WallpaperRandom.sh index 654d4bd3..8dd680d5 100755 --- a/config/hypr/UserScripts/WallpaperRandom.sh +++ b/config/hypr/UserScripts/WallpaperRandom.sh @@ -2,12 +2,13 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Script for Random Wallpaper ( CTRL ALT W) -wallDIR="$HOME/Pictures/wallpapers" +PICTURES_DIR="$(xdg-user-dir PICTURES 2>/dev/null || echo "$HOME/Pictures")" +wallDIR="$PICTURES_DIR/wallpapers" SCRIPTSDIR="$HOME/.config/hypr/scripts" focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name') -PICS=($(find -L ${wallDIR} -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.pnm" -o -name "*.tga" -o -name "*.tiff" -o -name "*.webp" -o -name "*.bmp" -o -name "*.farbfeld" -o -name "*.gif" \))) +PICS=($(find -L "${wallDIR}" -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.pnm" -o -name "*.tga" -o -name "*.tiff" -o -name "*.webp" -o -name "*.bmp" -o -name "*.farbfeld" -o -name "*.gif" \))) RANDOMPICS=${PICS[ $RANDOM % ${#PICS[@]} ]} diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index 0029d3e5..316a7cd4 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -4,7 +4,8 @@ # WALLPAPERS PATH terminal=kitty -wallDIR="$HOME/Pictures/wallpapers" +PICTURES_DIR="$(xdg-user-dir PICTURES 2>/dev/null || echo "$HOME/Pictures")" +wallDIR="$PICTURES_DIR/wallpapers" SCRIPTSDIR="$HOME/.config/hypr/scripts" wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" @@ -98,49 +99,6 @@ menu() { done } -# Offer SDDM Simple Wallpaper Option (only for non-video wallpapers) -set_sddm_wallpaper() { - sleep 1 - - # Resolve SDDM themes directory (standard and NixOS path) - local sddm_themes_dir="" - if [ -d "/usr/share/sddm/themes" ]; then - sddm_themes_dir="/usr/share/sddm/themes" - elif [ -d "/run/current-system/sw/share/sddm/themes" ]; then - sddm_themes_dir="/run/current-system/sw/share/sddm/themes" - fi - - [ -z "$sddm_themes_dir" ] && return 0 - - local sddm_simple="$sddm_themes_dir/simple_sddm_2" - - # Only prompt if theme exists and its Backgrounds directory is writable - if [ -d "$sddm_simple" ] && [ -w "$sddm_simple/Backgrounds" ]; then - - # Check if yad is running to avoid multiple notifications - if pidof yad >/dev/null; then - killall yad - fi - - if yad --info --text="Set current wallpaper as SDDM background?\n\nNOTE: This only applies to SIMPLE SDDM v2 Theme" \ - --text-align=left \ - --title="SDDM Background" \ - --timeout=5 \ - --timeout-indicator=right \ - --button="yes:0" \ - --button="no:1"; then - - # Check if terminal exists - if ! command -v "$terminal" &>/dev/null; then - notify-send -i "$iDIR/error.png" "Missing $terminal" "Install $terminal to enable setting of wallpaper background" - exit 1 - fi - - exec "$SCRIPTSDIR/sddm_wallpaper.sh" --normal - - fi - fi -} modify_startup_config() { local selected_file="$1" @@ -186,7 +144,6 @@ apply_image_wallpaper() { "$SCRIPTSDIR/Refresh.sh" sleep 1 - set_sddm_wallpaper } apply_video_wallpaper() { diff --git a/config/hypr/UserScripts/Weather.sh b/config/hypr/UserScripts/Weather.sh index ac9abc13..4588ed1d 100755 --- a/config/hypr/UserScripts/Weather.sh +++ b/config/hypr/UserScripts/Weather.sh @@ -2,16 +2,50 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # weather info from wttr. https://github.com/chubin/wttr.in # Remember to add city +# Function to get current city from IP address with fallback -city="" +# Get your current location with your IP adress +get_current_city() { + local city + + # First try: ipinfo.io + local location_data=$(curl -fsS "https://ipinfo.io/json" 2>/dev/null) + if [ $? -eq 0 ] && [ -n "$location_data" ]; then + city=$(echo "$location_data" | grep -o '"city"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4) + if [ -n "$city" ]; then + echo "$city" + return 0 + fi + fi + + # Fallback: ipapi.co + city=$(curl -fsS "https://ipapi.co/json" 2>/dev/null | grep -o '"city"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4) + if [ -n "$city" ]; then + echo "$city" + return 0 + fi + + # Last resort: ipwho.is + city=$(curl -fsS "https://ipwho.is/" 2>/dev/null | grep -o '"city"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4) + if [ -n "$city" ]; then + echo "$city" + return 0 + fi + + # If all fail + echo "Unknown" >&2 + return 1 +} +city=$(get_current_city) -# if city is blank, use https://ipapi.co/json to get location from IP -if [ -z "$city" ]; then - city=$(curl -fsS https://ipapi.co/json | grep city | cut -f4 -d'"') +# If city is empty, that means the IP check failed, which means, we should use manual setting +if [ -z "$city" ] || [ "$city" = "Unknown" ]; then + # SET YOUR MANUAL CITY HERE + city=" " # ← Change this to your preferred city + echo "Using manual city: $city" >&2 fi - # URL-encode city for safe use in URLs encoded_city="$city" if command -v python3 >/dev/null 2>&1; then @@ -206,4 +240,4 @@ tooltip_json=$(json_escape "${weather[0]}: $temperature $cond_disp") printf '{"text":"%s", "alt":"%s", "tooltip":"%s"}\n' "$text_json" "$alt_json" "$tooltip_json" # Write a two-line cache with an actual newline between lines -printf ' %s \n%s %s\n' "$temperature" "$condition" "${weather[1]}" > "$HOME/.cache/.weather_cache"
\ No newline at end of file +printf ' %s \n%s %s\n' "$temperature" "$condition" "${weather[1]}" > "$HOME/.cache/.weather_cache" diff --git a/config/hypr/UserScripts/WeatherWrap.sh b/config/hypr/UserScripts/WeatherWrap.sh index 10c125dc..5b266930 100755 --- a/config/hypr/UserScripts/WeatherWrap.sh +++ b/config/hypr/UserScripts/WeatherWrap.sh @@ -6,6 +6,30 @@ SCRIPT_DIR="$(dirname "$0")" PY_SCRIPT="$SCRIPT_DIR/Weather.py" BASH_FALLBACK="$SCRIPT_DIR/Weather.sh" +# Function to check network connectivity +check_network() { + # Try multiple methods to check network + if ping -c1 -W2 8.8.8.8 >/dev/null 2>&1; then + return 0 + fi + + if ping -c1 -W2 1.1.1.1 >/dev/null 2>&1; then + return 0 + fi + + if curl -s --connect-timeout 3 "https://ipinfo.io" >/dev/null 2>&1; then + return 0 + fi + + return 1 +} + +# If no network, return offline status immediately +if ! check_network; then + echo '{"text":"", "alt":"Offline", "tooltip":"No network connection"}' + exit 0 +fi + run_fallback() { if [ -f "$BASH_FALLBACK" ]; then # Invoke via bash to avoid requiring +x and ensure consistent shell @@ -30,4 +54,4 @@ else echo "python3 not found in PATH — falling back to Weather.sh" >&2 run_fallback "$@" exit $? -fi
\ No newline at end of file +fi |
