├── assets └── preview.png ├── Makefile ├── LICENSE ├── README.md ├── .gitignore └── src └── rainy.py /assets/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liveslol/rainy/HEAD/assets/preview.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | BINDIR = $(PREFIX)/bin 3 | 4 | install: 5 | install -d $(BINDIR) 6 | install -m 755 src/rainy.py $(BINDIR)/rainy 7 | chmod +x $(BINDIR)/rainy 8 | 9 | uninstall: 10 | rm -f $(BINDIR)/rainy 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 - present liveslol 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # rainy 3 | Neofetch-like, minimalistic, and customizable weather-fetching tool. 4 | 5 | 6 | 7 | ## Dependencies 8 | * ```python``` 9 | * ```requests``` 10 | * ```make``` 11 | 12 | You can install all of them from your distros repositories (usually they're named ```python```, ```python-requests``` and ```make```) 13 | /usr/local/bin/rainy 14 | ## Installation & Configuration 15 | To install rainy, clone or download the repo, ```cd``` into it and just run ```make install``` (you can run ```make uninstall``` to uninstall it) 16 | 17 | **Before usage, you need to configure it** 18 | 19 | * First create an [OpenWeatherMap](https://home.openweathermap.org/users/sign_up) account, go to [API keys](https://home.openweathermap.org/api_keys) and get your key. 20 | * Then edit ```/usr/local/bin/rainy``` and set the API key, city and time difference in the config section. 21 | * You can also set if you want to show city name or / and the current date if you want to. 22 | 23 | ## Usage 24 | When set up correctly, you can just go to your terminal and type ```rainy``` 25 | 26 | What if there's an update? You can just update your local git clone and sudo make again (you can also edit the config of the git clone you you don't have to set it every time you sudo make) 27 | 28 | If you like this tool, please consider starring as it helps the growth <3 29 | 30 | ### Thanks 31 | * [1Codealot](https://github.com/1Codealot) and [Chirikumbrah](https://github.com/Chirikumbrah) for helping out with the code a lot :) 32 | * [wego](https://github.com/schachmat/wego) for providing ASCII weather icons 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /src/rainy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Config 4 | 5 | ########################################################################################################################### 6 | 7 | api_key = "changeme" # Create an account on OpenWeather (it's free) and get your API token there 8 | city = "changeme" # Your city 9 | units = "metric" # you can choose metric or imperial (anything else is kelvin) 10 | timeplus = 0 # Time zone used by default is UTC/GMT so you can define how many hours should be added to the time 11 | timeminus = 0 # Time zone used by default is UTC/GMT so you can define how many hours should be subtracted from the time 12 | showcityname = False # Show the city name in information, True or False 13 | showdate = False # Shows the date. 14 | datetype = "%x" # Use strftime formats to switch how date is displayed, i.e. "%a, %Y-%d-%m" 15 | 16 | ########################################################################################################################### 17 | 18 | import requests 19 | import datetime 20 | import sys 21 | 22 | date = datetime.datetime.now().strftime(datetype) 23 | 24 | if units == "metric": 25 | windspeedunits = "m/s" 26 | elif units == "imperial": 27 | windspeedunits = "mph" 28 | else: 29 | windspeedunits = "m/s" 30 | 31 | weather_data = requests.get( 32 | f"https://api.openweathermap.org/data/2.5/weather?q={city}&units={units}&APPID={api_key}" 33 | ) 34 | 35 | if weather_data.json()["cod"] == 200: 36 | pass 37 | elif weather_data.json()["cod"] == "404": 38 | print("No city found.") 39 | sys.exit() 40 | elif weather_data.json()["cod"] == 401: 41 | print("Invalid API key.") 42 | sys.exit() 43 | else: 44 | print("Unknown error occured.") 45 | sys.exit() 46 | 47 | sourcesunrise = weather_data.json()["sys"]["sunrise"] 48 | sourcesunset = weather_data.json()["sys"]["sunset"] 49 | 50 | 51 | sunrise_datetime = datetime.datetime.fromtimestamp(sourcesunrise, tz=datetime.timezone.utc) 52 | sunset_datetime = datetime.datetime.fromtimestamp(sourcesunset, tz=datetime.timezone.utc) 53 | 54 | adjusted_sunrise = ( 55 | sunrise_datetime 56 | + datetime.timedelta(hours=timeplus) 57 | - datetime.timedelta(hours=timeminus) 58 | ) 59 | adjusted_sunset = ( 60 | sunset_datetime 61 | + datetime.timedelta(hours=timeplus) 62 | - datetime.timedelta(hours=timeminus) 63 | ) 64 | 65 | sunrisestring = adjusted_sunrise.strftime("%H:%M:%S") 66 | sunsetstring = adjusted_sunset.strftime("%H:%M:%S") 67 | 68 | weather = weather_data.json()["weather"][0]["main"] 69 | 70 | temp = str(round(weather_data.json()["main"]["temp"])) + "°" 71 | 72 | if units == "metric": 73 | temp += "C" 74 | elif units == "imperial": 75 | temp += "F" 76 | else: 77 | temp += "K" 78 | 79 | wind_speed = str(round(weather_data.json()["wind"]["speed"])) + " " + windspeedunits 80 | 81 | output = [] 82 | 83 | if weather == "Clear": 84 | output = ( 85 | [ 86 | r" " + "City: " + city, 87 | r" \ / " + "Weather: clear", 88 | r" .-. " + "Temperature: " + temp, 89 | r" ‒ ( ) ‒ " + "Wind speed: " + wind_speed, 90 | r" `-᾿ " + "Sunrise: " + sunrisestring, 91 | r" / \ " + "Sunset: " + sunsetstring, 92 | r" " + "Date: " + date if showdate else "", 93 | ] 94 | if showcityname 95 | else [ 96 | r" ", 97 | r" \ / " + "Weather: clear", 98 | r" .-. " + "Temperature: " + temp, 99 | r" ‒ ( ) ‒ " + "Wind speed: " + wind_speed, 100 | r" `-᾿ " + "Sunrise: " + sunrisestring, 101 | r" / \ " + "Sunset: " + sunsetstring, 102 | r" " + "Date: " + date if showdate else "", 103 | ] 104 | ) 105 | elif weather == "Clouds": 106 | output = ( 107 | [ 108 | r" " + "City: " + city, 109 | r" .--. " + "Weather: cloudy", 110 | r" .-( ). " + "Temperature: " + temp, 111 | r" (___.__)__) " + "Wind speed: " + wind_speed, 112 | r" " + "Sunrise: " + sunrisestring, 113 | r" " + "Sunset: " + sunsetstring, 114 | r" " + "Date: " + date if showdate else "", 115 | ] 116 | if showcityname 117 | else [ 118 | r" " + "Weather: cloudy", 119 | r" .--. " + "Temperature: " + temp, 120 | r" .-( ). " + "Wind speed: " + wind_speed, 121 | r" (___.__)__) " + "Sunrise: " + sunrisestring, 122 | r" " + "Sunset: " + sunsetstring, 123 | r" " + "Date: " + date if showdate else "", 124 | ] 125 | ) 126 | elif weather == "Rain": 127 | output = ( 128 | [ 129 | r" " + "City: " + city, 130 | r" .--. " + "Weather: rainy", 131 | r" .-( ). " + "Temperature: " + temp, 132 | r" (___.__)__) " + "Wind speed: " + wind_speed, 133 | r" ʻ‚ʻ‚ʻ‚ʻ‚ʻ " + "Sunrise: " + sunrisestring, 134 | r" " + "Sunset: " + sunsetstring, 135 | r" " + "Date: " + date if showdate else "", 136 | ] 137 | if showcityname 138 | else [ 139 | r" " + "Weather: rainy", 140 | r" .--. " + "Temperature: " + temp, 141 | r" .-( ). " + "Wind speed: " + wind_speed, 142 | r" (___.__)__) " + "Sunrise: " + sunrisestring, 143 | r" ʻ‚ʻ‚ʻ‚ʻ‚ʻ " + "Sunset: " + sunsetstring, 144 | r" " + "Date: " + date if showdate else "", 145 | ] 146 | ) 147 | elif weather == "Snow": 148 | output = ( 149 | [ 150 | r" " + "City: " + city, 151 | r" .--. " + "Weather: snowy", 152 | r" .-( ). " + "Temperature: " + temp, 153 | r" (___.__)__) " + "Wind speed: " + wind_speed, 154 | r" * * * * * " + "Sunrise: " + sunrisestring, 155 | r" " + "Sunset: " + sunsetstring, 156 | r" " + "Date: " + date if showdate else "", 157 | ] 158 | if showcityname 159 | else [ 160 | r" " + "Weather: snowy", 161 | r" .--. " + "Temperature: " + temp, 162 | r" .-( ). " + "Wind speed: " + wind_speed, 163 | r" (___.__)__) " + "Sunrise: " + sunrisestring, 164 | r" * * * * * " + "Sunset: " + sunsetstring, 165 | r" " + "Date: " + date if showdate else "", 166 | ] 167 | ) 168 | elif weather == "Thunderstorm": 169 | output = ( 170 | [ 171 | r" " + "City: " + city, 172 | r" .--. " + "Weather: stormy", 173 | r" .-( ). " + "Temperature: " + temp, 174 | r" (___.__)__) " + "Wind speed: " + wind_speed, 175 | r" /_ " + "Sunrise: " + sunrisestring, 176 | r" / " + "Sunset: " + sunsetstring, 177 | r" " + "Date: " + date if showdate else "", 178 | ] 179 | if showcityname 180 | else [ 181 | r" .--. " + "Weather: stormy", 182 | r" .-( ). " + "Temperature: " + temp, 183 | r" (___.__)__) " + "Wind speed: " + wind_speed, 184 | r" /_ " + "Sunrise: " + sunrisestring, 185 | r" / " + "Sunset: " + sunsetstring, 186 | r" " + "Date: " + date if showdate else "", 187 | ] 188 | ) 189 | else: 190 | output = ( 191 | [ 192 | r" " + "City: " + city, 193 | r" .--. " + "Weather: " + weather, 194 | r" .-( ). " + "Temperature: " + temp, 195 | r" (___.__)__) " + "Wind speed: " + wind_speed, 196 | r" " + "Sunrise: " + sunrisestring, 197 | r" " + "Sunset: " + sunsetstring, 198 | r" " + "Date: " + date if showdate else "", 199 | ] 200 | if showcityname 201 | else [ 202 | r" " + "Weather: " + weather, 203 | r" .--. " + "Temperature: " + temp, 204 | r" .-( ). " + "Wind speed: " + wind_speed, 205 | r" (___.__)__) " + "Sunrise: " + sunrisestring, 206 | r" " + "Sunset: " + sunsetstring, 207 | r" " + "Date: " + date if showdate else "", 208 | ] 209 | ) 210 | 211 | print(*output, sep="\n") 212 | --------------------------------------------------------------------------------