mirror of
https://github.com/olexsmir/dotfiles.git
synced 2026-01-15 16:51:34 +02:00
⚡ Add scripts & configs
This commit is contained in:
parent
f8ffdbda2e
commit
734af357dd
33 changed files with 1432 additions and 957 deletions
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
battery=$(sudo tlp-stat -b | tac | grep -m 1 "Charge" | tr -d -c "[:digit:],.")
|
||||
|
||||
echo " $battery %"
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json,sys,urllib.request,time
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: btc usd,eur,btc nok")
|
||||
sys.exit()
|
||||
|
||||
currencies = sys.argv[1]
|
||||
basecurrency = sys.argv[2]
|
||||
|
||||
currencyurl = "http://freecurrencyrates.com/api/action.php?do=cvals&iso=" + currencies.replace(',','') + "&f=" + basecurrency + "&v=1&s=cbr"
|
||||
f = urllib.request.urlopen(currencyurl)
|
||||
obj = json.loads(f.read())
|
||||
res="";
|
||||
for c in currencies.split(','):
|
||||
res += c.upper() + ":{:,.2f}".format(1/obj[c.upper()]).replace(',',' ')
|
||||
|
||||
# some unicode currency code replacement (optional)
|
||||
res = res.replace("USD", " $")
|
||||
res = res.replace("EUR", " €")
|
||||
res = res.replace("BTC", " ")
|
||||
|
||||
print(res);
|
||||
21
config/polybar/scripts/microphone.sh
Executable file
21
config/polybar/scripts/microphone.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
MICSYMBOL=$1
|
||||
MICMUTEDSYMBOL=$2
|
||||
|
||||
case "$1" in
|
||||
--click)
|
||||
amixer -D pulse sset Capture toggle
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
STATUS=$(amixer -D pulse get Capture | grep -E "\[on\]|\[off\]" | cut -s -d ' ' -f 8 | uniq)
|
||||
|
||||
if [[ $STATUS = "[on]" ]]; then
|
||||
echo $MICSYMBOL
|
||||
elif [[ $STATUS = "[off]" ]]; then
|
||||
echo $MICMUTEDSYMBOL
|
||||
else
|
||||
echo "Not working, check script."
|
||||
fi
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#!/bin/sh
|
||||
API="https://api.openweathermap.org/data/2.5"
|
||||
KEY="34e5d198afe8fb0303e3c3c37774d2ca"
|
||||
CITY="Horodnytsya, UA"
|
||||
UNITS="metric"
|
||||
SYMBOL="°С"
|
||||
|
||||
get_icon() {
|
||||
case $1 in
|
||||
# Icons for weather-icons
|
||||
01d) icon="";;
|
||||
01n) icon="";;
|
||||
02d) icon="";;
|
||||
02n) icon="";;
|
||||
03*) icon="";;
|
||||
04*) icon="";;
|
||||
09d) icon="";;
|
||||
09n) icon="";;
|
||||
10d) icon="";;
|
||||
10n) icon="";;
|
||||
11d) icon="";;
|
||||
11n) icon="";;
|
||||
13d) icon="";;
|
||||
13n) icon="";;
|
||||
50d) icon="";;
|
||||
50n) icon="";;
|
||||
*) icon="";
|
||||
esac
|
||||
|
||||
echo $icon
|
||||
}
|
||||
|
||||
if [ -n "$CITY" ]; then
|
||||
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
|
||||
CITY_PARAM="id=$CITY"
|
||||
else
|
||||
CITY_PARAM="q=$CITY"
|
||||
fi
|
||||
|
||||
weather=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
|
||||
else
|
||||
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
if [ -n "$location" ]; then
|
||||
location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
|
||||
weather=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$weather" ]; then
|
||||
weather_temp=$(echo "$weather" | jq ".main.temp" | cut -d "." -f 1)
|
||||
weather_icon=$(echo "$weather" | jq -r ".weather[0].icon")
|
||||
|
||||
echo "$(get_icon "$weather_icon")" "$weather_temp$SYMBOL"
|
||||
fi
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
BAR_HEIGHT=22 # polybar height
|
||||
BORDER_SIZE=1 # border size from your wm settings
|
||||
YAD_WIDTH=222 # 222 is minimum possible value
|
||||
YAD_HEIGHT=193 # 193 is minimum possible value
|
||||
DATE="$(date +"%a %d %H:%M")"
|
||||
|
||||
case "$1" in
|
||||
--popup)
|
||||
if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
eval "$(xdotool getmouselocation --shell)"
|
||||
eval "$(xdotool getdisplaygeometry --shell)"
|
||||
|
||||
# X
|
||||
if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
|
||||
: $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
|
||||
elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
|
||||
: $((pos_x = BORDER_SIZE))
|
||||
else #Center
|
||||
: $((pos_x = X - YAD_WIDTH / 2))
|
||||
fi
|
||||
|
||||
# Y
|
||||
if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
|
||||
: $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
|
||||
else #Top
|
||||
: $((pos_y = BAR_HEIGHT + BORDER_SIZE))
|
||||
fi
|
||||
|
||||
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
|
||||
--width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \
|
||||
--title="yad-calendar" --borders=0 >/dev/null &
|
||||
;;
|
||||
*)
|
||||
echo "$DATE"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$(pgrep -x redshift)" ]; then
|
||||
temp=$(redshift -p 2> /dev/null | grep temp | cut -d ":" -f 2 | tr -dc "[:digit:]")
|
||||
|
||||
if [ -z "$temp" ]; then
|
||||
echo "%{F#65737E} #"
|
||||
elif [ "$temp" -ge 5000 ]; then
|
||||
echo "%{F#8FA1B3} #"
|
||||
elif [ "$temp" -ge 4000 ]; then
|
||||
echo "%{F#EBCB8B} #"
|
||||
else
|
||||
echo "%{F#D08770} #"
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import dbus
|
||||
import argparse
|
||||
# -*- encoding: utf-8 -*-
|
||||
import sys, dbus, argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
|
|
|
|||
20
config/polybar/scripts/updates-pacman-aur.sh
Executable file
20
config/polybar/scripts/updates-pacman-aur.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
|
||||
updates_arch=0
|
||||
fi
|
||||
|
||||
if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then
|
||||
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
|
||||
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
|
||||
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
|
||||
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
|
||||
updates_aur=0
|
||||
fi
|
||||
|
||||
updates=$(("$updates_arch" + "$updates_aur"))
|
||||
|
||||
if [ "$updates" -gt 0 ]; then
|
||||
echo " $updates"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
|
||||
updates_arch=0
|
||||
fi
|
||||
|
||||
if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then
|
||||
updates_aur=0
|
||||
fi
|
||||
|
||||
updates=$(("$updates_arch" + "$updates_aur"))
|
||||
|
||||
if [ "$updates" -gt 0 ]; then
|
||||
echo "# $updates"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
30
config/polybar/scripts/weather.py
Executable file
30
config/polybar/scripts/weather.py
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- encoding: utf-8 -*-
|
||||
import requests, os
|
||||
|
||||
API_KEY = os.getenv("OWM_POLYBAR")
|
||||
CITY = "Horodnytsya,UA"
|
||||
|
||||
try:
|
||||
JSON = requests.get(f"http://api.openweathermap.org/data/2.5/weather?q={CITY}&lang=EN&&units=metric&appid={API_KEY}").json()
|
||||
except Exception as e:
|
||||
print("No connection")
|
||||
|
||||
try:
|
||||
if JSON['weather'][0]['main'] == "Clear": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Thunderstorm": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Drizzle": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Rain": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Snow": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Mist": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Smoke": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Haze": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Dust": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Fog": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Sand": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Ash": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Squall": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Tornado": print("", int(JSON["main"]["temp"]),"°С")
|
||||
elif JSON['weather'][0]['main'] == "Clouds": print("", int(JSON["main"]["temp"]),"°С")
|
||||
except Exception as e:
|
||||
print(int(JSON["main"]["temp"]),"°С")
|
||||
Loading…
Add table
Add a link
Reference in a new issue