Skip to content

Commit

Permalink
Add Cura.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Nov 10, 2022
1 parent d106920 commit 6baadb9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def require(name)
concurrent-edge
concurrent-ruby-ext
concurrent-ruby-edge
iniparse
plist
vdf
].freeze
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/brew.rake
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ namespace :brew do
'textmate-solarized' => {},
'transmission' => {},
'unicodechecker' => {},
'ultimaker-cura' => {},
'vagrant' => {},
'vagrant-manager' => {},
'visual-studio-code' => {},
Expand Down
46 changes: 46 additions & 0 deletions lib/tasks/cura.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

require 'iniparse'
require 'json'

MOONRAKER_INSTANCES = {
"Longer LK5 Pro" => {
api_key: "",
camera_url: "",
frontend_url: "",
output_format: "ufp",
power_device: "",
retry_interval: "",
trans_input: "",
trans_output: "",
trans_remove: "",
upload_autohide_messagebox: false,
upload_dialog: true,
upload_remember_state: false,
upload_start_print_job: false,
url: "http://lk5-pro.reiter.ooo/",
}
}

task :cura => [:'brew:casks_and_formulae'] do
cura_version = JSON.parse(capture('brew', 'info', '--json=v2', '--cask',
'ultimaker-cura')).fetch('casks').fetch(0).fetch('installed')
cura_version = cura_version.match(/\A(\d+\.\d+)\.\d+\Z/)[1]

config_dir = Pathname("~/Library/Application Support/cura/#{cura_version}").expand_path
config_path = config_dir / 'cura.cfg'

config = IniParse.parse(config_path.read)

general_config = config.section('general')
general_config['accepted_user_agreement'] = true
general_config['auto_slice'] = false
general_config['theme'] = 'cura-dark'

moonraker_config = config.section('moonraker')
moonraker_instances = moonraker_config['instances']&.yield_self { |json| JSON.parse(json) } || {}
moonraker_instances.merge!(MOONRAKER_INSTANCES)
moonraker_config['instances'] = moonraker_instances.to_json

config_path.write config.to_ini
end

0 comments on commit 6baadb9

Please sign in to comment.