1
0
Fork 0

plenty of statusbar changes

This commit is contained in:
Luca Bilke 2024-07-24 19:16:58 +02:00
parent 34739902ad
commit 2ee59d5af1
17 changed files with 404 additions and 1752 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
pkill -RTMIN+8 dwmblocks
pkill -RTMIN+1 dwmblocks
askupgrade() {
[ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMCMD upgrades

View File

@ -2,6 +2,6 @@
# battery status file is sent in as an argument from sb-battery
upower --monitor-detail -i "$1" | while read -r _; do
pkill -RTMIN+3 dwmblocks
timeout 5 cat >/dev/null
pkill -RTMIN+4 dwmblocks
sleep 5
done

View File

@ -1,4 +1,5 @@
#!/bin/sh
playerctl status -F | while read -r _; do
pkill -RTMIN+11 dwmblocks
# WARN: Not currently used in dwmblocks
pkill -RTMIN+11 dwmblocks
done

View File

@ -11,6 +11,7 @@
updateicon() {
echo "$1" >/tmp/recordingicon
# WARN: Not currently used in dwmblocks
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
}
@ -20,6 +21,7 @@ killrecording() {
kill -15 "$recpid"
rm -f /tmp/recordingpid
updateicon ""
# WARN: Not currently used in dwmblocks
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
sleep 3

View File

@ -1,66 +1,66 @@
#!/bin/sh
. "$HOME/.local/libexec/statusbar/colors"
. "colors"
[ -z "$(ls /sys/class/power_supply)" ] && exit 0
for battery in /sys/class/power_supply/BAT?*; do
pidof -x sbd-battery >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-battery" "$battery" >/dev/null 2>&1 &
[ -n "${capacity+x}" ] && printf " "
capacity="$(cat "$battery/capacity" 2>&1)"
case "$(cat "$battery/status" 2>&1)" in
"Full")
icon="󰁹"
color="$fggreen"
;;
"Not charging")
icon="󰁹"
color="$fgwhite"
;;
"Unknown")
icon="󰂑"
color="$fgorange"
;;
"Charging")
icon="󰂄"
color="$fgcyan"
;;
"Discharging")
if [ "$capacity" -le 10 ]; then
icon="󰂎"
color="$fgred"
elif [ "$capacity" -le 20 ]; then
icon="󰁺"
color="$fgred"
elif [ "$capacity" -le 30 ]; then
icon="󰁻"
color="$fgwhite"
elif [ "$capacity" -le 40 ]; then
icon="󰁼"
color="$fgwhite"
elif [ "$capacity" -le 50 ]; then
icon="󰁽"
color="$fgwhite"
elif [ "$capacity" -le 60 ]; then
icon="󰁾"
color="$fgwhite"
elif [ "$capacity" -le 70 ]; then
icon="󰁿"
color="$fgwhite"
elif [ "$capacity" -le 80 ]; then
icon="󰂀"
color="$fgwhite"
elif [ "$capacity" -le 90 ]; then
icon="󰂁"
color="$fgwhite"
elif [ "$capacity" -le 100 ]; then
icon="󰂂"
color="$fgwhite"
else
icon="󰁹"
color="$fgwhite"
fi
;;
*) exit 1 ;;
esac
printf "%b" "<span $color>$icon</span> $capacity"
pidof -x sbd-battery >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-battery" "$battery" >/dev/null 2>&1 &
[ -n "${capacity+x}" ] && printf " "
capacity="$(cat "$battery/capacity" 2>&1)"
case "$(cat "$battery/status" 2>&1)" in
"Full")
icon="󰁹"
color="$fggreen"
;;
"Not charging")
icon="󰁹"
color="$fggreen"
;;
"Unknown")
icon="󰂑"
color="$fgorange"
;;
"Charging")
icon="󰂄"
color="$fgcyan"
;;
"Discharging")
if [ "$capacity" -le 10 ]; then
icon="󰂎"
color="$fgred"
elif [ "$capacity" -le 20 ]; then
icon="󰁺"
color="$fgred"
elif [ "$capacity" -le 30 ]; then
icon="󰁻"
color="$fgwhite"
elif [ "$capacity" -le 40 ]; then
icon="󰁼"
color="$fgwhite"
elif [ "$capacity" -le 50 ]; then
icon="󰁽"
color="$fgwhite"
elif [ "$capacity" -le 60 ]; then
icon="󰁾"
color="$fgwhite"
elif [ "$capacity" -le 70 ]; then
icon="󰁿"
color="$fgwhite"
elif [ "$capacity" -le 80 ]; then
icon="󰂀"
color="$fgwhite"
elif [ "$capacity" -le 90 ]; then
icon="󰂁"
color="$fgwhite"
elif [ "$capacity" -le 100 ]; then
icon="󰂂"
color="$fgwhite"
else
icon="󰁹"
color="$fgwhite"
fi
;;
*) exit 1 ;;
esac
printf "%b" "<span $color>$icon</span> $capacity"
done && printf "\\n"

View File

@ -1,5 +1,5 @@
#!/bin/sh
. "$HOME/.local/libexec/statusbar/colors"
. "colors"
cache=$XDG_RUNTIME_DIR/cpubarscache
@ -13,23 +13,23 @@ printf "%b" " $temp"
first=true
echo "$stats" | while read -r row; do
id=${row%% *}
rest=${row#* }
total=${rest%% *}
idle=${rest##* }
case "$(
echo "$old" |
awk '{if ($1 == id) printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle" 2>/dev/null
)" in
"0") col=$fggreen icon=▁ ;;
"1") col=$fggreen icon=▂ ;;
"2") col=$fggreen icon=▃ ;;
"3") col=$fgorange icon=▄ ;;
"4") col=$fgorange icon=▅ ;;
"5") col=$fgorange icon=▆ ;;
"6" | "7" | "8") col=$fgred icon=▇ ;;
esac
id=${row%% *}
rest=${row#* }
total=${rest%% *}
idle=${rest##* }
case "$(
echo "$old" |
awk '{if ($1 == id) printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle" 2>/dev/null
)" in
"0") col=$fggreen icon=▁ ;;
"1") col=$fggreen icon=▂ ;;
"2") col=$fggreen icon=▃ ;;
"3") col=$fgorange icon=▄ ;;
"4") col=$fgorange icon=▅ ;;
"5") col=$fgorange icon=▆ ;;
"6" | "7" | "8") col=$fgred icon=▇ ;;
esac
if [ "$col" != "$prevcol" ]; then
[ "$first" != "true" ] && printf "%b" "</span>"
printf "%b" "<span $col>"

View File

@ -1,4 +1,5 @@
#!/bin/sh
. "colors"
IFS='
'
@ -15,7 +16,7 @@ for mnt in $(findmnt -Py -t "$types"); do
*) icon="" ;;
esac
$first || printf " "
echo "${icon} $(df -h "$TARGET" | awk ' /[0-9]/ {print $3 "/" $2}')"
printf "%b" "${icon} $(df -h "$TARGET" | awk ' /[0-9]/ {print $3 "/" $2}')"
first=false
done
printf "\n"

View File

@ -1,5 +1,5 @@
#!/bin/sh
. "$HOME/.local/libexec/statusbar/colors"
. "colors"
# NOTE: This script takes its dwmblocks update signal as an argument so that it can refresh itself (defaults to 5)
# Options can be found at https://wttr.in/:help
@ -11,26 +11,27 @@ weatheropts="?FA"
emojiopts="?FA&format=%c"
getforecast() {
curl -sfL --retry 5 "$url$weatheropts" >"$weatherfile" || return 1
curl -sfL "$url$emojiopts" --retry 5 | sed 's/☀️//;s/☁️//;s/⛅️//;s/⛈//;s/✨//;s/❄️//;s/🌦//;s/🌧//;s/🌨//;s/🌩//;s/🌫//;' | cut -d ' ' -f 1 >"$emojifile" || return 1
curl -sfL --retry 5 "$url$weatheropts" >"$weatherfile" || return 1
curl -sfL "$url$emojiopts" --retry 5 | sed 's/☀️//;s/☁️//;s/⛅️//;s/⛈//;s/✨//;s/❄️//;s/🌦//;s/🌧//;s/🌨//;s/🌩//;s/🌫//;' | cut -d ' ' -f 1 >"$emojifile" || return 1
}
fresh() {
[ -s "$weatherfile" ] && [ "$(stat -c %y "$weatherfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
[ -s "$weatherfile" ] && [ "$(stat -c %y "$weatherfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
}
readfile() {
weather="$(cat "$weatherfile")"
precipitation="$(echo "$weather" | sed '16q;d' | grep -wo "[0-9]*%" | sort -rn | head -1q)"
highlow="$(echo "$weather" | sed '13q;d' | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/[+m]//g' | sort -g | sed -e 1b -e '$!d')"
emoji="$(cat "$emojifile")"
weather="$(cat "$weatherfile")"
precipitation="$(echo "$weather" | sed '16q;d' | grep -wo "[0-9]*%" | sort -rn | head -1q)"
highlow="$(echo "$weather" | sed '13q;d' | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/[+m]//g' | sort -g | sed -e 1b -e '$!d')"
emoji="$(cat "$emojifile")"
}
output() {
readfile
printf "%b" "$emoji $precipitation <span $fgblue></span> $(echo "$highlow" | cut -d" " -f1)° <span $fgred></span> $(echo "$highlow" | cut -d" " -f2)°\n"
readfile
printf "%b" "$emoji $precipitation <span $fgblue></span> $(echo "$highlow" | cut -d" " -f1)° <span $fgred></span> $(echo "$highlow" | cut -d" " -f2)°\n"
}
if fresh; then
output
output
else
getforecast && pkill "-RTMIN+${1:-5}" dwmblocks &
printf "%b" " Getting Weather\n"
# WARN: Not currently used in dwmblocks
getforecast && pkill "-RTMIN+5" dwmblocks &
printf "%b" " Getting Weather\n"
fi

View File

@ -1,4 +1,5 @@
#!/bin/sh
. "colors"
shift=""

View File

@ -1,6 +1,16 @@
#!/bin/sh
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
loc_addr="$(ip route get 9.9.9.9 | head -1 | cut -d ' ' -f7)"
pub_addr="$(curl ipv4.icanhazip.com 2>/dev/null)" || exit
# flag="$(grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed 's/ flag: .*//')"
printf "%s %s\n" "$loc_addr" "$pub_addr"
. "colors"
cache="${XDG_CACHE_HOME:-$HOME/.cache}/geoip"
# loc_addr="$(ip route get 9.9.9.9 | awk 'NR==1 {print $7}')"
pub_addr="$(curl -s ipv4.icanhazip.com 2>/dev/null)"
location="$(awk -F: -v ip="$pub_addr" '$1==ip {print $2}' "$cache")"
[ -z "$location" ] && {
location="$(curl -s "https://reallyfreegeoip.org/json/${pub_addr}" | jq -r '.country_name')"
echo "${pub_addr}:${location}" >>"$cache"
}
flag="$(awk -v loc="$location" '$0 ~ loc {print $1}' "${XDG_DATA_HOME:-$HOME/.local/share}/emoji")"
echo "${flag} ${pub_addr}"

View File

@ -1,3 +1,5 @@
#!/bin/sh
. "colors"
printf "%b" "󰘚 "
free -m | awk 'NR==2 { printf ("%2.2fG/%2.2fG\n", ($3 / 1024), ($2 / 1024)) }'

View File

@ -1,15 +1,17 @@
#!/bin/sh
. "colors"
filter() {
if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then
song=$(mpc current -f "%artist% - %title%" | xargs -0)
[ ${#song} -gt 35 ] && song="$(printf %.35s "$song")…"
mpc | awk 'NR==2' | grep -q playing && icon="󰏤" || icon="󰐊"
echo "$icon $song"
elif mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 1 ]; then
echo "󰓛"
else
exit 1
fi
if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then
song=$(mpc current -f "%artist% - %title%" | xargs -0)
[ ${#song} -gt 35 ] && song="$(printf %.35s "$song")…"
mpc | awk 'NR==2' | grep -q playing && icon="󰏤" || icon="󰐊"
echo "$icon $song"
elif mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 1 ]; then
echo "󰓛"
else
exit 1
fi
}
pidof -x sbd-music >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-music" >/dev/null 2>&1 &
filter

View File

@ -1,17 +1,17 @@
#!/bin/sh
# . "$HOME/.local/libexec/statusbar/colors"
. "colors"
# TODO: Coloring based on speed
update() {
sum=0
for arg; do
read -r i <"$arg"
sum=$((sum + i))
done
cache=$XDG_RUNTIME_DIR/${1##*/}
[ -f "$cache" ] && read -r old <"$cache" || old=0
printf "%b" "$sum\n" >"$cache"
printf "%b" "$((sum - old))\n"
sum=0
for arg; do
read -r i <"$arg"
sum=$((sum + i))
done
cache=$XDG_RUNTIME_DIR/${1##*/}
[ -f "$cache" ] && read -r old <"$cache" || old=0
printf "%b" "$sum\n" >"$cache"
printf "%b" "$((sum - old))\n"
}
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)

View File

@ -1,4 +1,5 @@
#!/bin/sh
. "colors"
icon=""

View File

@ -1,4 +1,5 @@
#!/bin/sh
. "colors"
pidof -x sbd-playerctl >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-playerctl" >/dev/null 2>&1 &
[ "$(playerctl status 2>&1)" = "No players found" ] && printf "%b" "" && exit 1

File diff suppressed because it is too large Load Diff

261
.local/share/emoji Normal file
View File

@ -0,0 +1,261 @@
🇦🇨 Ascension Island
🇦🇩 Andorra
🇦🇪 United Arab Emirates
🇦🇫 Afghanistan
🇦🇬 Antigua & Barbuda
🇦🇮 Anguilla
🇦🇱 Albania
🇦🇲 Armenia
🇦🇴 Angola
🇦🇶 Antarctica
🇦🇷 Argentina
🇦🇸 American Samoa
🇦🇹 Austria
🇦🇺 Australia
🇦🇼 Aruba
🇦🇽 Åland Islands
🇦🇿 Azerbaijan
🇧🇦 Bosnia & Herzegovina
🇧🇧 Barbados
🇧🇩 Bangladesh
🇧🇪 Belgium
🇧🇫 Burkina Faso
🇧🇬 Bulgaria
🇧🇭 Bahrain
🇧🇮 Burundi
🇧🇯 Benin
🇧🇱 St. Barthélemy
🇧🇲 Bermuda
🇧🇳 Brunei
🇧🇴 Bolivia
🇧🇶 Caribbean Netherlands
🇧🇷 Brazil
🇧🇸 Bahamas
🇧🇹 Bhutan
🇧🇻 Bouvet Island
🇧🇼 Botswana
🇧🇾 Belarus
🇧🇿 Belize
🇨🇦 Canada
🇨🇨 Cocos (Keeling) Islands
🇨🇩 Congo - Kinshasa
🇨🇫 Central African Republic
🇨🇬 Congo - Brazzaville
🇨🇭 Switzerland
🇨🇮 Côte dIvoire
🇨🇰 Cook Islands
🇨🇱 Chile
🇨🇲 Cameroon
🇨🇳 China
🇨🇴 Colombia
🇨🇵 Clipperton Island
🇨🇷 Costa Rica
🇨🇺 Cuba
🇨🇻 Cape Verde
🇨🇼 Curaçao
🇨🇽 Christmas Island
🇨🇾 Cyprus
🇨🇿 Czechia
🇩🇪 Germany
🇩🇬 Diego Garcia
🇩🇯 Djibouti
🇩🇰 Denmark
🇩🇲 Dominica
🇩🇴 Dominican Republic
🇩🇿 Algeria
🇪🇦 Ceuta & Melilla
🇪🇨 Ecuador
🇪🇪 Estonia
🇪🇬 Egypt
🇪🇭 Western Sahara
🇪🇷 Eritrea
🇪🇸 Spain
🇪🇹 Ethiopia
🇪🇺 European Union
🇫🇮 Finland
🇫🇯 Fiji
🇫🇰 Falkland Islands
🇫🇲 Micronesia
🇫🇴 Faroe Islands
🇫🇷 France
🇬🇦 Gabon
🇬🇧 United Kingdom
🇬🇩 Grenada
🇬🇪 Georgia
🇬🇫 French Guiana
🇬🇬 Guernsey
🇬🇭 Ghana
🇬🇮 Gibraltar
🇬🇱 Greenland
🇬🇲 Gambia
🇬🇳 Guinea
🇬🇵 Guadeloupe
🇬🇶 Equatorial Guinea
🇬🇷 Greece
🇬🇸 South Georgia & South Sandwich Islands
🇬🇹 Guatemala
🇬🇺 Guam
🇬🇼 Guinea-Bissau
🇬🇾 Guyana
🇭🇰 Hong Kong SAR China
🇭🇲 Heard & McDonald Islands
🇭🇳 Honduras
🇭🇷 Croatia
🇭🇹 Haiti
🇭🇺 Hungary
🇮🇨 Canary Islands
🇮🇩 Indonesia
🇮🇪 Ireland
🇮🇱 Israel
🇮🇲 Isle of Man
🇮🇳 India
🇮🇴 British Indian Ocean Territory
🇮🇶 Iraq
🇮🇷 Iran
🇮🇸 Iceland
🇮🇹 Italy
🇯🇪 Jersey
🇯🇲 Jamaica
🇯🇴 Jordan
🇯🇵 Japan
🇰🇪 Kenya
🇰🇬 Kyrgyzstan
🇰🇭 Cambodia
🇰🇮 Kiribati
🇰🇲 Comoros
🇰🇳 St. Kitts & Nevis
🇰🇵 North Korea
🇰🇷 South Korea
🇰🇼 Kuwait
🇰🇾 Cayman Islands
🇰🇿 Kazakhstan
🇱🇦 Laos
🇱🇧 Lebanon
🇱🇨 St. Lucia
🇱🇮 Liechtenstein
🇱🇰 Sri Lanka
🇱🇷 Liberia
🇱🇸 Lesotho
🇱🇹 Lithuania
🇱🇺 Luxembourg
🇱🇻 Latvia
🇱🇾 Libya
🇲🇦 Morocco
🇲🇨 Monaco
🇲🇩 Moldova
🇲🇪 Montenegro
🇲🇫 St. Martin
🇲🇬 Madagascar
🇲🇭 Marshall Islands
🇲🇰 North Macedonia
🇲🇱 Mali
🇲🇲 Myanmar (Burma)
🇲🇳 Mongolia
🇲🇴 Macao SAR China
🇲🇵 Northern Mariana Islands
🇲🇶 Martinique
🇲🇷 Mauritania
🇲🇸 Montserrat
🇲🇹 Malta
🇲🇺 Mauritius
🇲🇻 Maldives
🇲🇼 Malawi
🇲🇽 Mexico
🇲🇾 Malaysia
🇲🇿 Mozambique
🇳🇦 Namibia
🇳🇨 New Caledonia
🇳🇪 Niger
🇳🇫 Norfolk Island
🇳🇬 Nigeria
🇳🇮 Nicaragua
🇳🇱 Netherlands
🇳🇴 Norway
🇳🇵 Nepal
🇳🇷 Nauru
🇳🇺 Niue
🇳🇿 New Zealand
🇴🇲 Oman
🇵🇦 Panama
🇵🇪 Peru
🇵🇫 French Polynesia
🇵🇬 Papua New Guinea
🇵🇭 Philippines
🇵🇰 Pakistan
🇵🇱 Poland
🇵🇲 St. Pierre & Miquelon
🇵🇳 Pitcairn Islands
🇵🇷 Puerto Rico
🇵🇸 Palestinian Territories
🇵🇹 Portugal
🇵🇼 Palau
🇵🇾 Paraguay
🇶🇦 Qatar
🇷🇪 Réunion
🇷🇴 Romania
🇷🇸 Serbia
🇷🇺 Russia
🇷🇼 Rwanda
🇸🇦 Saudi Arabia
🇸🇧 Solomon Islands
🇸🇨 Seychelles
🇸🇩 Sudan
🇸🇪 Sweden
🇸🇬 Singapore
🇸🇭 St. Helena
🇸🇮 Slovenia
🇸🇯 Svalbard & Jan Mayen
🇸🇰 Slovakia
🇸🇱 Sierra Leone
🇸🇲 San Marino
🇸🇳 Senegal
🇸🇴 Somalia
🇸🇷 Suriname
🇸🇸 South Sudan
🇸🇹 São Tomé & Príncipe
🇸🇻 El Salvador
🇸🇽 Sint Maarten
🇸🇾 Syria
🇸🇿 Eswatini
🇹🇦 Tristan da Cunha
🇹🇨 Turks & Caicos Islands
🇹🇩 Chad
🇹🇫 French Southern Territories
🇹🇬 Togo
🇹🇭 Thailand
🇹🇯 Tajikistan
🇹🇰 Tokelau
🇹🇱 Timor-Leste
🇹🇲 Turkmenistan
🇹🇳 Tunisia
🇹🇴 Tonga
🇹🇷 Turkey
🇹🇹 Trinidad & Tobago
🇹🇻 Tuvalu
🇹🇼 Taiwan
🇹🇿 Tanzania
🇺🇦 Ukraine
🇺🇬 Uganda
🇺🇲 U.S. Outlying Islands
🇺🇳 United Nations
🇺🇸 United States
🇺🇾 Uruguay
🇺🇿 Uzbekistan
🇻🇦 Vatican City
🇻🇨 St. Vincent & Grenadines
🇻🇪 Venezuela
🇻🇬 British Virgin Islands
🇻🇮 U.S. Virgin Islands
🇻🇳 Vietnam
🇻🇺 Vanuatu
🇼🇫 Wallis & Futuna
🇼🇸 Samoa
🇽🇰 Kosovo
🇾🇪 Yemen
🇾🇹 Mayotte
🇿🇦 South Africa
🇿🇲 Zambia
🇿🇼 Zimbabwe
🏴󠁧󠁢󠁥󠁮󠁧󠁿 England
🏴󠁧󠁢󠁳󠁣󠁴󠁿 Scotland
🏴󠁧󠁢󠁷󠁬󠁳󠁿 Wales