Huge Update

This commit is contained in:
sankalp committed 2024-01-24 20:15:59 +05:45
1 parent b3f41b52b1
commit 0867aa7fca
26 files changed
+1182 -124

No files matched your search

+52 -4
View File
@@ -25,16 +25,26 @@ touchpad() {
# Toggle Wifi
wifi() {
wifi="$(nmcli r wifi | awk 'FNR = 2 {print $1}')"
if [ -n "$wifi" ]; then
rfkill block all &
wifi_status=$(nmcli radio wifi)
if [ "$wifi_status" == "enabled" ]; then
nmcli radio wifi off
notify-send -u low -i "$notif" 'Airplane mode: OFF'
else
rfkill unblock all &
nmcli radio wifi on
notify-send -u low -i "$notif" 'Airplane mode: ON'
fi
}
# Toggle Bluetooth
bluetooth() {
if [ "$bluetooth_status" == "no" ]; then
bluetoothctl power on
notify-send -u low -i "$notif" 'Bluetooth ON'
else
bluetoothctl power off
notify-send -u low -i "$notif" 'Bluetooth OFF'
fi
}
# Reload Waybar, Rofi, Swaync, and Rainbowborder.sh (SHIFT ALT R)
reload() {
@@ -109,3 +119,41 @@ disable_edp1() {
enable_edp1() {
hyprctl keyword monitor eDP-1,preferred,auto,1
}
weather() {
city=kohalpur
cachedir=~/.cache/rbn
cachefile=${0##*/}-$1
mkdir -p $cachedir
touch $cachedir/$cachefile
SAVEIFS=$IFS;IFS=$'\n'
cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
[ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ] && {
data=($(curl -s https://en.wttr.in/"$city"$1\?0qnT 2>&1))
for i in {1..2}; do echo ${data[$i]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile; done
}
IFS=$SAVEIFS
weather=($(cat $cachedir/$cachefile))
temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]]+)\.\./\1 to /g')
case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
clear|sunny) condition="" ;;
partly\ cloudy) condition="󰖕" ;;
cloudy) condition="" ;;
overcast) condition="" ;;
fog|freezing\ fog) condition="" ;;
patchy\ rain\ possible|patchy\ light\ drizzle|light\ drizzle|patchy\ light\ rain|light\ rain|light\ rain\ shower|mist|rain) condition="󰼳" ;;
moderate\ rain\ at\ times|moderate\ rain|heavy\ rain\ at\ times|heavy\ rain|moderate\ or\ heavy\ rain\ shower|torrential\ rain\ shower|rain\ shower) condition="" ;;
patchy\ snow\ possible|patchy\ sleet\ possible|patchy\ freezing\ drizzle\ possible|freezing\ drizzle|heavy\ freezing\ drizzle|light\ freezing\ rain|moderate\ or\ heavy\ freezing\ rain|light\ sleet|ice\ pellets|light\ sleet\ showers|moderate\ or\ heavy\ sleet\ showers) condition="󰼴" ;;
blowing\ snow|moderate\ or\ heavy\ sleet|patchy\ light\ snow|light\ snow|light\ snow\ showers) condition="󰙿" ;;
blizzard|patchy\ moderate\ snow|moderate\ snow|patchy\ heavy\ snow|heavy\ snow|moderate\ or\ heavy\ snow\ with\ thunder|moderate\ or\ heavy\ snow\ showers) condition="" ;;
thundery\ outbreaks\ possible|patchy\ light\ rain\ with\ thunder|moderate\ or\ heavy\ rain\ with\ thunder|patchy\ light\ snow\ with\ thunder) condition="" ;;
*) condition="" ;;
esac
echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
}