dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

commit 2e61a90caae40625dd81a06928abf8bc0a8023b6
parent 5f1d05d893c078824d6fe5a659f4d653a8397568
Author: regexghost <dev@regexghost.com>
Date:   Sat, 20 Jun 2026 22:16:25 +0100

updated bar and metoffice scripts to be compliant with POSIX core utils (switched to suckless sbase)

Diffstat:
Mpanel-scripts/lemonbar-bar.sh | 6+++---
Mpanel-scripts/metoffice.sh | 13++++++++-----
2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/panel-scripts/lemonbar-bar.sh b/panel-scripts/lemonbar-bar.sh @@ -44,7 +44,7 @@ update_vol () { } update_wifi () { - con="$(nmcli -t -f NAME c show --active | grep -v "^lo$" | head -c 6 | sed 's/ $//g')" + con="$(nmcli -t -f NAME c show --active | grep -v "^lo$" | string-trunc 6 ".." | sed 's/ $//g')" if [ "$con" = "" ]; then wifi="${wifi_down_colour} N/A${COLOUR_RESET}" @@ -84,7 +84,7 @@ update_weather () { # This is done by index so I can change the streams checked by just altering the order in the config file stream_live () { streamer_name="$(sed -n "${1}p" "$XDG_CONFIG_HOME/regexghost/streams.csv" | cut -d "," -f 1)" - first_char="$(echo "$streamer_name" | head -c 1)" + first_char="$(echo "$streamer_name" | cut -c 1-1)" live="$(stream-check -yn "$streamer_name")" if [ "$live" = "y" ]; then echo "${first_char} ${stream_live_colour} ${COLOUR_RESET}" @@ -101,7 +101,7 @@ update_streams () { update_music () { state="$(mocp -M "$XDG_CONFIG_HOME/moc" -i)" - song="$(echo "$state" | grep -e "SongTitle" -e "Artist" | tac | paste -sd "-" | sed 's/-Artist: / - /g' | sed 's/^SongTitle: //g; s/"//g' | string-trunc 16 ".." | sed 's/ $//g')" + song="$(echo "$state" | grep -e "SongTitle" -e "Artist" | tac | tr "\n" "-" | sed 's/-Artist: / - /g' | sed 's/^SongTitle: //g; s/"//g' | string-trunc 16 ".." | sed 's/ $//g')" pause="$(echo "$state" | grep -e "State" | cut -d " " -f 2)" if [ "$song" = "" ]; then music="${music_stopped_colour} N/A${COLOUR_RESET}" diff --git a/panel-scripts/metoffice.sh b/panel-scripts/metoffice.sh @@ -10,14 +10,17 @@ lat=$(cat "$curLocationFile" | cut -d "|" -f 1) lon=$(cat "$curLocationFile" | cut -d "|" -f 2) geohash=$(geohash $lat $lon 9) today_string="$(date "+%Y-%m-%d")" -tomorrow_string="$(date -d tomorrow "+%Y-%m-%d")" -second_day_string="$(date -d "+2 days" "+%Y-%m-%d")" +tomorrow_string="$(date -d $(($(date +%s)+86400)) "+%Y-%m-%d")" +second_day_string="$(date -d $(($(date +%s)+86400+86400)) "+%Y-%m-%d")" curl --connect-timeout 5 -s -L "https://weather.metoffice.gov.uk/forecast/$geohash" > "/tmp/panel_i3_data/metoffice.html" -icon_name_today=$(cat "/tmp/panel_i3_data/metoffice.html" | grep -A 5 -B 5 -i "datetime=\"$today_string\"" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') -icon_name_tomorrow=$(cat "/tmp/panel_i3_data/metoffice.html" | grep -A 5 -B 5 -i "datetime=\"$tomorrow_string\"" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') -icon_name_second_day=$(cat "/tmp/panel_i3_data/metoffice.html" | grep -A 5 -B 5 -i "datetime=\"$second_day_string\"" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') +# awk instead of grep -A/-B - https://superuser.com/questions/298123/how-to-grep-and-print-the-next-n-lines-after-the-hit/298127#298127 +icon_name_today=$(awk -v var="$today_string" '$0 ~ "datetime=\"" var "\"" {p = 5} p > 0 {print $0; p--}' "/tmp/panel_i3_data/metoffice.html" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') +icon_name_tomorrow=$(awk -v var="$today_string" '$0 ~ "datetime=\"" var "\"" {p = 5} p > 0 {print $0; p--}' "/tmp/panel_i3_data/metoffice.html" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') +icon_name_second_day=$(awk -v var="$today_string" '$0 ~ "datetime=\"" var "\"" {p = 5} p > 0 {print $0; p--}' "/tmp/panel_i3_data/metoffice.html" | grep "class=\"tab-icon\"" | sed 's/;" class.*//g' | sed 's/.*alt="//g') echo "$icon_name_today" echo "$icon_name_tomorrow" echo "$icon_name_second_day" + +