-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorsair-mac-fix.rb
More file actions
73 lines (64 loc) · 2.35 KB
/
corsair-mac-fix.rb
File metadata and controls
73 lines (64 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/ruby
require 'fileutils'
def prompt(answer)
unless (answer == "Y") || (answer == "N")
until (answer == "Y") || (answer == "N")
print "Invalid input, please try again: "
answer = gets.upcase.strip
end
end
end
puts
puts "(Note: sudo password is required, enter it if / when prompted)"
puts
print "Have you previously attempted (failed) to install iCUE and would you like to clean up? [Delete -> /Applications/Corsair] (Y/N): "
previous_install = gets.upcase.strip
prompt(previous_install)
if previous_install == "Y"
system "ps aux | grep -i icue | awk '{print $2}' | xargs kill -9"
system "/usr/bin/sudo rm -rf /Applications/Corsair/"
end
puts
print "Have you previously installed homebrew (http://brew.sh)? [answering \"N\" will install it] (Y/N): "
existing = gets.upcase.strip
prompt(existing)
puts
if existing == "N"
system "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
puts
end
sleep 1
system "/usr/local/bin/brew install kamilturek/python2/python@2"
sleep 1
puts
system "/usr/local/bin/python2 -m pip install pyobjc-framework-Cocoa"
sleep 1
puts
system "/usr/local/bin/python2 -m pip install PyCocoa"
puts
puts "Creating requred file, it will be located here: #{FileUtils.pwd()}/set-file-icon"
puts "(This file can be safely removed once this process completes.)"
corsair_file = File.open("set-file-icon", "w:UTF-8")
corsair_file.puts "#!/usr/local/bin/python2"
corsair_file.puts
corsair_file.puts "import Cocoa"
corsair_file.puts "import sys"
corsair_file.puts
corsair_file.puts "Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit(\"Unable to set file icon\")"
corsair_file.close
FileUtils.chmod 0755, "#{FileUtils.pwd()}/set-file-icon"
puts
puts "After continuing below, you may start the iCUE Installer."
puts
puts "While it's installing, leave the terminal window open in the background. Crtl+c in the terminal window after installation completes."
puts
print "Continue? (Y/N): "
continue = gets.upcase.strip
prompt(continue)
puts
if continue == "Y"
while true
system "/usr/bin/sudo /bin/cp -v -f #{FileUtils.pwd()}/set-file-icon /Applications/Corsair/iCUEUninstaller.app/Contents/Scripts/"
sleep 0.1
end
end