@@ -9,6 +9,7 @@ mod plugins;
99mod tray;
1010
1111use crate :: config:: { load_config, Config } ;
12+ use crate :: tray:: TrayMessage ;
1213use anyhow:: { bail, Context , Result } ;
1314use async_osc:: OscMessage ;
1415use clap:: Parser ;
@@ -132,26 +133,33 @@ impl Launcher {
132133 }
133134
134135 async fn wait ( & mut self , subsys : & SubsystemHandle ) -> Result < ( ) > {
135- let ( reload_tx , mut reload_rx ) = mpsc:: channel ( 4 ) ;
136- let mut tray = tray:: Tray :: new ( reload_tx , self . dark_mode_icons ) ?;
136+ let ( tray_tx , mut tray_rx ) = mpsc:: channel ( 4 ) ;
137+ let mut tray = tray:: Tray :: new ( tray_tx , self . dark_mode_icons ) ?;
137138 let mut maybe_plugin_subsys: Option < NestedSubsystem > = None ;
138139
139140 loop {
140141 select ! {
141- Some ( ( ) ) = reload_rx. recv( ) => {
142- info!( "Reloading plugins" ) ;
143- self . config = Arc :: new( load_config( ) . await ?) ;
144-
145- if let Some ( plugin_subsys) = maybe_plugin_subsys {
146- subsys. perform_partial_shutdown( plugin_subsys) . await ?;
147-
148- let config = self . config. clone( ) ;
149- let receiver_tx = self . receiver_tx. clone( ) ;
150- let sender_tx = self . sender_tx. clone( ) ;
151-
152- maybe_plugin_subsys = Some ( subsys. start( "Plugins" , move |subsys| {
153- run_plugins( subsys, config, receiver_tx, sender_tx)
154- } ) ) ;
142+ Some ( message) = tray_rx. recv( ) => {
143+ match message {
144+ TrayMessage :: ReloadPlugins => {
145+ info!( "Reloading plugins" ) ;
146+ self . config = Arc :: new( load_config( ) . await ?) ;
147+
148+ if let Some ( plugin_subsys) = maybe_plugin_subsys {
149+ subsys. perform_partial_shutdown( plugin_subsys) . await ?;
150+
151+ let config = self . config. clone( ) ;
152+ let receiver_tx = self . receiver_tx. clone( ) ;
153+ let sender_tx = self . sender_tx. clone( ) ;
154+
155+ maybe_plugin_subsys = Some ( subsys. start( "Plugins" , move |subsys| {
156+ run_plugins( subsys, config, receiver_tx, sender_tx)
157+ } ) ) ;
158+ }
159+ }
160+ TrayMessage :: Exit => {
161+ subsys. request_shutdown( ) ;
162+ }
155163 }
156164 }
157165 Some ( vrchat_running) = self . rx. recv( ) => {
0 commit comments