Module: Lich::Main::StartupTheme

Defined in:
documented/main/startup_theme.rb

Overview

Resolves and applies Lich's persisted or explicitly requested startup theme.

Class Method Summary collapse

Class Method Details

.apply(argv_options) ⇒ Boolean

Apply the effective dark-mode setting for this process.

An explicit command-line value takes precedence and becomes the new persisted preference. Otherwise, the existing preference is used.

Parameters:

  • argv_options (Hash)

    parsed command-line options

Returns:

  • (Boolean)

    the effective dark-mode setting

Raises:

  • (ArgumentError)

    if the options or dark-mode value are invalid



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'documented/main/startup_theme.rb', line 17

def self.apply(argv_options)
  raise ArgumentError, 'argv_options must be a Hash' unless argv_options.is_a?(Hash)

  explicit = argv_options.key?(:dark_mode)
  theme_state = explicit ? argv_options[:dark_mode] : Lich.track_dark_mode
  unless theme_state == true || theme_state == false
    raise ArgumentError, 'dark_mode must be true or false'
  end

  Lich.track_dark_mode = theme_state if explicit
  Gtk::Settings.default.gtk_application_prefer_dark_theme = theme_state if defined?(Gtk)
  theme_state
end