File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ impl App {
108108 display_name: "Quit RustCast" . to_string( ) ,
109109 search_name: "quit" . to_string( ) ,
110110 } ,
111+ App {
112+ ranking: 0 ,
113+ open_command: AppCommand :: Function ( Function :: QuitAllApps ) ,
114+ desc: RUSTCAST_DESC_NAME . to_string( ) ,
115+ icons: icons. clone( ) ,
116+ display_name: "Quit All Apps" . to_string( ) ,
117+ search_name: "quit all apps" . to_string( ) ,
118+ } ,
111119 App {
112120 ranking: 0 ,
113121 open_command: AppCommand :: Message ( Message :: SwitchToPage ( Page :: Settings ) ) ,
Original file line number Diff line number Diff line change @@ -11,14 +11,15 @@ use crate::{
1111 calculator:: Expr ,
1212 clipboard:: ClipBoardContentType ,
1313 config:: Config ,
14- quit:: terminate_app,
14+ quit:: { terminate_all_apps , terminate_app} ,
1515} ;
1616
1717/// The different functions that rustcast can perform
1818#[ derive( Debug , Clone , PartialEq ) ]
1919pub enum Function {
2020 OpenApp ( String ) ,
2121 QuitApp ( String ) ,
22+ QuitAllApps ,
2223 RunShellCommand ( String ) ,
2324 OpenWebsite ( String ) ,
2425 RandomVar ( i32 ) , // Easter egg function
@@ -50,6 +51,10 @@ impl Function {
5051 . unwrap_or ( ( ) ) ;
5152 }
5253
54+ Function :: QuitAllApps => {
55+ terminate_all_apps ( ) ;
56+ }
57+
5358 Function :: QuitApp ( name) => {
5459 terminate_app ( name. to_owned ( ) ) ;
5560 }
Original file line number Diff line number Diff line change @@ -65,3 +65,12 @@ pub fn terminate_app(name: String) {
6565 }
6666 }
6767}
68+
69+ pub fn terminate_all_apps ( ) {
70+ let open_apps = NSWorkspace :: sharedWorkspace ( ) . runningApplications ( ) ;
71+ for app in open_apps {
72+ if app. activationPolicy ( ) == NSApplicationActivationPolicy :: Regular {
73+ app. terminate ( ) ;
74+ }
75+ }
76+ }
You can’t perform that action at this time.
0 commit comments