@@ -24,7 +24,14 @@ use self::toplevel_handler::{toplevel_handler, ToplevelAction, ToplevelEvent};
24
24
pub async fn main ( ) {
25
25
tracing:: info!( "starting cosmic-toplevel" ) ;
26
26
27
- let ( mut app, mut toplevel_rx) = App :: new ( async_stdout ( ) ) ;
27
+ let mut tx = async_stdout ( ) ;
28
+
29
+ if session_is_cosmic ( ) {
30
+ send ( & mut tx, PluginResponse :: Deactivate ) . await ;
31
+ return ;
32
+ }
33
+
34
+ let ( mut app, mut toplevel_rx) = App :: new ( tx) ;
28
35
29
36
let mut requests = json_input_stream ( async_stdin ( ) ) ;
30
37
let mut next_request = requests. next ( ) ;
@@ -94,7 +101,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
94
101
fn new ( tx : W ) -> ( Self , mpsc:: UnboundedReceiver < ToplevelEvent > ) {
95
102
let ( toplevels_tx, toplevel_rx) = mpsc:: unbounded ( ) ;
96
103
let ( calloop_tx, calloop_rx) = calloop:: channel:: channel ( ) ;
97
- let _ = std:: thread:: spawn ( move || toplevel_handler ( toplevels_tx, calloop_rx) ) ;
104
+ let _handle = std:: thread:: spawn ( move || toplevel_handler ( toplevels_tx, calloop_rx) ) ;
98
105
99
106
(
100
107
Self {
@@ -123,7 +130,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
123
130
}
124
131
} ) {
125
132
tracing:: info!( "activating: {id}" ) ;
126
- let _ = self . calloop_tx . send ( ToplevelAction :: Activate ( handle) ) ;
133
+ let _res = self . calloop_tx . send ( ToplevelAction :: Activate ( handle) ) ;
127
134
}
128
135
}
129
136
@@ -138,7 +145,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
138
145
None
139
146
}
140
147
} ) {
141
- let _ = self . calloop_tx . send ( ToplevelAction :: Close ( handle) ) ;
148
+ let _res = self . calloop_tx . send ( ToplevelAction :: Close ( handle) ) ;
142
149
}
143
150
}
144
151
@@ -197,3 +204,12 @@ impl<W: AsyncWrite + Unpin> App<W> {
197
204
let _ = self . tx . flush ( ) ;
198
205
}
199
206
}
207
+
208
+ #[ must_use]
209
+ fn session_is_cosmic ( ) -> bool {
210
+ if let Ok ( var) = std:: env:: var ( "XDG_CURRENT_DESKTOP" ) {
211
+ return var. contains ( "COSMIC" ) ;
212
+ }
213
+
214
+ false
215
+ }
0 commit comments