-
-
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 opening clipboard manager on Linux
- Added support for opening clipboard manager on Linux using common clipboard managers (copyq, gpaste-client, clipman, parcellite, xfce4-clipman, klipper, diodon) or using Win+V - Moved open clipboard logic to a dedicated open_clipboard.py file - Updated commands.py to use the new open_clipboard function
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
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
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,48 @@ | ||
from app.utils.platform import is_windows, is_linux | ||
|
||
import subprocess | ||
import pyautogui | ||
from app.utils.logger import log | ||
|
||
|
||
def open_clipboard(): | ||
if is_windows: | ||
pyautogui.hotkey("win", "v") | ||
|
||
if is_linux: | ||
def is_command_available(command): | ||
"""Check if a command is available on the system.""" | ||
try: | ||
if subprocess.run(["which", command], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: | ||
return True | ||
return False | ||
except FileNotFoundError: | ||
return False | ||
|
||
# Check for common clipboard managers and open them if installed | ||
clipboard_managers = { | ||
"copyq": "copyq show", | ||
"gpaste-client": "gpaste-client ui", | ||
"clipman": "clipman show-history", | ||
"parcellite": "parcellite", | ||
"xfce4-clipman": "xfce4-clipman-history", | ||
"klipper": "qdbus org.kde.klipper /klipper org.kde.klipper.klipper.showHistory", | ||
"diodon": "diodon --indicator", | ||
} | ||
|
||
for manager, command in clipboard_managers.items(): | ||
if is_command_available(manager): | ||
if subprocess.run(command, shell=True).returncode == 0: | ||
log.success(f"Opened clipboard manager: '{manager}' Using command: '{command}'") | ||
else: | ||
log.error(f"Failed to open {manager}") | ||
|
||
return | ||
|
||
pyautogui.hotkey("win", "v") | ||
|
||
log.error("No supported clipboard manager found. Please install one, e.g., 'copyq'. Performing default action (Win+V).") | ||
raise RuntimeError("No supported clipboard manager found. Please install one, e.g., 'copyq'. Performing default action (Win+V).") | ||
|
||
else: | ||
raise NotImplementedError("This is not implemented for this platform.") |