diff --git a/polybar-themes/sblocks/config-4k.ini b/polybar-themes/sblocks/config-4k.ini index 5902730..9bf82e4 100644 --- a/polybar-themes/sblocks/config-4k.ini +++ b/polybar-themes/sblocks/config-4k.ini @@ -145,7 +145,7 @@ font-2 = "FiraCode Nerd Font:size=10;3" modules-left = sep launcher sep workspaces sep cust-mpd-prev custom-mpd cust-mpd-next modules-center = title ; modules-right = color-switch sep alsa sep battery sep network sep date sep sysmenu sep -modules-right = updates sep bluetooth-4k sep pulseaudio sep battery sep network sep date sep sysmenu sep +modules-right = updates sep bluetooth-4k sep pulseaudio sep battery sep network sep date weather sep sysmenu sep ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ diff --git a/polybar-themes/sblocks/config.ini b/polybar-themes/sblocks/config.ini index 30d04aa..c535a3f 100644 --- a/polybar-themes/sblocks/config.ini +++ b/polybar-themes/sblocks/config.ini @@ -144,11 +144,11 @@ font-3 = "Material Icons:size=10;3" ; modules-center = xwindow xbacklight ; modules-right = ipc clock -; modules-left = sep menu sep workspaces sep cust-mpd-prev custom-mpd cust-mpd-next modules-left = sep launcher sep workspaces sep cust-mpd-icon cust-mpd-prev custom-mpd cust-mpd-next modules-center = title ; modules-right = color-switch sep alsa sep battery sep network sep date sep sysmenu sep -modules-right = updates sep bluetooth sep pulseaudio sep network-wlan sep date sep sysmenu sep +; modules-right = package-updates-trigger package-updates bluetooth sep pulseaudio sep network-wlan sep weather sep date sep sysmenu sep +modules-right = bluetooth sep pulseaudio sep network-wlan sep date weather sep sysmenu sep ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ diff --git a/polybar-themes/sblocks/scripts/openweathermap-fullfeatured.sh b/polybar-themes/sblocks/scripts/openweathermap-fullfeatured.sh new file mode 100755 index 0000000..cea89f5 --- /dev/null +++ b/polybar-themes/sblocks/scripts/openweathermap-fullfeatured.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash + +[ -f "$HOME/.weatherkey" ] && source "$HOME/.weatherkey" + +get_icon() { + case $1 in + # Icons for weather-icons + 01d) icon="" ;; + 01n) icon="" ;; + 02d) icon="" ;; + 02n) icon="" ;; + 03*) icon="" ;; + 04*) icon="" ;; + 09d) icon="" ;; + 09n) icon="" ;; + 10d) icon="" ;; + 10n) icon="" ;; + 11d) icon="" ;; + 11n) icon="" ;; + 13d) icon="" ;; + 13n) icon="" ;; + 50d) icon="" ;; + 50n) icon="" ;; + *) icon="" ;; + + # Icons for Font Awesome 5 Pro + # 01d) icon="";; + # 01n) icon="";; + # 02d) icon="";; + # 02n) icon="";; + # 03d) icon="";; + # 03n) icon="";; + # 04*) icon="";; + # 09*) icon="";; + # 10d) icon="";; + # 10n) icon="";; + # 11*) icon="";; + # 13*) icon="";; + # 50*) icon="";; + # *) icon=""; + esac + + echo $icon +} + +get_duration() { + + osname=$(uname -s) + + case $osname in + *BSD) date -r "$1" -u +%H:%M ;; + *) date --date="@$1" -u +%H:%M ;; + esac + +} + +KEY="$OPENWEATHERMAP_KEY" +# CITY="Ann Arbor" +CITY="Los%20Angeles" +UNITS="imperial" +SYMBOL="°" + +API="https://api.openweathermap.org/data/2.5" + +if [ -n "$CITY" ]; then + if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then + CITY_PARAM="id=$CITY" + else + CITY_PARAM="q=$CITY" + fi + current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS") + forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1") + # echo "$current | $forecast" +else + location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue) + + if [ -n "$location" ]; then + location_lat="$(echo "$location" | jq '.location.lat')" + location_lon="$(echo "$location" | jq '.location.lng')" + + current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS") + forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1") + fi +fi + +if [ -n "$current" ] && [ -n "$forecast" ]; then + current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1) + current_icon=$(echo "$current" | jq -r ".weather[0].icon") + + forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1) + forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon") + + if [ "$current_temp" -gt "$forecast_temp" ]; then + trend="" + elif [ "$forecast_temp" -gt "$current_temp" ]; then + trend="" + else + trend="" + fi + + sun_rise=$(echo "$current" | jq ".sys.sunrise") + sun_set=$(echo "$current" | jq ".sys.sunset") + now=$(date +%s) + now2=$(date +%h-%d-%Y) + #now2=$(date +%h/%d/%Y) + #now2=$(date +%h/%d--%H:%m) + now2_symbol="" + + if [ "$sun_rise" -gt "$now" ]; then + daytime=" $(get_duration "$((sun_rise - now))")" + elif [ "$sun_set" -gt "$now" ]; then + daytime=" $(get_duration "$((sun_set - now))")" + else + daytime=" $(get_duration "$((sun_rise - now))")" + fi + + # WITH TREND AND DAYTIME + # echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime" + # WITH TREND + # echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL" + + # ex color string + # "%{F#e5c07b}xyz%{F- }" + COLOR="" + if [ "$current_temp" -lt 0 ]; then + COLOR="%{F#1E90FF}" + elif [ "$current_temp" -ge 0 ] && [ "$current_temp" -le 40 ]; then + COLOR="%{F#46d9ff}" + elif [ "$current_temp" -gt 40 ] && [ "$current_temp" -le 80 ]; then + COLOR="%{F#ecbe7b}" + elif [ "$current_temp" -gt 80 ] && [ "$current_temp" -le 120 ]; then + COLOR="%{F#ff6c6b}" + fi + # echo "$COLOR$(get_icon "$current_icon") $current_temp$SYMBOL%{F- }" + echo "| $COLOR$(get_icon "$current_icon") $current_temp$SYMBOL%{F- }" + # echo "$(get_icon "$current_icon") $current_temp$SYMBOL $now2_symbol $now2" + # echo "$(get_icon "$current_icon") $current_temp$SYMBOL" +fi diff --git a/polybar-themes/sblocks/scripts/package-updates b/polybar-themes/sblocks/scripts/package-updates new file mode 100755 index 0000000..ac9cec2 --- /dev/null +++ b/polybar-themes/sblocks/scripts/package-updates @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +format() { + if [ "$1" -eq 0 ]; then + echo '-' + else + echo "$1" + fi +} + +if ! updates_arch="$(checkupdates | wc -l)"; then + updates_arch=0 +fi + +if ! updates_aur="$(paru -Qum 2>/dev/null | wc -l)"; then + updates_aur=0 +fi + +updates="$((updates_arch + updates_aur))" + +if [ "$updates" -gt 0 ]; then + #echo " ($(format $updates_arch)/$(format $updates_aur))" + # echo " ($(format $updates_arch)/$(format $updates_aur))" + # dunstify -i "/usr/share/icons/breeze-dark/mimetypes/24/package-x-generic.svg" " Outdated Packages: ($(format $updates_arch)/$(format $updates_aur))" + # dunstify -i "/usr/share/icons/breeze-dark/mimetypes/24/package-x-generic.svg" "Outdated Packages: ($(format $updates_arch)/$(format $updates_aur))" + echo "%{B#ecbe7b} %{B-}%{B#464b55} ($(format $updates_arch)/$(format $updates_aur)) %{B-}" +else + echo +fi diff --git a/polybar-themes/sblocks/user_modules.ini b/polybar-themes/sblocks/user_modules.ini index 934c8d5..91bf3d5 100644 --- a/polybar-themes/sblocks/user_modules.ini +++ b/polybar-themes/sblocks/user_modules.ini @@ -13,7 +13,7 @@ type = custom/script ; Available tokens: ; %counter% ; Command to be executed (using "/usr/bin/env sh -c [command]") -exec = ~/.config/polybar/blocks/scripts/updates.sh +exec = ~/SudacodeRice/polybar-themes/slocks/scripts/updates.sh ; Conditional command that, if defined, needs to exit successfully ; before the main exec command is invoked. @@ -316,4 +316,29 @@ format-prefix-padding = 1 format-overline = ${color.background} format-underline = ${color.background} +[module/package-updates] +type = custom/ipc +interval = 400 +hook-0 = ~/SudacodeRice/polybar-themes/sblocks/scripts/package-updates +format-padding = 1 +format-background = ${color.yellow} +format-overline = ${color.background} +format-underline = ${color.background} + +[module/package-updates-trigger] +type = custom/script +exec = polybar-msg hook package-updates 1 &>/dev/null +interval = 400 + +[module/weather] +type = custom/script +exec = ~/SudacodeRice/polybar-themes/sblocks/scripts/openweathermap-fullfeatured.sh +click-left = gnome-weather +interval = 600 +format-font = 3 +format-background = ${color.background-alt} +format-padding = 1 +format-prefix-padding = 1 +format-overline = ${color.background} +format-underline = ${color.background} ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ diff --git a/scripts/rofi-bluetooth b/scripts/rofi-bluetooth index 93e7a63..e527c76 100755 --- a/scripts/rofi-bluetooth +++ b/scripts/rofi-bluetooth @@ -183,7 +183,8 @@ toggle_trust() { # Useful for status bars like polybar, etc. print_status() { if power_on; then - printf '' + # printf '' + echo -n "%{F#A3BE8C}  %{F-}" mapfile -t paired_devices < <(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2) counter=0 @@ -203,7 +204,8 @@ print_status() { done printf "\n" else - echo "" + # echo "" + echo -n "%{F#EC7875}  %{F-}" fi } diff --git a/scripts/rofi-bluetooth.desktop b/scripts/rofi-bluetooth.desktop index 670f04e..e116ff4 100755 --- a/scripts/rofi-bluetooth.desktop +++ b/scripts/rofi-bluetooth.desktop @@ -183,7 +183,7 @@ toggle_trust() { # Useful for status bars like polybar, etc. print_status() { if power_on; then - echo "%{F#A3BE8C}  %{F-}" + echo -n "%{F#A3BE8C}  %{F-}" mapfile -t paired_devices < <(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2) counter=0 @@ -203,7 +203,7 @@ print_status() { done printf "\n" else - echo "%{F#EC7875}  %{F-}" + echo -n "%{F#EC7875}  %{F-}" fi }