This commit is contained in:
sankalp committed 2023-04-24 15:41:27 +05:45
1 parent 0b17aa140b
commit dde4ef218a
136 files changed
+9796

No files matched your search

+133
View File
@@ -0,0 +1,133 @@
#!/usr/bin/env bash
encode_to_url_format() {
echo "$1" | sed 's/ /%20/g'
}
check_if_empty() {
[[ -z "$1" ]] && echo "0" || echo "$1"
}
KEY="1f6e449790b8cf73a3cab8d5715483f8"
CITY="Kohalpur"
CITYN=$(encode_to_url_format "$CITY")
WEATHER=$(curl -sf "api.openweathermap.org/data/2.5/weather?q=$CITYN&appid=$KEY&units=metric")
WEATHER_DESC=$(echo $WEATHER | jq -r ".weather[0].main")
WEATHER_TEMP=$(echo $WEATHER | jq ".main.temp" | cut -d "." -f 1)
WEATHER_ICON_CODE=$(echo "$WEATHER" | jq -r ".weather[].icon" | head -1)
WEATHER_FEELS_LIKE=$(echo $WEATHER | jq ".main.feels_like" | cut -d "." -f 1)
WEATHER_HUMIDITY=$(echo $WEATHER | jq ".main.humidity" | cut -d "." -f 1)
WEATHER_ICON=""
WEATHER_HEX=""
case $WEATHER_ICON_CODE in
"01d")
WEATHER_ICON="󰖙"
WEATHER_HEX="#ffd86b"
;;
"01n")
WEATHER_ICON="󰖔"
WEATHER_HEX="#fcdcf6"
;;
"02d")
WEATHER_ICON="󰖕"
WEATHER_HEX="#adadff"
;;
"02n")
WEATHER_ICON="󰼱"
WEATHER_HEX="#adadff"
;;
"03d")
WEATHER_ICON="󰖐"
WEATHER_HEX="#adadff"
;;
"03n")
WEATHER_ICON="󰖐"
WEATHER_HEX="#adadff"
;;
"04d")
WEATHER_ICON="󰖐"
WEATHER_HEX="#adadff"
;;
"04n")
WEATHER_ICON="󰖐"
WEATHER_HEX="#acb0d0"
;;
"09d")
WEATHER_ICON="󱐋"
WEATHER_HEX="#6b95ff"
;;
"09n")
WEATHER_ICON="󱐋"
WEATHER_HEX="#6b95ff"
;;
"10d")
WEATHER_ICON="󱐋"
WEATHER_HEX="#6b95ff"
;;
"10n")
WEATHER_ICON="󱐋"
WEATHER_HEX="#6b95ff"
;;
"11d")
WEATHER_ICON="󱐋"
WEATHER_HEX="#ffeb57"
;;
"11n")
WEATHER_ICON="󱐋"
WEATHER_HEX="#ffeb57"
;;
"13d")
WEATHER_ICON="󰜗"
WEATHER_HEX="#e3e6fc"
;;
"13n")
WEATHER_ICON="󰜗"
WEATHER_HEX="#e3e6fc"
;;
"40d")
WEATHER_ICON="󰖝"
WEATHER_HEX="#84afdb"
;;
"40n")
WEATHER_ICON="󰖝"
WEATHER_HEX="#84afdb"
;;
*)
WEATHER_ICON="󰖐"
WEATHER_HEX="#adadff"
;;
esac
case $1 in
"current_temp")
check_if_empty $WEATHER_TEMP
;;
"current_temp_fahrenheit")
WEATHER_TEMP=$((($WEATHER_TEMP * 9 / 5) + 32))
check_if_empty $WEATHER_TEMP
;;
"feels_like")
check_if_empty $WEATHER_FEELS_LIKE
;;
"humidity")
check_if_empty $WEATHER_HUMIDITY
;;
"weather_desc")
[[ -z $WEATHER_DESC ]] && echo "Not Available." || echo "$WEATHER_DESC"
;;
"icon")
echo $WEATHER_ICON
;;
"hex")
echo $WEATHER_HEX
;;
"full")
echo $WEATHER
;;
"city")
echo $CITY
;;
esac
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
weather=$(curl -s wttr.in/Kohalpur?format=3)
if [ $(echo "$weather" | grep -E "(Unknown|curl|HTML)" | wc -l) -gt 0 ]; then
echo "WEATHER UNAVAILABLE"
else
echo "$weather" | awk '{print $2" "$3}'
fi
+3
View File
@@ -0,0 +1,3 @@
#/usr/bin/env sh
mpc status | grep "%)" | awk '{ print $4 }' | awk -F% '{ print $1 }' | awk 'sub(/^.{1}/,"")'
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
title=$(playerctl metadata --format '{{ title }}')
count=$(echo -n "$title" | wc -c)
if [ -z "$title" ]; then
echo "Nothing Playing...";
else
if [ "$count" -le 18 ]; then
echo $title
else
echo $(playerctl metadata --format '{{ title }}' | cut -c-18)...
fi
fi
+220
View File
@@ -0,0 +1,220 @@
#!/bin/bash
# Controls spotify if it's running, (kill spotify process to switch)
# add different players here (also at the end)
if [[ -n $(pgrep spotify) ]]; then
Control="spotify"
else
Control="MPD"
fi
# Covers will be saved here (for both the players)
Cover=/tmp/cover.png
# mpd music directory
mpddir=~/Music
############# Spotify ##############
spotcover() {
albumart="$(playerctl --player=spotify metadata mpris:artUrl | sed -e 's/open.spotify.com/i.scdn.co/g')"
if [ $(playerctl --player=spotify metadata mpris:artUrl) ]; then
curl -s "$albumart" --output $Cover;
else cp ~/.config/eww/images/music.png $Cover;
fi
echo "$Cover"
}
spotstatusicon() {
if [[ $(playerctl --player=spotify status 2>&1) == "Playing" ]];then
echo ""
elif [[ $(playerctl --player=spotify status 2>&1) == "Paused" ]];then
echo "喇"
else
echo "ﭥ"
fi
}
############ MPD #################
###
mpctitle() {
song=`mpc -f %title% current`
if [[ -n "$song" ]]; then
echo "$song"
else
echo "Play Someting"
fi
}
mpcartist() {
artist=`mpc -f %artist% current`
if [[ -n "$artist" ]]; then
echo "$artist"
else
echo "Artist"
fi
}
mpcalbum() {
album=`mpc -f %album% current`
if [[ -n "$album" ]]; then
echo "$album"
else
echo "Album"
fi
}
mpccover() {
ffmpeg -i "$mpddir"/"$(mpc current -f %file%)" "${Cover}" -y &> /dev/null
STATUS=$?
if [ "$STATUS" -eq 0 ];then
echo "$Cover"
else
cp ~/.config/eww/images/music.png $Cover;
echo "$Cover"
fi
}
mpctime() {
time=`mpc status %currenttime%`
if [[ -n "$time" ]]; then
echo "$time"
else
echo "0:00"
fi
}
mpclength() {
length=`mpc status %totaltime%`
if [[ -n "$length" ]]; then
echo "$length"
else
echo "0:00"
fi
}
mpcicon() {
if [[ $(mpc status) == *"[playing]"* ]]; then
echo ""
else
echo "喇"
fi
}
mpcstatus() {
if [[ $(mpc status) == *"[playing]"* ]]; then
echo "Playing"
elif [[ $(mpc status) == *"[paused]"* ]]; then
echo "Paused"
else
echo "Stopped"
fi
}
mpcperc() {
perc=`mpc status %percenttime%`
if [[ -n "$perc" ]]; then
echo "$perc"
else
echo "0"
fi
}
mpcsongpos() {
pos=`mpc status %songpos%`
length=`mpc status %length%`
if [[ -n "$pos" ]]; then
echo "$pos/$length"
else
echo "0/0"
fi
}
case $Control in
spotify)
if [[ $1 == "next" ]];then
playerctl --player=spotify next
elif [[ $1 == "previous" ]];then
playerctl --player=spotify previous
elif [[ $1 == "toggle" ]];then
playerctl --player=spotify play-pause
elif [[ $1 == "title" ]];then
playerctl --player=spotify metadata --format {{title}}
elif [[ $1 == "artist" ]];then
playerctl --player=spotify metadata --format {{artist}}
elif [[ $1 == "album" ]];then
playerctl --player=spotify metadata --format {{album}}
elif [[ $1 == "status" ]];then
playerctl --player=spotify status
elif [[ $1 == "statusicon" ]];then
spotstatusicon
elif [[ $1 == "player" ]];then
echo " Spotify"
elif [[ $1 == "coverloc" ]];then
spotcover
elif [[ $1 == "showcover" ]];then
spotcover | xargs feh
elif [[ $1 == "time" ]];then
echo "0:00"
elif [[ $1 == "length" ]];then
echo "0:00"
elif [[ $1 == "percent" ]];then
echo "0"
elif [[ $1 == "playlist" ]];then
playerctl metadata xesam:trackNumber
fi
;;
MPD)
if [[ $1 == "next" ]];then
mpc -q next
elif [[ $1 == "previous" ]];then
mpc -q prev
elif [[ $1 == "toggle" ]];then
mpc -q toggle
elif [[ $1 == "title" ]];then
mpctitle
elif [[ $1 == "artist" ]];then
mpcartist
elif [[ $1 == "album" ]];then
mpcalbum
elif [[ $1 == "status" ]];then
mpcstatus
elif [[ $1 == "statusicon" ]];then
mpcicon
elif [[ $1 == "player" ]];then
echo " MPD"
elif [[ $1 == "coverloc" ]];then
mpccover
elif [[ $1 == "showcover" ]];then
mpccover | xargs feh
elif [[ $1 == "time" ]];then
mpctime
elif [[ $1 == "length" ]];then
mpclength
elif [[ $1 == "percent" ]];then
mpcperc
elif [[ $1 == "playlist" ]];then
mpcsongpos
fi
esac 2>/dev/null