@@ -5,13 +5,12 @@ pub mod update;
55use crate :: app:: apps:: App ;
66use crate :: app:: { ArrowKey , Message , Move , Page } ;
77use crate :: clipboard:: ClipBoardContentType ;
8- use crate :: config:: Config ;
8+ use crate :: config:: { Config , Shelly } ;
99use crate :: debounce:: Debouncer ;
1010use crate :: platform:: default_app_paths;
11+ use crate :: platform:: macos:: launching:: Shortcut ;
1112
1213use arboard:: Clipboard ;
13- use global_hotkey:: hotkey:: HotKey ;
14- use global_hotkey:: { GlobalHotKeyEvent , HotKeyState } ;
1514
1615use iced:: futures:: SinkExt ;
1716use iced:: futures:: channel:: mpsc:: { Sender , channel} ;
@@ -190,9 +189,9 @@ pub struct Tile {
190189/// Stores the toggle [`HotKey`] and the Clipboard [`HotKey`]
191190#[ derive( Clone , Debug ) ]
192191pub struct Hotkeys {
193- pub toggle : HotKey ,
194- pub clipboard_hotkey : HotKey ,
195- pub shells : HashMap < u32 , String > ,
192+ pub toggle : Shortcut ,
193+ pub clipboard_hotkey : Shortcut ,
194+ pub shells : HashMap < Shortcut , Shelly > ,
196195}
197196
198197impl Tile {
@@ -229,7 +228,6 @@ impl Tile {
229228 _ => None ,
230229 } ) ;
231230 Subscription :: batch ( [
232- Subscription :: run ( handle_hotkeys) ,
233231 Subscription :: run ( handle_hot_reloading) ,
234232 keyboard,
235233 Subscription :: run ( handle_recipient) ,
@@ -241,37 +239,34 @@ impl Tile {
241239 if let keyboard:: Event :: KeyPressed { key, modifiers, .. } = event {
242240 match key {
243241 keyboard:: Key :: Named ( Named :: ArrowUp ) => {
244- return Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) ) ;
242+ Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) )
245243 }
246244 keyboard:: Key :: Named ( Named :: ArrowLeft ) => {
247- return Some ( Message :: ChangeFocus ( ArrowKey :: Left , 1 ) ) ;
245+ Some ( Message :: ChangeFocus ( ArrowKey :: Left , 1 ) )
248246 }
249247 keyboard:: Key :: Named ( Named :: ArrowRight ) => {
250- return Some ( Message :: ChangeFocus ( ArrowKey :: Right , 1 ) ) ;
248+ Some ( Message :: ChangeFocus ( ArrowKey :: Right , 1 ) )
251249 }
252250 keyboard:: Key :: Named ( Named :: ArrowDown ) => {
253- return Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) ) ;
251+ Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) )
254252 }
255253 keyboard:: Key :: Character ( chr) => {
256254 if modifiers. command ( ) && chr. to_string ( ) == "r" {
257- return Some ( Message :: ReloadConfig ) ;
255+ Some ( Message :: ReloadConfig )
258256 } else if chr. to_string ( ) == "p" && modifiers. control ( ) {
259- return Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) ) ;
257+ Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) )
260258 } else if chr. to_string ( ) == "n" && modifiers. control ( ) {
261- return Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) ) ;
259+ Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) )
262260 } else {
263- return Some ( Message :: FocusTextInput ( Move :: Forwards (
264- chr. to_string ( ) ,
265- ) ) ) ;
261+ Some ( Message :: FocusTextInput ( Move :: Forwards ( chr. to_string ( ) ) ) )
266262 }
267263 }
268- keyboard:: Key :: Named ( Named :: Enter ) => return Some ( Message :: OpenFocused ) ,
264+ keyboard:: Key :: Named ( Named :: Enter ) => Some ( Message :: OpenFocused ) ,
269265 keyboard:: Key :: Named ( Named :: Backspace ) => {
270- return Some ( Message :: FocusTextInput ( Move :: Back ) ) ;
266+ Some ( Message :: FocusTextInput ( Move :: Back ) )
271267 }
272- _ => { }
268+ _ => None ,
273269 }
274- None
275270 } else {
276271 None
277272 }
@@ -337,22 +332,6 @@ impl Tile {
337332 }
338333}
339334
340- /// This is the subscription function that handles hotkeys, e.g. for hiding / showing the window
341- fn handle_hotkeys ( ) -> impl futures:: Stream < Item = Message > {
342- stream:: channel ( 100 , async |mut output| {
343- let receiver = GlobalHotKeyEvent :: receiver ( ) ;
344- loop {
345- info ! ( "Hotkey received" ) ;
346- if let Ok ( event) = receiver. recv ( )
347- && event. state == HotKeyState :: Pressed
348- {
349- output. try_send ( Message :: KeyPressed ( event. id ) ) . unwrap ( ) ;
350- }
351- tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
352- }
353- } )
354- }
355-
356335/// This is the subscription function that handles the change in clipboard history
357336fn handle_clipboard_history ( ) -> impl futures:: Stream < Item = Message > {
358337 stream:: channel ( 100 , async |mut output| {
@@ -602,7 +581,6 @@ fn handle_recipient() -> impl futures::Stream<Item = Message> {
602581 let abcd = recipient
603582 . try_recv ( )
604583 . map ( async |msg| {
605- info ! ( "Sending a message" ) ;
606584 output. send ( msg) . await . unwrap ( ) ;
607585 } )
608586 . ok ( ) ;
0 commit comments