LinuxDistro.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. module RimeDeploy
  2. module LinuxDistro
  3. class InstallRimeJob < Job
  4. def update_config_path(path)
  5. module ::RimeDeploy::Config::LinuxDistro
  6. alias ConfigPath path
  7. end
  8. end
  9. def call
  10. puts intro
  11. puts "Different Linux has it's own package manager. So make sure you had installed Rime before."
  12. tips = <<-TIP
  13. Different Linux has it's own package manager. So make sure you had installed Rime before.
  14. For Fcitx5, installfcitx5-rime.
  15. For Fcitx, install fcitx-rime.
  16. For IBus, install ibus-rime.
  17. more:
  18. https://wiki.archlinux.org/title/Rime
  19. TIP
  20. puts tips
  21. puts ""
  22. puts "Then choose what your had installed."
  23. ChooseSession.new(
  24. [
  25. ["ibus-rime", -> { update_config_path(::RimeDeploy::Config::LinuxDistro::ConfigPathIbus) }],
  26. ["fcitx-rime", -> { update_config_path(::RimeDeploy::Config::LinuxDistro::ConfigPathFcitx) }],
  27. ["fcitx5-rime", -> { update_config_path(::RimeDeploy::Config::LinuxDistro::ConfigPathFcitx5) }],
  28. ]
  29. ).call
  30. sleep 1
  31. return :next
  32. end
  33. end
  34. class BackupRimeConfigJob < Job
  35. def call
  36. puts intro
  37. system(
  38. "mv #{Config::LinuxDistro::ConfigPath} #{Config::LinuxDistro::ConfigPath}.#{Time.now.to_i}.old"
  39. )
  40. sleep 1
  41. return :next
  42. end
  43. end
  44. class CloneConfigJob < Job
  45. def call
  46. puts intro
  47. system(
  48. "git clone --depth=1 #{Config::RIME_CONFIG_REPO} #{Config::LinuxDistro::ConfigPath}"
  49. )
  50. sleep 1
  51. return :next
  52. end
  53. end
  54. class CopyCustomConfigJob < Job
  55. def call
  56. puts intro
  57. system(
  58. "cp ./custom/default.custom.yaml #{Config::LinuxDistro::ConfigPath}/"
  59. )
  60. system(
  61. "cp ./custom/squirrel.custom.yaml #{Config::LinuxDistro::ConfigPath}/"
  62. )
  63. sleep 1
  64. return :next
  65. end
  66. end
  67. class FinishedJob < Job
  68. def call
  69. puts ""
  70. puts "Tips: When finished all jobs. You need to do follow:".yellow
  71. puts "1) Restart system."
  72. puts "2) open Rime input method setting pane and click " +
  73. "DEPLOY".yellow + " button."
  74. puts "Enjoy~ 🍻"
  75. puts "more info:".yellow
  76. puts "Config path: #{Config::LinuxDistro::ConfigPath}/"
  77. return :next
  78. end
  79. end
  80. BeforeHook = [
  81. CheckInstallRimeJob
  82. ]
  83. Jobs = [
  84. BackupRimeConfigJob,
  85. CloneConfigJob,
  86. CopyCustomConfigJob
  87. ]
  88. FinishedHook = [FinishedJob]
  89. end
  90. end