dotfiles/.config/sway/swaybar.sh

44 lines
952 B
Bash
Raw Normal View History

2020-12-19 18:44:57 +00:00
#!/bin/bash
# vim: ts=4
2020-12-19 18:44:57 +00:00
2021-02-02 14:47:47 +00:00
source $HOME/.secrets/finnhub
2020-12-19 18:44:57 +00:00
function getPowerValue() {
POWER=$(cat /sys/class/power_supply/BAT0/capacity)%
echo $POWER
}
2020-12-24 11:51:15 +00:00
function getPowerStatus() {
POWERSTATUS=$(cat /sys/class/power_supply/BAT0/status)
if [ "$POWERSTATUS" == "Charging" ]; then
echo "+"
elif [ "$POWERSTATUS" == "Discharging" ]; then
2020-12-24 11:51:15 +00:00
echo "-"
fi
}
2020-12-19 18:44:57 +00:00
function getDate() {
echo $(date +'%Y-%m-%d %H:%M')
}
2020-12-24 11:51:15 +00:00
function getVolume() {
echo $(amixer get Master | grep 'Left:' | awk -F"[][]" '{ print $2 }')
}
2020-12-19 18:44:57 +00:00
2021-02-02 14:47:47 +00:00
function getStock() {
curl -s "https://finnhub.io/api/v1/quote?symbol=$1&token=$SECRET_FINNHUB_TOKEN" | jq ".c"
}
function getNextEvent() {
khal list now -df "" | grep -v "^ " | head -n 1
}
2021-03-12 10:12:49 +00:00
function getCurrentSong() {
echo $(playerctl metadata artist) - $(playerctl metadata title)
}
2020-12-19 18:44:57 +00:00
while [ True ]; do
2021-03-12 10:12:49 +00:00
echo "$(getCurrentSong) | $(getNextEvent) | $(getVolume) | $(getPowerValue)$(getPowerStatus) | $(getDate)"
2020-12-19 18:44:57 +00:00
sleep 30
done