summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-08-31 20:06:01 +0300
committerThanos Apollo <[email protected]>2023-08-31 20:06:01 +0300
commitf660054178d8f49e1703c18705a8e3772d905d17 (patch)
treee21167905cc5cbb5e6d6c7b552821ec38e604ed3
parent8e0d9d4c3b54dfe52fb6672ca41e2b19b29bcb98 (diff)
Add scripts normally, not as submodules
-rw-r--r--.gitmodules5
m---------.scripts0
-rwxr-xr-xscripts/keyboard-light-x220.sh9
-rwxr-xr-xscripts/waybar-wttr.py119
4 files changed, 129 insertions, 4 deletions
diff --git a/.gitmodules b/.gitmodules
index 9d249aa..bf86588 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
[submodule ".stumpwm.d/modules"]
path = .stumpwm.d/modules
- url = https://github.com/stumpwm/stumpwm-contrib
-[submodule ".scripts"]
- path = .scripts
- url = [email protected]:~thanosapollo/scripts
+ url = https://github.com/stumpwm/stumpwm-contrib \ No newline at end of file
diff --git a/.scripts b/.scripts
deleted file mode 160000
-Subproject 3c2112a18433dfa3d346291970d60435433279d
diff --git a/scripts/keyboard-light-x220.sh b/scripts/keyboard-light-x220.sh
new file mode 100755
index 0000000..6aa509b
--- /dev/null
+++ b/scripts/keyboard-light-x220.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+STATUS=$(brightnessctl --device "tpacpi::thinklight" | grep "Current brightness")
+
+if [[ "$STATUS" == *"(0%)" ]]; then
+ brightnessctl --device "tpacpi::thinklight" set 1
+else
+ brightnessctl --device "tpacpi::thinklight" set 0
+fi
diff --git a/scripts/waybar-wttr.py b/scripts/waybar-wttr.py
new file mode 100755
index 0000000..08b49a6
--- /dev/null
+++ b/scripts/waybar-wttr.py
@@ -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['maxtempF']}° ⬇️ {day['mintempF']}° "
+ 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))