mani-calc 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ui/floating-search.js +149 -1
package/package.json
CHANGED
|
@@ -98,7 +98,155 @@ class FloatingSearchBox {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
async handleSystemCommand(query) {
|
|
102
|
+
const cmd = query.toLowerCase().trim();
|
|
103
|
+
const { exec } = require('child_process');
|
|
104
|
+
const { promisify } = require('util');
|
|
105
|
+
const execAsync = promisify(exec);
|
|
106
|
+
|
|
107
|
+
const commands = {
|
|
108
|
+
'help': {
|
|
109
|
+
action: async () => {
|
|
110
|
+
return 'Commands: sleep, lock, shutdown, restart, logout, mute, volume up/down, theme, quit';
|
|
111
|
+
},
|
|
112
|
+
description: 'Show available commands'
|
|
113
|
+
},
|
|
114
|
+
'quit': {
|
|
115
|
+
action: async () => {
|
|
116
|
+
setTimeout(() => app.quit(), 500);
|
|
117
|
+
return 'Quitting Mani-Calc...';
|
|
118
|
+
},
|
|
119
|
+
description: 'Quit application'
|
|
120
|
+
},
|
|
121
|
+
'exit': {
|
|
122
|
+
action: async () => {
|
|
123
|
+
setTimeout(() => app.quit(), 500);
|
|
124
|
+
return 'Quitting Mani-Calc...';
|
|
125
|
+
},
|
|
126
|
+
description: 'Quit application'
|
|
127
|
+
},
|
|
128
|
+
'theme': {
|
|
129
|
+
action: async () => {
|
|
130
|
+
this.window.webContents.send('toggle-theme');
|
|
131
|
+
return 'Toggled theme';
|
|
132
|
+
},
|
|
133
|
+
description: 'Toggle Light/Dark mode'
|
|
134
|
+
},
|
|
135
|
+
'sleep': {
|
|
136
|
+
action: async () => {
|
|
137
|
+
await execAsync('rundll32.exe powrprof.dll,SetSuspendState 0,1,0');
|
|
138
|
+
return 'System going to sleep...';
|
|
139
|
+
},
|
|
140
|
+
description: 'Put computer to sleep'
|
|
141
|
+
},
|
|
142
|
+
'shutdown': {
|
|
143
|
+
action: async () => {
|
|
144
|
+
await execAsync('shutdown /s /t 0');
|
|
145
|
+
return 'Shutting down...';
|
|
146
|
+
},
|
|
147
|
+
description: 'Shutdown computer'
|
|
148
|
+
},
|
|
149
|
+
'restart': {
|
|
150
|
+
action: async () => {
|
|
151
|
+
await execAsync('shutdown /r /t 0');
|
|
152
|
+
return 'Restarting...';
|
|
153
|
+
},
|
|
154
|
+
description: 'Restart computer'
|
|
155
|
+
},
|
|
156
|
+
'lock': {
|
|
157
|
+
action: async () => {
|
|
158
|
+
await execAsync('rundll32.exe user32.dll,LockWorkStation');
|
|
159
|
+
return 'Locking computer...';
|
|
160
|
+
},
|
|
161
|
+
description: 'Lock computer'
|
|
162
|
+
},
|
|
163
|
+
'logout': {
|
|
164
|
+
action: async () => {
|
|
165
|
+
await execAsync('shutdown /l');
|
|
166
|
+
return 'Logging out...';
|
|
167
|
+
},
|
|
168
|
+
description: 'Log out current user'
|
|
169
|
+
},
|
|
170
|
+
'empty recycle bin': {
|
|
171
|
+
action: async () => {
|
|
172
|
+
await execAsync('rd /s /q %systemdrive%\\$Recycle.bin');
|
|
173
|
+
return 'Recycle bin emptied';
|
|
174
|
+
},
|
|
175
|
+
description: 'Empty recycle bin'
|
|
176
|
+
},
|
|
177
|
+
'volume up': {
|
|
178
|
+
action: async () => {
|
|
179
|
+
await execAsync('nircmd.exe changesysvolume 2000');
|
|
180
|
+
return 'Volume increased';
|
|
181
|
+
},
|
|
182
|
+
description: 'Increase volume'
|
|
183
|
+
},
|
|
184
|
+
'volume down': {
|
|
185
|
+
action: async () => {
|
|
186
|
+
await execAsync('nircmd.exe changesysvolume -2000');
|
|
187
|
+
return 'Volume decreased';
|
|
188
|
+
},
|
|
189
|
+
description: 'Decrease volume'
|
|
190
|
+
},
|
|
191
|
+
'mute': {
|
|
192
|
+
action: async () => {
|
|
193
|
+
await execAsync('nircmd.exe mutesysvolume 1');
|
|
194
|
+
return 'Volume muted';
|
|
195
|
+
},
|
|
196
|
+
description: 'Mute volume'
|
|
197
|
+
},
|
|
198
|
+
'unmute': {
|
|
199
|
+
action: async () => {
|
|
200
|
+
await execAsync('nircmd.exe mutesysvolume 0');
|
|
201
|
+
return 'Volume unmuted';
|
|
202
|
+
},
|
|
203
|
+
description: 'Unmute volume'
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
if (commands[cmd]) {
|
|
208
|
+
try {
|
|
209
|
+
const message = await commands[cmd].action();
|
|
210
|
+
return {
|
|
211
|
+
result: message,
|
|
212
|
+
type: 'system_command',
|
|
213
|
+
formatted: message
|
|
214
|
+
};
|
|
215
|
+
} catch (error) {
|
|
216
|
+
return {
|
|
217
|
+
error: `Failed to execute: ${error.message}`,
|
|
218
|
+
type: 'error'
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
show() {
|
|
227
|
+
if (this.window) {
|
|
228
|
+
this.window.show();
|
|
229
|
+
this.window.focus();
|
|
230
|
+
this.isVisible = true;
|
|
231
|
+
this.window.webContents.send('focus-input');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
hide() {
|
|
236
|
+
if (this.window) {
|
|
237
|
+
this.window.hide();
|
|
238
|
+
this.isVisible = false;
|
|
239
|
+
this.window.webContents.send('clear-input');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
toggle() {
|
|
244
|
+
if (this.isVisible) {
|
|
245
|
+
this.hide();
|
|
246
|
+
} else {
|
|
247
|
+
this.show();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
102
250
|
|
|
103
251
|
destroy() {
|
|
104
252
|
if (this.window) {
|