LinuxDistro.rb 2.7 KB

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