diff --git a/LICENSE b/LICENSE index 31593d8..81d866e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 koffeejava +Copyright (c) 2026 koffeejava Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index bde0a9f..ba17f6b 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,48 @@ This version of wfetch is semi-backwards compatible (config.toml will work! But ## Installation -Run the installer executible in root and follow instructions. +### Linux + +Fist download the latest release fron the releases page and extract it. Inside of the folder, you will see an executible named "wf-tool". +This will be the program that you will use to install and setup wfetch. + +Open your favorite terminal in the folder and run `sudo ./wf-tool -i` This will install wfetch. +> **WARNING**: You must run wf-tool with sudo to install wfetch. + +Wfetch should quickly install. After wfetch is installed, run `./wf-tool -s` and follow the setup instructions +> **WARNING**: Do not run this command under sudo. It will not let you run the setup if you do so. + +### Windows + +At this time Windows dows not have a build. + +### MacOS + +At this time MacOS does not have a build. + +## Compiling + +### Requirements + +- Crystal compiler +- Wfetch Source Code +- wfetch-1.0.0-data.tar.gz + +Download the latest release's source code and open your terminal inside the directory and run `shards build --release` and the build will be outputted in bin/ + +To actually install and setup your wfetch build, you will need to have a data directory with wftech and the disp configs. + +Extract the data directory file and copy it to where your wfetch and wf-tool executable are. Once your data directory is copied/moved over, move wfetch inside of the data directory and then follow the installing instructions. ## FAQ ### How do I get an Weather API key? First, go to the [Weather API](https://www.weatherapi.com/) website and then sign up. When finished creating an account, login then copy your api key. -Make sure to paste that api key to setup. ### Why don't you provide an api key? -I'm lazy. (plus api call limit stuff) - +Giving out an api key is one of the top ten things to never do in your life. ## Contributing diff --git a/disp-configs/customary.toml b/disp-configs/customary.toml deleted file mode 100644 index 86f911a..0000000 --- a/disp-configs/customary.toml +++ /dev/null @@ -1,9 +0,0 @@ -# This is for customary units - -1 = "{icon}" -2 = "Live Temperature: {temp_f}°" -3 = "Feels like: {feels_temp_f}°" -4 = "Wind Speed: {wind_mph} MPH" -5 = "Humidity: {humidity}%" -6 = "Pressure: {pressure_in}" -7 = "Description: {orange}{bold}{description}{reset}" diff --git a/shard.yml b/shard.yml index c4e0d40..f228d53 100644 --- a/shard.yml +++ b/shard.yml @@ -7,6 +7,9 @@ authors: targets: wfetch: main: src/wfetch.cr + + wf-tool: + main: src/wf-tool.cr crystal: '>= 1.19.1' diff --git a/src/icon-list.cr b/src/icon-list.cr index ee2cf06..83c1279 100644 --- a/src/icon-list.cr +++ b/src/icon-list.cr @@ -1,6 +1,6 @@ def icon(id) - gray = "\e[38;5;241m" + gray = "\e[38;5;8m" blue = "\e[38;5;33m" yellow = "\e[38;5;220m" reset = "\e[0m" @@ -8,15 +8,15 @@ def icon(id) if Time.local.minute < 10 time = (Time.local.hour.to_s + 0.to_s + Time.local.minute.to_s).to_i - if time > 1200 - orange = "\e[38;5;235m" + if time > 1830 + orange = "\e[38;5;8m" else orange = "\e[38;5;214m" end elsif Time.local.minute >= 10 time = (Time.local.hour.to_s + Time.local.minute.to_s).to_i - if time > 1200 - orange = "\e[38;5;235m" + if time > 1830 + orange = "\e[38;5;8m" else orange = "\e[38;5;214m" end @@ -30,8 +30,7 @@ def icon(id) ⠀⠀⠀⠀⠀⠀⠀⠀⡪⡢⡱⡸⡐⡕⡱⡸⡘⡔⢕⢱⢸⢨⠂⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⢊⢆⢣⢪⠸⡨⡢⢣⠪⡊⡎⡪⢢⠣⠁⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠣⡱⡸⡘⡌⢎⠆⡇⡣⡪⡊⡆⠃⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠌⡪⡸⡨⡪⢪⠸⡐⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⠀⠀#{reset}" +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠌⡪⡸⡨⡪⢪⠸⡐⠑⠀⠀⠀#{reset}" elsif id == 1003 print "#{bold}#{orange} ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{bold}#{orange}⠀⠀⢠⢠⢢⢢⢢⢢⡀ #{reset}⠀⠀⠀⠀⠀⠀⠀ @@ -40,8 +39,7 @@ def icon(id) ⠀⠀⠀⠀⠀⠀⠠⢀⢂⢂⠂⠅⠅⡂⡂⡂⠅⠅⠅⡂#{bold}#{orange}⢣⢣⢣⢣⠣⠀⠀⠀⠀⠀#{reset} ⠀⠀⠀⠀⠀⠠⢁⢂⢂⠂⠌⠌⡐⡐⡐⠠⠡⠡⢁⠂⠌⠌#{bold}#{orange}⠪⡪⠂⠀⠀⠀⠀⠀#{reset} ⠀⠀⠀⠀⠀⠨⢐⢐⢐⠨⠨⢐⢐⢐⠠⠡⠡⢁⠂⠌⠌⠌⡐⡀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠂⠂⠂⠌⠌⠐⠐⠐⠨⠨⠨⠐⠨⠨⠨⠐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - " +⠀⠀⠀⠀⠀⠀⠂⠂⠂⠌⠌⠐⠐⠐⠨⠨⠨⠐⠨⠨⠨⠐⠐⠀⠀" elsif id == 1006 print " ⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⡐⠨⢐⢐⢐⠨⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ @@ -52,60 +50,52 @@ def icon(id) ⠀⠀⠀⠀⠀⠀⠀⠈⠐⠈⠐⠐⠐⠀⠁⠁⠂⠂⠂⠁⠁⠂⠈⠀⠀⠀⠀⠀⠀⠀ " elsif id == 1009 || id == 804 print " -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{gray} ⠀⢠⣰⢴⢦⣄⠀⠀⠀#{reset}⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡐⡐⡐#{gray}⡈⠳⡯⡯⡷⣝⡧⣠⢄⡀⠀⠀⠀⠀⠀#{reset}⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠠⠡#{gray}⢙⠽⠽⡳⣝⣗⡯⣯⢀⠀⠀⠀⠀⠀⠀#{reset}⠀⠀ -⠀⠀⠀⠀⠀⠀⠄⠄⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠#{gray}⢹⢮⡻⡮⣯⣻⠄⠀⠀⠀⠀#{reset}⠀⠀ -⠀⠀⠀⠀⠠⠨⠨⢐⢐⢐⢐⢐⠠⠡⢁⠂⠌⡐⠨⠨⠩#{gray}⠙⣽⣺⠺⠁⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{bold}#{gray} ⠀⢠⣰⢴⢦⣄⠀⠀⠀#{reset}⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡐⡐⡐#{bold}#{gray}⡈⠳⡯⡯⡷⣝⡧⣠⢄⡀⠀⠀⠀⠀⠀#{reset}⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠠⠡#{bold}#{gray}⢙⠽⠽⡳⣝⣗⡯⣯⢀⠀⠀⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠀⠀⠄⠄⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠#{bold}#{gray}⢹⢮⡻⡮⣯⣻⠄⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠠⠨⠨⢐⢐⢐⢐⢐⠠⠡⢁⠂⠌⡐⠨⠨⠩#{bold}#{gray}⠙⣽⣺⠺⠁⠀⠀⠀⠀#{reset}⠀⠀ ⠀⠀⠀⠀⠨⠨⠨⢐⢐⢐⢐⢐⠨⠨⢐⠨⢐⠠⠡⠡⠡⢁⠂⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠈⠌⠐⠐⠐⠐⠐⠨⠨⠐⠨⠐⠨⠨⠨⠨⠐⠀⠀⠀⠀⠀⠀⠀⠀ - - " +⠀⠀⠀⠀⠀⠈⠌⠐⠐⠐⠐⠐⠨⠨⠐⠨⠐⠨⠨⠨⠨⠐⠀⠀⠀⠀⠀⠀⠀⠀ " elsif id == 1072 || id == 1150 || id == 1153 || id == 1168 || id == 1180 || id == 1183 || id == 1186 || id == 1189 || id == 1198 || id == 1240 print " -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠠⢐⠀#{gray}⢮⢯⣗⣟⡦⣠⡀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠡⢁⠂⠌⠄#{gray}⠹⠞⢮⡻⣮⣻⣂⡀⠀⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠀⠄⡂⠅⠅⡂⠌⠌⠌⠌⠌⡐#{gray}⡸⣗⣗⣗⣟⠆⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠨⢐⠠⠡⢁⠂⠅⠅⠅⠅⠅⡂⡂⡂⡑⠓#{gray}⠉⠀⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠈⠐⠨⠨⠐#{blue}⣬#{reset}⠨⠨⠨⠨⢐⢐⢐⢐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ -#{blue}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠁⢠⡄⠀⢜⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠠⢐⠀#{bold}#{gray}⢮⢯⣗⣟⡦⣠⡀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠡⢁⠂⠌⠄#{bold}#{gray}⠹⠞⢮⡻⣮⣻⣂⡀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠄⡂⠅⠅⡂⠌⠌⠌⠌⠌⡐#{bold}#{gray}⡸⣗⣗⣗⣟⠆⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠨⢐⠠⠡⢁⠂⠅⠅⠅⠅⠅⡂⡂⡂⡑⠓#{bold}#{gray}⠉⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠈⠐⠨⠨⠐#{bold}#{blue}⣬#{reset}⠨⠨⠨⠨⢐⢐⢐⢐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ +#{bold}#{blue}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠁⢠⡄⠀⢜⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋⠠⣈⠂⡠⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ #{reset} - - " +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ #{reset} " elsif id == 1087 print " -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{gray}⡀⣤⢤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢐⢐⢐⠐#{gray}⢽⣺⢽⢮⡻⣆⣄⣄⠀⠀⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠨⠠#{gray}⢹⠽⠽⣽⣺⡺⡮⣇⡀⠀⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠀⠠⠠⢐⢐⢐⢐⢐⠨⠨⢐⠨⢐⠈#{gray}⡾⡽⡽⡮⡯⣧⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠌⠌⠌⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠⠡⢉#{gray}⢫⢯⠻⠊⠀⠀⠀⠀⠀#{reset} -⠀⠀⠀⠀⠀⠡⠡⢁⢂⢂#{yellow}⢢⡒⡎#{reset}⠌⠌⡐⠨⢐⠨⠨⢐⢐⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠁⠂⠂#{yellow}⡂⡇⡇⡖#{reset}⠡⠁⠂⠅⠂⠌⠌⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀#{yellow}⠀⡜⠌⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}⠀ - - " +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{bold}#{gray}⡀⣤⢤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢐⢐⢐⠐#{bold}#{gray}⢽⣺⢽⢮⡻⣆⣄⣄⠀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠨⠠#{bold}#{gray}⢹⠽⠽⣽⣺⡺⡮⣇⡀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠠⠠⢐⢐⢐⢐⢐⠨⠨⢐⠨⢐⠈#{bold}#{gray}⡾⡽⡽⡮⡯⣧⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠌⠌⠌⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠⠡⢉#{bold}#{gray}⢫⢯⠻⠊⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠡⠡⢁⢂⢂#{bold}#{yellow}⢢⡒⡎#{reset}⠌⠌⡐⠨⢐⠨⠨⢐⢐⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠁⠂⠂#{bold}#{yellow}⡂⡇⡇⡖#{reset}⠡⠁⠂⠅⠂⠌⠌⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀#{bold}#{yellow}⠀⡜⠌⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}" elsif id == 1066 || id == 1069 || id == 1114 || id == 1117 || id == 1204 || id == 1207 || id == 1210 || id == 1213 || id == 1216 || id == 1219 || id == 1222 || id == 1225 || id == 1237 - puts " + puts "#{bold} ⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⡀⢠⡄⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⢦⠌⠫⡮⡧⠏⢡⢦⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⡻⣺⢧⣀⡸⣇⢠⣸⣳⢝⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣘⣉⢁⠉⣞⡍⡘⣽⠀⢁⢉⡃⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⣕⢯⡏⠃⢻⡊⠉⢯⢯⢏⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⢞⢆⣜⢮⡻⣤⠘⠧⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠘⠇⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - " +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠘⠇⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}" elsif id == 1030 || id == 1135 || id == 1147 - puts " + puts "#{bold}#{gray} ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠙⠙⠙⠙⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠈⠋⠋⠋⡋⡋⡋⡋⡋⡋⡃⡀⡀⡀⡀⡀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⡀⡀⡀⡀⡉⡉⡉⡉⡉⡉⡉⡉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠉⠉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⣌⣌⣌⣌⣌⣌⣌⣌⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀ - " +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⣌⣌⣌⣌⣌⣌⣌⣌⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}" end end \ No newline at end of file diff --git a/src/installer.cr b/src/installer.cr deleted file mode 100644 index 0583669..0000000 --- a/src/installer.cr +++ /dev/null @@ -1,51 +0,0 @@ -orange = "\e[38;5;214m" -red = "\e[0;31m" -bold = "\033[1m" -reset = "\e[0m" - -lib C - fun getuid : UInt32 -end - -if C.getuid != 0 - puts "#{red}#{bold}You must be in root to install wfetch!#{reset}" - exit(0) -end - -sudo_user = ENV["SUDO_USER"]? -home = "/home/#{sudo_user}" - -puts "#{orange}#{bold}wfetch installer 0.1.0#{reset}" - -File.copy("data/wfetch", "/usr/bin/wfetch") - -puts "#{orange}#{bold}Finished installing! Let's setup.#{reset}" - -puts "Please enter your WeatherApi key (Learn to get one at README.md):" - -api = gets - -puts "Please enter the (closest) city you live in: " - -city = gets - -puts "#{orange}#{bold}Config setup finished. Starting disp setup.#{reset}" - -File.write("/home/#{sudo_user}/.local/share/Wfetch/config.toml", "api = \"#{api}\" -city = \"#{city}\"") - -puts "#{orange}#{bold}Would you like customary (1), metric (2), or both (3)?#{reset}" - -choice = gets - -if choice == "1" - File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml") -elsif choice == "2" - File.copy("data/2.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml") -elsif choice == "3" - File.copy("data/3.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml") -else - File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml") -end - -puts "#{orange}#{bold}Install finnished. Enjoy!#{reset}" \ No newline at end of file diff --git a/src/wf-tool.cr b/src/wf-tool.cr new file mode 100644 index 0000000..1a68e66 --- /dev/null +++ b/src/wf-tool.cr @@ -0,0 +1,94 @@ +require "option_parser" + +orange = "\e[38;5;214m" +red = "\e[0;31m" +bold = "\033[1m" +reset = "\e[0m" + +sudo_user = ENV["SUDO_USER"]? +home = "/home/#{sudo_user}" + +OptionParser.parse do |parser| + parser.banner = "Usage: wf-tool [arguments]" + parser.on("-i", "--install-only", "Only instals wfetch; Does not run setup") { + if LibC.getuid != 0 + puts "#{red}#{bold}You must be in root to install wfetch!#{reset}" + exit(0) + end + + puts "#{orange}#{bold}wfetch installer#{reset}" + + File.copy("data/wfetch", "/usr/bin/wfetch") + + puts "#{orange}#{bold}Finished installing!#{reset}" + exit + } + parser.on("-u", "--uninstall", "Uninstalls wfetch"){ + if LibC.getuid != 0 + puts "#{red}#{bold}You must be in root to uninstall wfetch!#{reset}" + exit(0) + end + + File.delete("/usr/bin/wfetch") + File.delete("#{home}/.local/share/Wfetch/disp.toml") + File.delete("#{home}/.local/share/Wfetch/config.toml") + Dir.delete("#{home}/.local/share/Wfetch") + puts "#{bold}#{orange}Finished#{reset}" + exit + } + parser.on("-s", "--setup", "Runs setup") { + if LibC.getuid == 0 + puts "#{red}#{bold}Don't run the setup in root!#{reset}" + exit(0) + end + + Dir.mkdir(Path["~/.local/share/Wfetch"].expand(home: true)) + + + puts "Please enter your WeatherApi key (Learn to get one at README.md):" + + api = gets + + puts "Please enter the (closest) city you live in: " + + city = gets + + puts "#{orange}#{bold}Config setup finished. Starting disp setup.#{reset}" + + File.write(Path["~/.local/share/Wfetch/config.toml"].expand(home: true), " + api = \"#{api}\" + city = \"#{city}\" + ") + + puts "#{orange}#{bold}Would you like customary (1), metric (2), or both (3)?#{reset}" + + choice = gets + + if choice == "1" + File.copy("data/1.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)) + elsif choice == "2" + File.copy("data/2.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)) + elsif choice == "3" + File.copy("data/3.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)) + else + File.copy("data/1.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)) + end + + puts "#{orange}#{bold}Setup finnished. Enjoy!#{reset}" + exit + } + parser.on("-h", "--help", "Show this help") do + + puts parser + exit(1) + end + parser.invalid_option do |flag| + STDERR.puts "ERROR: #{flag} is not a valid option." + STDERR.puts parser + exit(1) + end + end + + if ARGV.empty? + puts "Run wf-tool -h" + end \ No newline at end of file diff --git a/src/wfetch.cr b/src/wfetch.cr index 5b97f73..34cacfd 100644 --- a/src/wfetch.cr +++ b/src/wfetch.cr @@ -5,15 +5,14 @@ require "./icon-list" require "option_parser" module Wfetch - VERSION = "0.1.0" + VERSION = "1.0.0" orange = "\e[38;5;214m" red = "\e[0;31m" - bold = "\033[1m" + bold = "\e[1m" reset = "\e[0m" - puts "#{bold}#{orange}Wfetch KoffeeJava 2026#{reset}" - debug = false + test_config = false OptionParser.parse do |parser| parser.banner = "Usage: wfetch [arguments]" @@ -29,9 +28,15 @@ module Wfetch print "End" exit(1) } - parser.on("-v", "--verbose", "Gives additional details.") {debug = true} + parser.on("-d", "--debug", "Turns on debug mode.") {debug = true} + parser.on("-t", "--test-disp-config", "Test a disp config without editing yours.") { + test_config = true + } + parser.on("-v", "--version", "Shows the current version of wfetch") { + puts "#{bold}#{orange}Wfetch 1.0.0 KoffeeJava 2026#{reset}" + exit + } parser.on("-h", "--help", "Show this help") do - puts parser exit(1) end @@ -42,7 +47,7 @@ module Wfetch end end - + print "#{bold}#{orange}Wfetch KoffeeJava 2026#{reset}" config = TOML.parse(File.read(Path["~/.local/share/Wfetch/config.toml"].expand(home: true))) city = config["city"] @@ -58,32 +63,118 @@ module Wfetch data = JSON.parse(response.body.lines.join) if debug == true - puts data + puts "\n#{data}" end - feelslike_f = data["current"]["feelslike_f"] - feelslike_c = data["current"]["feelslike_c"] - temp_f = data["current"]["temp_f"] - temp_c = data["current"]["temp_c"] - desc = data["current"]["condition"]["text"] - press_in = data["current"]["pressure_in"] - press_mb = data["current"]["pressure_mb"] - wind_mph = data["current"]["wind_mph"] - wind_kph = data["current"]["wind_kph"] - humidity = data["current"]["humidity"] - vis_mi = data["current"]["vis_miles"] - vis_km = data["current"]["vis_km"] - heatindex_f = data["current"]["heatindex_f"] - heatindex_c = data["current"]["heatindex_c"] - windchill_f = data["current"]["windchill_f"] - windchill_c = data["current"]["windchill_c"] + feelslike_f = data["current"]["feelslike_f"].to_s.to_f + feelslike_c = data["current"]["feelslike_c"].to_s.to_f + temp_f = data["current"]["temp_f"].to_s.to_f + temp_c = data["current"]["temp_c"].to_s.to_f + desc = data["current"]["condition"]["text"].to_s + press_in = data["current"]["pressure_in"].to_s.to_f + press_mb = data["current"]["pressure_mb"].to_s.to_f + wind_mph = data["current"]["wind_mph"].to_s.to_f + wind_kph = data["current"]["wind_kph"].to_s.to_f + humidity = data["current"]["humidity"].to_s.to_f + vis_mi = data["current"]["vis_miles"].to_s.to_f + vis_km = data["current"]["vis_km"].to_s.to_f + heatindex_f = data["current"]["heatindex_f"].to_s.to_f + heatindex_c = data["current"]["heatindex_c"].to_s.to_f + windchill_f = data["current"]["windchill_f"].to_s.to_f + windchill_c = data["current"]["windchill_c"].to_s.to_f id = data["current"]["condition"]["code"] - disp = TOML.parse(File.read(Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))) - + if debug == true + disp = TOML.parse(" + 1 = \"{icon}\" + 2 = \"Live Temperature: {temp_f_color}{temp_f}{reset}°F\" + 3 = \"Live Temperature: {temp_c_color}{temp_c}{reset}°C\" + 4 = \"Feels like: {fl_f_color}{feels_like_f}{reset}°F\" + 5 = \"Feels like: {fl_c_color}{feels_like_c}{reset}°C\" + 6 = \"Wind Speed: {wind_mph_color}{wind_mph}{reset} MPH\" + 7 = \"Wind Speed: {wind_kph_color}{wind_kph}{reset} KPH\" + 8 = \"Humidity: {humidity}%\" + 9 = \"Pressure: {pressure_in} IN\" + 10 = \"Pressure: {pressure_mb} MB\" + 11 = \"Description: {orange}{bold}{description}{reset}\" + 12 = \"{goodbye}\" + ") + elsif test_config + puts "\nPlease paste the path of the config" + path_config = gets + disp = TOML.parse(File.read(Path["#{path_config}"].expand(home: true))) + else + disp = TOML.parse(File.read(Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))) + end repeat = 1 + if Time.local.minute < 10 + time = (Time.local.hour.to_s + 0.to_s + Time.local.minute.to_s).to_f + + if time < 1200 + message = "#{bold}#{orange}Have a good morning!#{reset}" + elsif time >= 1200 + message = "#{bold}#{orange}Have a good afternoon!#{reset}" + end + elsif Time.local.minute >= 10 + time = (Time.local.hour.to_s + Time.local.minute.to_s).to_f + if time < 1200 + message = "#{bold}#{orange}Have a good morning!#{reset}" + elsif time >= 1200 + message = "#{bold}#{orange}Have a good afternoon!#{reset}" + end + end + + if feelslike_f > 85 + fl_f_color = bold + red + elsif (70..84).includes?(feelslike_f) + fl_f_color = bold + "\e[1;33m" + elsif feelslike_f < 70 + fl_f_color = "\e[0;34m" + bold + end + + if feelslike_c > 29 + fl_c_color = bold + red + elsif (21..28).includes?(feelslike_c) + fl_c_color = bold + "\e[1;33m" + elsif feelslike_c < 21 + fl_c_color = "\e[0;34m" + bold + end + + if temp_f > 85 + temp_f_color = bold + red + elsif (70..84).includes?(temp_f) + temp_f_color = bold + "\e[1;33m" + elsif temp_f < 70 + temp_f_color = "\e[0;34m" + bold + end + + if temp_c > 29 + temp_c_color = bold + red + elsif (21..28).includes?(temp_c) + temp_c_color = bold + "\e[1;33m" + elsif temp_c < 21 + temp_c_color = "\e[0;34m" + bold + end + + if wind_mph > 73 + wind_mph_color = bold + red + elsif (13..26).includes?(wind_mph) + wind_mph_color = bold + "\e[1;33m" + elsif (1..12).includes?(wind_mph) + wind_mph_color = "\e[0;34m" + bold + end + + if wind_kph > 46 + wind_kph_color = bold + red + elsif (20..45).includes?(wind_mph) + wind_kph_color = bold + "\e[1;33m" + elsif (1..19).includes?(wind_mph) + wind_kph_color = "\e[0;34m" + bold + end + + vars = { "{temp_f}" => temp_f, "{temp_c}" => temp_c, @@ -101,13 +192,19 @@ module Wfetch "{description}" => desc, "{orange}" => orange, "{bold}" => bold, + "{fl_f_color}" => fl_f_color, + "{fl_c_color}" => fl_c_color, + "{temp_f_color}" => temp_f_color, + "{temp_c_color}" => temp_c_color, + "{wind_mph_color}" => wind_mph_color, + "{wind_kph_color}" => wind_kph_color, "{reset}" => reset, - "{icon}" => nil + "{icon}" => nil, + "{goodbye}" => message } - File.each_line("/home/koffeejava/.local/share/Wfetch/disp.toml") do |line| + File.each_line(Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)) do |line| entry = disp["#{repeat}"]? - if entry if entry.to_s == "{icon}" icon(id) @@ -115,7 +212,6 @@ module Wfetch pattern = Regex.new(vars.keys.map { |k| Regex.escape(k) }.join("|")) puts entry.to_s.gsub(pattern, vars) end - repeat += 1 end