Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82b3a4847d | ||
|
|
c5248c6209 | ||
|
|
d9984d97a6 |
@@ -8,8 +8,8 @@ targets:
|
|||||||
wfetch:
|
wfetch:
|
||||||
main: src/wfetch.cr
|
main: src/wfetch.cr
|
||||||
|
|
||||||
wfp-tool:
|
wf-tool:
|
||||||
main: src/wfp-tool.cr
|
main: src/wf-tool.cr
|
||||||
|
|
||||||
crystal: '>= 1.19.1'
|
crystal: '>= 1.19.1'
|
||||||
|
|
||||||
|
|||||||
94
src/wf-tool.cr
Normal file
94
src/wf-tool.cr
Normal file
@@ -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
|
||||||
@@ -5,7 +5,7 @@ require "./icon-list"
|
|||||||
require "option_parser"
|
require "option_parser"
|
||||||
|
|
||||||
module Wfetch
|
module Wfetch
|
||||||
VERSION = "1.1.0"
|
VERSION = "1.0.0"
|
||||||
orange = "\e[38;5;214m"
|
orange = "\e[38;5;214m"
|
||||||
red = "\e[0;31m"
|
red = "\e[0;31m"
|
||||||
bold = "\e[1m"
|
bold = "\e[1m"
|
||||||
@@ -33,7 +33,7 @@ module Wfetch
|
|||||||
test_config = true
|
test_config = true
|
||||||
}
|
}
|
||||||
parser.on("-v", "--version", "Shows the current version of wfetch") {
|
parser.on("-v", "--version", "Shows the current version of wfetch") {
|
||||||
puts "#{bold}#{orange}Wfetch 1.1.0 KoffeeJava 2026#{reset}"
|
puts "#{bold}#{orange}Wfetch 1.0.0 KoffeeJava 2026#{reset}"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
parser.on("-h", "--help", "Show this help") do
|
parser.on("-h", "--help", "Show this help") do
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
orange = "\e[38;5;214m"
|
|
||||||
red = "\e[0;31m"
|
|
||||||
bold = "\033[1m"
|
|
||||||
reset = "\e[0m"
|
|
||||||
|
|
||||||
Dir.mkdir("config")
|
|
||||||
|
|
||||||
|
|
||||||
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("config/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", "config/disp.toml")
|
|
||||||
elsif choice == "2"
|
|
||||||
File.copy("data/2.toml", "config/disp.toml")
|
|
||||||
elsif choice == "3"
|
|
||||||
File.copy("data/3.toml", "config/disp.toml")
|
|
||||||
else
|
|
||||||
File.copy("data/1.toml", "config/disp.toml")
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "#{orange}#{bold}Setup finnished. Enjoy!#{reset}"
|
|
||||||
|
|
||||||
Dir.remove("data")
|
|
||||||
Reference in New Issue
Block a user