Move .scripts -> .local/bin
This commit is contained in:
@@ -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 |
|
||||
Executable
+13
@@ -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
|
||||
Executable
+57
@@ -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"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
DATE="$(date +'%A, %B %d, %Y')"
|
||||
|
||||
notify-send -r 3 "Date" "\
|
||||
$DATE"
|
||||
Executable
+10
@@ -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"
|
||||
Executable
+11
@@ -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
|
||||
Executable
+12
@@ -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"
|
||||
Reference in New Issue
Block a user