diff --git a/src/icon-list.cr b/src/icon-list.cr index 76ed458..4d89e59 100644 --- a/src/icon-list.cr +++ b/src/icon-list.cr @@ -1,5 +1,3 @@ - - def icon(id) gray = "\e[38;5;241m" @@ -8,12 +6,20 @@ def icon(id) reset = "\e[0m" bold = "\033[1m" - time = (Time.local.hour.to_s + Time.local.minute.to_s).to_i - - if time > 1200 - orange = "\e[38;5;235m" - else - orange = "\e[38;5;214m" + 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" + 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" + else + orange = "\e[38;5;214m" + end end if id == 1000 diff --git a/src/installer.cr b/src/installer.cr index 0c801d1..0583669 100644 --- a/src/installer.cr +++ b/src/installer.cr @@ -1,15 +1,51 @@ orange = "\e[38;5;214m" -red = "\e[38;5;52m" +red = "\e[0;31m" bold = "\033[1m" reset = "\e[0m" -if Process.uid != 0 +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 "Finished" \ No newline at end of file +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/wfetch.cr b/src/wfetch.cr index ba568ee..f0981a4 100644 --- a/src/wfetch.cr +++ b/src/wfetch.cr @@ -7,7 +7,7 @@ require "option_parser" module Wfetch VERSION = "0.1.0" orange = "\e[38;5;214m" - red = "\e[38;5;52m" + red = "\e[0;31m" bold = "\033[1m" reset = "\e[0m"