-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for "kill a task" button for Linux
- Added support for killing tasks on Linux using `killall -ignore-case` - Moved task killing logic to a dedicated taskkill.py file - Updated commands.py to use the new kill function - Updated commands.json to include OS-specific arguments for task killing - Updated translations to include OS-specific argument names for task killing
- Loading branch information
Showing
9 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .command_handler import handle_command | ||
from .screensaver import handle_command as screensaver | ||
from .lock_session import lock_session | ||
from .taskkill import kill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from app.utils.platform import is_windows, is_linux | ||
|
||
import os | ||
import subprocess | ||
import pyautogui | ||
from app.utils.logger import log | ||
from .. import window | ||
|
||
def kill(message): | ||
process = ( | ||
message.replace("/kill", "") | ||
.replace("/taskill", "") | ||
.replace("/taskkill", "") | ||
.replace("/forceclose", "") | ||
).strip() | ||
|
||
if is_windows: | ||
if process.endswith(".exe"): | ||
subprocess.Popen(f"taskkill /f /im {process}", shell=True) | ||
else: | ||
window_name = process | ||
hwnd = window.get_by_name(window_name) | ||
if hwnd: | ||
log.debug(f"Window '{window_name}' found with handle : {hwnd}") | ||
try: | ||
window.close(hwnd) | ||
except: | ||
subprocess.Popen(f"taskkill /f /im {window_name}.exe", shell=True) | ||
else: | ||
log.debug(f"Window '{window_name}' not found") | ||
subprocess.Popen(f"taskkill /f /im {window_name}.exe", shell=True) | ||
|
||
elif is_linux: | ||
log.debug(f"Killing process '{process}'") | ||
if subprocess.run(f"killall --ignore-case {process}", shell=True).returncode == 0: | ||
log.success(f"Process '{process}' killed successfully") | ||
else: | ||
log.error(f"Process '{process}' not found") | ||
raise RuntimeError(f"Process '{process}' not found") | ||
|
||
else: | ||
raise NotImplementedError("Screensaver is not implemented for this platform.") | ||
|
||
|
||
def screensaver_off(): | ||
pyautogui.press("CTRL") | ||
if is_linux: | ||
os.system("gnome-screensaver-command -d") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters