nvim config edits, rename 'old_configs' -> 'non-nix_configs'
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
discharging = str("discharging")
|
||||
|
||||
|
||||
def alert(id):
|
||||
stream = os.popen("cat /sys/class/power_supply/BAT0/capacity")
|
||||
output = stream.read()
|
||||
battery = int(output.split('\n')[0])
|
||||
|
||||
stream = os.popen("cat /sys/class/power_supply/BAT0/status")
|
||||
output = stream.read()
|
||||
status = str(output.split('\n')[0]).lower().strip()
|
||||
|
||||
if battery <= 10 and status == discharging:
|
||||
os.system(f'dunstify -u critical "Low Battery" "Connect Power Adapter" -i /usr/share/icons/Adwaita/symbolic/status/battery-caution-symbolic.svg -r {id} -t 60000')
|
||||
else:
|
||||
stream = os.popen(f'dunstctl history | grep {id}')
|
||||
output = stream.read()
|
||||
if output.strip() != '':
|
||||
os.system('dunstctl close')
|
||||
os.system(f'dunstctl history-rm {id}')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
alert(int(sys.argv[1]))
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
notif_id=$1
|
||||
|
||||
bat_alert_lvl=15
|
||||
bat_lvl=$(grep "" /sys/class/power_supply/BAT0/capacity )
|
||||
bat_status=$(grep Discharging /sys/class/power_supply/BAT0/status )
|
||||
|
||||
if (( $bat_lvl < $bat_alert_lvl )) && [ $bat_status == "Discharging" ]; then
|
||||
dunstify -u critical "Low Battery" "Connect Power Adapter" -i /usr/share/icons/Adwaita/symbolic/status/battery-caution-symbolic.svg -r $notif_id -t 60000
|
||||
else
|
||||
hist_check=$(dunstctl history | grep $notif_id)
|
||||
if [[ $hist_check == "" ]]; then
|
||||
dunstctl close
|
||||
fi
|
||||
dunstctl history-rm $notif_id
|
||||
fi
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
|
||||
stream = os.popen("brightnessctl -m")
|
||||
output = stream.read()
|
||||
|
||||
perc = output.split(',')[3]
|
||||
|
||||
print(perc)
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(dunstctl history | grep 255)" == "" ];
|
||||
then
|
||||
echo "absent"
|
||||
else
|
||||
echo "present"
|
||||
fi
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
WEATHER_CODES = {
|
||||
'113': '☀️ ',
|
||||
'116': '⛅ ',
|
||||
'119': '☁️ ',
|
||||
'122': '☁️ ',
|
||||
'143': '☁️ ',
|
||||
'176': '🌧️',
|
||||
'179': '🌧️',
|
||||
'182': '🌧️',
|
||||
'185': '🌧️',
|
||||
'200': '⛈️ ',
|
||||
'227': '🌨️',
|
||||
'230': '🌨️',
|
||||
'248': '☁️ ',
|
||||
'260': '☁️ ',
|
||||
'263': '🌧️',
|
||||
'266': '🌧️',
|
||||
'281': '🌧️',
|
||||
'284': '🌧️',
|
||||
'293': '🌧️',
|
||||
'296': '🌧️',
|
||||
'299': '🌧️',
|
||||
'302': '🌧️',
|
||||
'305': '🌧️',
|
||||
'308': '🌧️',
|
||||
'311': '🌧️',
|
||||
'314': '🌧️',
|
||||
'317': '🌧️',
|
||||
'320': '🌨️',
|
||||
'323': '🌨️',
|
||||
'326': '🌨️',
|
||||
'329': '❄️ ',
|
||||
'332': '❄️ ',
|
||||
'335': '❄️ ',
|
||||
'338': '❄️ ',
|
||||
'350': '🌧️',
|
||||
'353': '🌧️',
|
||||
'356': '🌧️',
|
||||
'359': '🌧️',
|
||||
'362': '🌧️',
|
||||
'365': '🌧️',
|
||||
'368': '🌧️',
|
||||
'371': '❄️',
|
||||
'374': '🌨️',
|
||||
'377': '🌨️',
|
||||
'386': '🌨️',
|
||||
'389': '🌨️',
|
||||
'392': '🌧️',
|
||||
'395': '❄️ '
|
||||
}
|
||||
|
||||
data = {}
|
||||
|
||||
|
||||
weather = requests.get("https://wttr.in/?format=j1").json()
|
||||
|
||||
|
||||
def format_time(time):
|
||||
return time.replace("00", "").zfill(2)
|
||||
|
||||
|
||||
def format_temp(temp):
|
||||
return (hour['FeelsLikeC']+"°").ljust(3)
|
||||
|
||||
|
||||
def format_chances(hour):
|
||||
chances = {
|
||||
"chanceoffog": "Fog",
|
||||
"chanceoffrost": "Frost",
|
||||
"chanceofovercast": "Overcast",
|
||||
"chanceofrain": "Rain",
|
||||
"chanceofsnow": "Snow",
|
||||
"chanceofsunshine": "Sunshine",
|
||||
"chanceofthunder": "Thunder",
|
||||
"chanceofwindy": "Wind"
|
||||
}
|
||||
|
||||
conditions = []
|
||||
for event in chances.keys():
|
||||
if int(hour[event]) > 0:
|
||||
conditions.append(chances[event]+" "+hour[event]+"%")
|
||||
return ", ".join(conditions)
|
||||
|
||||
tempint = int(weather['current_condition'][0]['FeelsLikeC'])
|
||||
extrachar = ''
|
||||
if tempint > 0 and tempint < 10:
|
||||
extrachar = '+'
|
||||
|
||||
|
||||
data['text'] = ' '+WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
|
||||
" "+extrachar+weather['current_condition'][0]['FeelsLikeC']+"°"
|
||||
|
||||
data['tooltip'] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°</b>\n"
|
||||
data['tooltip'] += f"Feels like: {weather['current_condition'][0]['FeelsLikeC']}°\n"
|
||||
data['tooltip'] += f"Wind: {weather['current_condition'][0]['windspeedKmph']}Km/h\n"
|
||||
data['tooltip'] += f"Humidity: {weather['current_condition'][0]['humidity']}%\n"
|
||||
for i, day in enumerate(weather['weather']):
|
||||
data['tooltip'] += f"\n<b>"
|
||||
if i == 0:
|
||||
data['tooltip'] += "Today, "
|
||||
if i == 1:
|
||||
data['tooltip'] += "Tomorrow, "
|
||||
data['tooltip'] += f"{day['date']}</b>\n"
|
||||
data['tooltip'] += f"⬆️ {day['maxtempC']}° ⬇️ {day['mintempC']}° "
|
||||
data['tooltip'] += f"🌅 {day['astronomy'][0]['sunrise']} 🌇 {day['astronomy'][0]['sunset']}\n"
|
||||
for hour in day['hourly']:
|
||||
if i == 0:
|
||||
if int(format_time(hour['time'])) < datetime.now().hour-2:
|
||||
continue
|
||||
data['tooltip'] += f"{format_time(hour['time'])} {WEATHER_CODES[hour['weatherCode']]} {format_temp(hour['FeelsLikeC'])} {hour['weatherDesc'][0]['value']}, {format_chances(hour)}\n"
|
||||
|
||||
|
||||
print(json.dumps(data))
|
||||
Reference in New Issue
Block a user