From b17345ecdfc63fff90656d906e6974df32c11c08 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 29 May 2021 19:03:23 +0100 Subject: [PATCH] Update some commands and change terminal to st --- .config/shell/profile | 3 +- .local/bin/cron/checkup | 8 +-- .local/bin/cron/crontog | 0 .local/bin/cron/newsup | 4 +- .local/bin/statusbar/sb-forecast | 89 ++++++++++++++++++++------ .local/bin/statusbar/sb-iplocate | 10 --- .local/bin/statusbar/sb-kbselect | 2 +- .local/bin/statusbar/sb-news | 10 +-- .local/bin/statusbar/sb-pacpackages | 4 +- .local/share/applications/file.desktop | 2 +- .local/share/applications/mail.desktop | 2 +- .local/share/applications/text.desktop | 2 +- 12 files changed, 88 insertions(+), 48 deletions(-) mode change 100644 => 100755 .local/bin/cron/checkup mode change 100644 => 100755 .local/bin/cron/crontog mode change 100644 => 100755 .local/bin/cron/newsup delete mode 100755 .local/bin/statusbar/sb-iplocate diff --git a/.config/shell/profile b/.config/shell/profile index 9bf50fc..14f7f0c 100644 --- a/.config/shell/profile +++ b/.config/shell/profile @@ -9,8 +9,9 @@ unsetopt PROMPT_SP # Default programs export EDITOR="nvim" -export TERMINAL="alacritty" +export TERMINAL="st" export BROWSER="firefox" +export LOCATION="guildford" # ~/ Clean-up: export TOWER="$HOME/Tower" diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup old mode 100644 new mode 100755 index d754317..26cbe65 --- a/.local/bin/cron/checkup +++ b/.local/bin/cron/checkup @@ -2,9 +2,7 @@ # Syncs repositories and downloads updates, meant to be run as a cronjob. -ping -q -c 1 example.org > /dev/null || exit - -notify-send "📦 Repository Sync" "Checking for package updates..." +notify-send " Repository Sync" "Checking for package updates..." sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. Check your internet connection, if pacman is already running, or run update manually to see errors." @@ -12,7 +10,7 @@ pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" if pacman -Qu | grep -v "\[ignored\]" then - notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update." + notify-send " Repository Sync" "Updates available. Click statusbar icon () for update." else - notify-send "📦 Repository Sync" "Sync complete. No new packages for update." + notify-send " Repository Sync" "Sync complete. No new packages for update." fi diff --git a/.local/bin/cron/crontog b/.local/bin/cron/crontog old mode 100644 new mode 100755 diff --git a/.local/bin/cron/newsup b/.local/bin/cron/newsup old mode 100644 new mode 100755 index 29f2b3c..c2091e8 --- a/.local/bin/cron/newsup +++ b/.local/bin/cron/newsup @@ -3,13 +3,11 @@ # Set as a cron job to check for new RSS entries for newsboat. # If newsboat is open, sends it an "R" key to refresh. -ping -q -c 1 example.org > /dev/null || exit - /usr/bin/notify-send "📰 Updating RSS feeds..." pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit -echo 🔃 > /tmp/newsupdate +echo  > /tmp/newsupdate pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}" /usr/bin/newsboat -x reload rm -f /tmp/newsupdate diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index 26df501..5c95197 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -1,35 +1,88 @@ #!/bin/sh -# Displays todays precipication chance (☔) and daily low (🥶) and high (🌞). +# Displays todays precipication chance () and daily low () and high (). # Usually intended for the statusbar. # If we have internet, get a weather report from wttr.in and store it locally. # You could set up a shell alias to view the full file in a pager in the # terminal if desired. This function will only be run once a day when needed. -weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" -getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} +weather_report="${XDG_DATA_HOME:-$HOME/.local/share}/weather_report" -# Some very particular and terse stream manipulation. We get the maximum -# precipitation chance and the daily high and low from the downloaded file and -# display them with coresponding emojis. -showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | - grep -wo "[0-9]*%" | sort -rn | sed "s/^//g;1q" | tr -d '\n')" -sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " " $1 "°","" $2 "°"}' ;} +get_forecast() { + curl -sf "wttr.in/$LOCATION?format=j1" > "$weather_report" || exit 1 +} + +codes="113= +116= +119= +122= +143= +176= +179= +182= +185= +200= +227= +230= +248= +260= +263= +266= +281= +284= +293= +296= +299= +302= +305= +308= +311= +314= +317= +320= +323= +326= +329= +332= +335= +338= +350= +353= +356= +359= +362= +365= +368= +371= +374= +377= +386= +389= +392= +395=" + +show_weather() { + weather_code="$(cat "$weather_report" | jq -r '.current_condition[0].weatherCode')" + temperature="$(cat "$weather_report" | jq -r '.current_condition[0].FeelsLikeC')" + + echo "$codes" | sed -n "/$weather_code/{s/[0-9]*=//;p;q}" | tr -d '\n' + + symbol="$([[ $temperature -lt 15 ]] && echo  || echo )" + + echo " $temperature$symbol" +} case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; - 2) getforecast && showweather ;; + 1) setsid -f "$TERMINAL" -e curl "wttr.in/$LOCATION";; + 2) get_forecast && show_weather ;; 3) notify-send "🌈 Weather module" "\- Left click for full forecast. -- Middle click to update forecast. -: Chance of rain/snow -: Daily low -: Daily high" ;; +- Middle click to update forecast." ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac # The test if our forcecast is updated to the day. If it isn't download a new # weather report from wttr.in with the above function. -[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || - getforecast +[ "$(stat -c %y "$weather_report" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + get_forecast -showweather +show_weather diff --git a/.local/bin/statusbar/sb-iplocate b/.local/bin/statusbar/sb-iplocate deleted file mode 100755 index 02adab8..0000000 --- a/.local/bin/statusbar/sb-iplocate +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Gets your public ip address checks which country you are in and -# displays that information in the statusbar -# -# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ - -ifinstalled "geoip" || exit -addr="$(curl ifconfig.me 2>/dev/null)" || exit -grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//" diff --git a/.local/bin/statusbar/sb-kbselect b/.local/bin/statusbar/sb-kbselect index f0c923f..ceebe17 100755 --- a/.local/bin/statusbar/sb-kbselect +++ b/.local/bin/statusbar/sb-kbselect @@ -13,4 +13,4 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -echo "$kb" +echo " $kb" diff --git a/.local/bin/statusbar/sb-news b/.local/bin/statusbar/sb-news index fd8a36b..4db6a49 100755 --- a/.local/bin/statusbar/sb-news +++ b/.local/bin/statusbar/sb-news @@ -4,14 +4,14 @@ # When clicked, brings up `newsboat`. case $BLOCK_BUTTON in - 1) setsid "$TERMINAL" -e newsboat ;; - 2) setsid -f newsup >/dev/null exit ;; - 3) notify-send "📰 News module" "\- Shows unread news items + 1) setsid "$TERMINAL" -e newsboat ;; + 2) setsid -f newsup >/dev/null exit ;; + 3) notify-send " News module" "\- Shows unread news items - Shows  if updating with \`newsup\` - Left click opens newsboat - Middle click syncs RSS feeds Note: Only one instance of newsboat (including updates) may be running at a time." ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac - cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)" + cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print " " $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)" diff --git a/.local/bin/statusbar/sb-pacpackages b/.local/bin/statusbar/sb-pacpackages index 6f318b6..e4e5238 100755 --- a/.local/bin/statusbar/sb-pacpackages +++ b/.local/bin/statusbar/sb-pacpackages @@ -20,10 +20,10 @@ case $BLOCK_BUTTON in 1) setsid -f "$TERMINAL" -e sb-popupgrade ;; 2) notify-send "$(/usr/bin/pacman -Qu)" ;; - 3) notify-send "🎁 Upgrade module" ": number of upgradable packages + 3) notify-send " Upgrade module" ": number of upgradable packages - Left click to upgrade packages - Middle click to show upgradable packages" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -pacman -Qu | grep -Fcv "[ignored]" | sed "s/^//;s/^0$//g" +pacman -Qu | grep -Fcv "[ignored]" | sed "s/^//;s/^0$//g" diff --git a/.local/share/applications/file.desktop b/.local/share/applications/file.desktop index 33e187f..369bdc0 100644 --- a/.local/share/applications/file.desktop +++ b/.local/share/applications/file.desktop @@ -1,4 +1,4 @@ [Desktop Entry] Type=Application Name=File Manager -Exec=/usr/bin/alacritty -e lf %u +Exec=/usr/local/bin/st -e lf %u diff --git a/.local/share/applications/mail.desktop b/.local/share/applications/mail.desktop index 27ff82d..d24aea2 100644 --- a/.local/share/applications/mail.desktop +++ b/.local/share/applications/mail.desktop @@ -1,4 +1,4 @@ [Desktop Entry] Type=Application Name=Mail -Exec=/usr/bin/alacritty -e neomutt %u +Exec=/usr/local/bin/st -e neomutt %u diff --git a/.local/share/applications/text.desktop b/.local/share/applications/text.desktop index 812da78..41ee05f 100644 --- a/.local/share/applications/text.desktop +++ b/.local/share/applications/text.desktop @@ -1,4 +1,4 @@ [Desktop Entry] Type=Application Name=Text editor -Exec=/usr/bin/alacritty -e nvim %u +Exec=/usr/local/bin/st -e nvim %u