update dotfiles
This commit is contained in:
3
regolith3/i3xrocks/90_time
Normal file
3
regolith3/i3xrocks/90_time
Normal file
@@ -0,0 +1,3 @@
|
||||
# Date Time
|
||||
[time]
|
||||
interval=xresource:i3xrocks.time.interval 10
|
||||
93
regolith3/i3xrocks/scripts/net-traffic
Normal file
93
regolith3/i3xrocks/scripts/net-traffic
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeu -o pipefail
|
||||
|
||||
# Note: net-traffic uses interval type 'repeat' so cannot use button events.
|
||||
# See https://github.com/vivien/i3blocks#interval
|
||||
|
||||
# some default values for arguments"
|
||||
UP=${label_icon:-$(xrescat i3xrocks.label.up " up")}
|
||||
DN=${label_icon:-$(xrescat i3xrocks.label.dn " dn")}
|
||||
DLY=${DLY:-5}
|
||||
ERROR_DLY=${ERROR_DLY:-10}
|
||||
RT=${RT:-}
|
||||
|
||||
# Padding the output to 5 characters to avoid jittering on the bar
|
||||
NUMFMT="numfmt --to iec --format %f --padding 5"
|
||||
|
||||
# determine the net interface name, but only use one interface
|
||||
# there could be several default routes, if you have a VPN for example
|
||||
IF="${BLOCK_INSTANCE:-$(awk '$2 == 00000000 && $1 !~ /(ppp|tun|tap)/ { print $1; exit }' < /proc/net/route)}"
|
||||
|
||||
IF_PATH="/sys/class/net/${IF}"
|
||||
|
||||
if [ -d "${IF_PATH}/bonding" ]; then
|
||||
# this is a bond, use the active slave's interface
|
||||
IF="$(< "${IF_PATH}/bonding/active_slave")"
|
||||
IF_PATH="/sys/class/net/${IF}"
|
||||
fi
|
||||
|
||||
if [[ "$IF" == "" || ! -d "$IF_PATH" || ! -f "${IF_PATH}"/statistics/rx_bytes || ! -f "${IF_PATH}"/statistics/tx_bytes ]]; then
|
||||
sleep "${ERROR_DLY}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -d "${IF_PATH}/wireless" ]; then
|
||||
NIC=${label_icon:-$(xrescat i3xrocks.label.wifi )}
|
||||
else
|
||||
NIC=${label_icon:-$(xrescat i3xrocks.label.wired )}
|
||||
fi
|
||||
|
||||
# read dev file and compute net usage
|
||||
RX1=$(cat "${IF_PATH}"/statistics/rx_bytes)
|
||||
TX1=$(cat "${IF_PATH}"/statistics/tx_bytes)
|
||||
|
||||
sleep "${DLY}"
|
||||
|
||||
RX2=$(cat "${IF_PATH}"/statistics/rx_bytes)
|
||||
TX2=$(cat "${IF_PATH}"/statistics/tx_bytes)
|
||||
|
||||
RX_DIFF=$(echo "($RX2-$RX1)/$DLY" | bc)
|
||||
TX_DIFF=$(echo "($TX2-$TX1)/$DLY" | bc)
|
||||
RX=$(echo "${RX_DIFF}" | ${NUMFMT})
|
||||
TX=$(echo "${TX_DIFF}" | ${NUMFMT})
|
||||
AX=$(echo "($RX_DIFF+$TX_DIFF)" | bc | ${NUMFMT})
|
||||
|
||||
# Add a B for bytes at the end if the string is missing a letter
|
||||
if ! [[ "${RX}" =~ [BKMG]$ ]]; then
|
||||
RX="${RX#?}B"
|
||||
fi
|
||||
|
||||
if ! [[ "${TX}" =~ [BKMG]$ ]]; then
|
||||
TX="${TX#?}B"
|
||||
fi
|
||||
|
||||
if ! [[ "${AX}" =~ [BKMG]$ ]]; then
|
||||
AX="${AX#?}B"
|
||||
fi
|
||||
|
||||
# span for text
|
||||
fspan() {
|
||||
echo "<span font_desc=\"${VALUE_FONT}\" color=\"${VALUE_COLOR}\"> ${1}</span>"
|
||||
}
|
||||
|
||||
# span for label/icon
|
||||
lspan() {
|
||||
echo "<span font_desc=\"${VALUE_FONT}\" color=\"${LABEL_COLOR}\">${1}</span>"
|
||||
}
|
||||
|
||||
# get font specifics from xresource file
|
||||
VALUE_COLOR=${color:-$(xrescat i3xrocks.value.color "#D8DEE9")}
|
||||
LABEL_COLOR=${label_color:-$(xrescat i3xrocks.label.color "#7B8394")}
|
||||
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
|
||||
|
||||
# output net usage using pango markup
|
||||
if [ "$RT" = "up" ]; then
|
||||
echo "$(lspan "${NIC}")$(fspan "$TX")$(lspan "${UP}")"
|
||||
elif [ "$RT" = "down" ] || [ "$RT" = "dn" ]; then
|
||||
echo "$(lspan "${NIC}")$(fspan "$RX")$(lspan "${DN}")"
|
||||
elif [ "$RT" = "total" ]; then
|
||||
echo "$(lspan "${NIC}")$(fspan "$AX")"
|
||||
else
|
||||
echo "$(lspan "${NIC}")$(fspan "$RX") $(lspan "${DN}") /$(fspan "$TX") $(lspan "${UP}")"
|
||||
fi
|
||||
42
regolith3/i3xrocks/scripts/send-weather-notification
Normal file
42
regolith3/i3xrocks/scripts/send-weather-notification
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeu -o pipefail
|
||||
|
||||
VALUE_COLOR=${color:-$(xrescat i3xrocks.value.color "#D8DEE9")}
|
||||
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
|
||||
BUTTON="${button:-}"
|
||||
|
||||
# Information on the various formats: https://github.com/chubin/wttr.in
|
||||
VALUE_WEATHER_FORMAT=${weather_format:-$(xrescat i3xrocks.weather.format "1")}
|
||||
VALUE_WEATHER_FORMAT="?format=${VALUE_WEATHER_FORMAT}"
|
||||
# all format options: "https://wttr.in?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S+%s"
|
||||
VALUE_SUNSET_SUNRISE_FORMAT="?format=%S-%s%20%m+"
|
||||
|
||||
# Determine units to use for temperature
|
||||
# We don't supply a default here because wttr.in is "smart" enough to choose for us
|
||||
WEATHER_UNIT=${weather_unit:-$(xrescat i3xrocks.weather.units "")}
|
||||
if [ -n "${WEATHER_UNIT}" ]; then
|
||||
WEATHER_UNIT="&${WEATHER_UNIT}"
|
||||
fi
|
||||
|
||||
# Defaults to IP address location
|
||||
VALUE_WEATHER_LOCATION=${weather_location:-$(xrescat i3xrocks.weather.location "Genova")}
|
||||
VALUE_WEATHER_ERROR_MESSAGE=${error_message:-$(xrescat i3xrocks.weather.error_message $'\u26D4')}
|
||||
WEATHER=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_WEATHER_FORMAT}${WEATHER_UNIT}" || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
|
||||
|
||||
SUNRISE_SUNSET=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_SUNSET_SUNRISE_FORMAT}${WEATHER_UNIT}")
|
||||
SUNRISE_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 1-5)
|
||||
SUNSET_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 10-14)
|
||||
|
||||
if echo "${WEATHER}" | grep -q -P "Unknown\slocation"; then
|
||||
WEATHER=${VALUE_WEATHER_ERROR_MESSAGE}
|
||||
fi
|
||||
|
||||
echo "<span font_desc=\"${VALUE_FONT}\" color=\"${VALUE_COLOR}\">${WEATHER} (${SUNRISE_VALUE}-${SUNSET_VALUE})</span>"
|
||||
|
||||
#echo "x${BUTTON}"
|
||||
|
||||
if [ ! "x${BUTTON}" == "x" ]; then
|
||||
ACTION=$(xrescat i3xrocks.action.weather "xdg-open https://wttr.in/${VALUE_WEATHER_LOCATION}")
|
||||
/usr/bin/i3-msg -q exec "$ACTION"
|
||||
fi
|
||||
54
regolith3/i3xrocks/scripts/time
Normal file
54
regolith3/i3xrocks/scripts/time
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# This time blocklet will use Xresources date format if defined
|
||||
# or try to determine most appropriate format based on locale and GNOME settings.
|
||||
|
||||
IS_ISO_8601=$(xrescat i3xrocks.date.iso8601)
|
||||
DATE_FORMAT=$(xrescat i3xrocks.date.format2)
|
||||
BUTTON=${button:-}
|
||||
|
||||
BAR_SEPARATOR_CHAR=$(xrescat wm.bar.separatorchar)
|
||||
BAR_SEPARATOR_COLOR=$(xrescat wm.bar.separator.color)
|
||||
|
||||
if [ "$IS_ISO_8601" == "true" ]; then
|
||||
DATE_VALUE="$(date --iso-8601=seconds)"
|
||||
elif [ -z "$DATE_FORMAT" ]; then # No custom format defined, use system defaults
|
||||
COUNTRY=$(locale | grep LC_TIME | head -n1 | cut -d "=" -f 2 | cut -d "_" -f 2 | cut -d "." -f 1)
|
||||
if [ -z "$COUNTRY" ]; then
|
||||
DATE_SPEC="%m/%d"
|
||||
else
|
||||
case $COUNTRY in
|
||||
"US" | "CN" | "JP" | "KP" | "KR" | "CA" | "TW" | "HU" | "MN" | "LT" | "BT" )
|
||||
DATE_SPEC="%m/%d"
|
||||
;;
|
||||
*)
|
||||
DATE_SPEC="%d/%m"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
TIME_FORMAT=$(gsettings get org.gnome.desktop.interface clock-format)
|
||||
|
||||
if [ "$TIME_FORMAT" == "'12h'" ]; then
|
||||
TIME_SPEC="%I:%M"
|
||||
else
|
||||
TIME_SPEC="%H:%M"
|
||||
fi
|
||||
|
||||
DATE_VALUE=$(date "+ $DATE_SPEC $TIME_SPEC")
|
||||
else
|
||||
DATE_VALUE=$(date "+ $DATE_FORMAT")
|
||||
fi
|
||||
|
||||
LABEL_ICON=${icon:-$(xrescat i3xrocks.label.time )}
|
||||
LABEL_COLOR=${label_color:-$(xrescat i3xrocks.label.color "#7B8394")}
|
||||
VALUE_COLOR=${color:-$(xrescat i3xrocks.value.color "#D8DEE9")}
|
||||
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
|
||||
|
||||
echo "<span font_desc=\"${VALUE_FONT}\" color=\"${LABEL_COLOR}\">$LABEL_ICON</span> \
|
||||
<span font_desc=\"${VALUE_FONT}\" color=\"${VALUE_COLOR}\"> $DATE_VALUE</span> \
|
||||
<span font_desc=\"${VALUE_FONT}\" color=\"${BAR_SEPARATOR_COLOR}\">$BAR_SEPARATOR_CHAR </span>";
|
||||
|
||||
if [ "x${BUTTON}" == "x1" ]; then
|
||||
ACTION=$(xrescat i3xrocks.action.time "regolith-control-center datetime")
|
||||
/usr/bin/i3-msg -q exec "$ACTION"
|
||||
fi
|
||||
45
regolith3/i3xrocks/scripts/weather
Normal file
45
regolith3/i3xrocks/scripts/weather
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeu -o pipefail
|
||||
|
||||
VALUE_COLOR=${color:-$(xrescat i3xrocks.value.color "#D8DEE9")}
|
||||
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
|
||||
BUTTON="${button:-}"
|
||||
|
||||
# Information on the various formats: https://github.com/chubin/wttr.in
|
||||
VALUE_WEATHER_FORMAT=${weather_format:-$(xrescat i3xrocks.weather.format "1")}
|
||||
VALUE_WEATHER_FORMAT="?format=${VALUE_WEATHER_FORMAT}"
|
||||
# all format options: "https://wttr.in?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S+%s"
|
||||
VALUE_SUNSET_SUNRISE_FORMAT="?format=%S-%s%20%m+"
|
||||
|
||||
# Determine units to use for temperature
|
||||
# We don't supply a default here because wttr.in is "smart" enough to choose for us
|
||||
WEATHER_UNIT=${weather_unit:-$(xrescat i3xrocks.weather.units "")}
|
||||
if [ -n "${WEATHER_UNIT}" ]; then
|
||||
WEATHER_UNIT="&${WEATHER_UNIT}"
|
||||
fi
|
||||
|
||||
# Defaults to IP address location
|
||||
VALUE_WEATHER_LOCATION=${weather_location:-$(xrescat i3xrocks.weather.location "Pärnu")}
|
||||
VALUE_WEATHER_ERROR_MESSAGE=${error_message:-$(xrescat i3xrocks.weather.error_message $'\u26D4')}
|
||||
VALUE_FETCH_WEATHER_URL="https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_WEATHER_FORMAT}${WEATHER_UNIT}"
|
||||
#echo "hahaha = '$VALUE_FETCH_WEATHER_URL'"
|
||||
WEATHER=$(curl -sS "$VALUE_FETCH_WEATHER_URL" || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
|
||||
|
||||
SUNRISE_SUNSET=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_SUNSET_SUNRISE_FORMAT}${WEATHER_UNIT}")
|
||||
SUNRISE_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 1-5)
|
||||
SUNSET_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 10-14)
|
||||
|
||||
if echo "${WEATHER}" | grep -q -P "Unknown\slocation"; then
|
||||
WEATHER=${VALUE_WEATHER_ERROR_MESSAGE}
|
||||
fi
|
||||
|
||||
echo "<span font_desc=\"${VALUE_FONT}\" color=\"${VALUE_COLOR}\">${WEATHER} (${SUNRISE_VALUE}-${SUNSET_VALUE})</span>"
|
||||
|
||||
#echo "x${BUTTON}"
|
||||
|
||||
if [ ! "x${BUTTON}" == "x" ]; then
|
||||
FULL_WEATHER=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S+%s" || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
|
||||
ACTION=$(notify-send "$FULL_WEATHER")
|
||||
/usr/bin/i3-msg -q exec "$ACTION"
|
||||
fi
|
||||
Reference in New Issue
Block a user