Move .scripts -> .local/bin

This commit is contained in:
Riyyi
2021-02-25 20:16:07 +01:00
parent 3ac7d9f601
commit ba10984084
40 changed files with 93 additions and 94 deletions
+20
View File
@@ -0,0 +1,20 @@
#+LANGUAGE: en
#+OPTIONS: toc:nil num:nil
* Polybar
Panel configuration.
** Dependencies
| Package | Script(s) |
|--------------+------------|
| acpi | battery.sh |
|--------------+------------|
| iw | wifi.sh |
|--------------+------------|
| libnotify-id | battery.sh |
| | iface.sh |
| | wifi.sh |
|--------------+------------|
| polybar | polybar.sh |
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
BAT_INFO=${BLOCK_INSTANCE:-"$(acpi -b | grep ': [^Unknown]')"}
CAPACITY=$(echo "$BAT_INFO" | awk '{ print int($4) }')
if [ "$(echo "$BAT_INFO" | awk '{ print $6 }')" = "remaining" ]; then
if [ "$CAPACITY" -lt "20" ]; then
notify-send -u critical -r 1 -t 30000 "Battery critically low!"
fi
elif [ "$CAPACITY" -ge "95" ]; then
notify-send -u low -r 1 "You should probably unplug."
fi
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
# Enable mathematics in POSIX shell
calc() { awk "BEGIN { printf(\"%.2f\", $*) }"; }
data() {
[ -z "$1" ] && return 1
url="$1"
curl --location --request GET --silent "$url"
}
output() {
[ -z "$1" ] && return 1
# Get symbol and color
difference="$1"
possitive=$(calc "$difference >= 0" | cut -c 1)
if [ "$possitive" -eq 1 ]; then
symbol=""
color="$COLOR2"
else
symbol=""
color="$COLOR1"
fi
# Result
echo "%{F$color}$symbol $difference%%{F$COLOR15}"
}
# Get dates
date_last_week_start="$(date --date 'last week' +%s000)"
date_last_week_end=$(calc "$date_last_week_start + (1000 * 60 * 60)") # +1h
date_last_week_end=${date_last_week_end%.00} # cut off ".00" at the end
# API URLs
url="https://api.coincap.io/v2/assets/bitcoin"
url_last_week="${url}/history?interval=h1&start=${date_last_week_start}&end=${date_last_week_end}"
# Current price
data="$(data "$url")"
price="$(echo "$data" | jq --compact-output --raw-output '.data.priceUsd')"
price=$(calc "$price")
# Get yesterdays difference
difference_yesterday="$(echo "$data" | jq --compact-output --raw-output '.data.changePercent24Hr')"
difference_yesterday="$(calc "$difference_yesterday")"
# Get last weeks difference
price_last_week="$(data "$url_last_week" | jq --compact-output --raw-output '.data[0].priceUsd')"
difference_last_week=$(calc "$price / $price_last_week * 100 - 100")
# Create output formatting
difference_yesterday_output="d $(output "$difference_yesterday")"
difference_last_week_output="w $(output "$difference_last_week")"
echo "\$$price $difference_yesterday_output $difference_last_week_output"
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
DATE="$(date +'%A, %B %d, %Y')"
notify-send -r 3 "Date" "\
$DATE"
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
WIRED="${1:-eth0}"
IP="$(ip a show "$WIRED" \
| awk '/inet / { print substr($2, 0, length($2) - 3) }')"
notify-send -r 3 "Wired" "\
Interface: $WIRED
IP: $IP"
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
# Kill existing panels
while [ "$(pgrep -cx polybar)" -gt 1 ]; do
pkill -x -9 polybar;
done
# Start a panel on each monitor
for m in $(polybar --list-monitors | cut -d ":" -f1); do
MONITOR=$m polybar --reload polybar &
done
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
WIRELESS="${1:-wlan0}"
SSID="$(iw dev "$WIRELESS" link | awk '/SSID/ { print $2 }')"
IP="$(ip a show "$WIRELESS" \
| awk '/inet / { print substr($2, 0, length($2) - 3) }')"
notify-send -r 3 "Wifi" "\
Interface: $WIRELESS
SSID: $SSID
IP: $IP"