shit insert works

This commit is contained in:
buenosairesam
2025-12-29 14:17:17 -03:00
parent f5ddcad45c
commit 88caa3dc96

View File

@@ -8,6 +8,7 @@ Usage:
datetime-clipboard.py 3t # 360-time format (0-359)
datetime-clipboard.py uid # UUID first 8 chars
"""
import sys
import subprocess
from datetime import datetime
@@ -15,18 +16,25 @@ import uuid
def copy_to_clipboard(text):
"""Copy text to clipboard using wl-copy (Wayland) or xclip (X11) as fallback."""
"""Copy text to both clipboard and primary selection (for Shift+Insert in terminals)."""
try:
# Try wl-copy first (Wayland)
subprocess.run(['wl-copy'], input=text.encode(), check=True)
subprocess.run(["wl-copy"], input=text.encode(), check=True)
subprocess.run(["wl-copy", "--primary"], input=text.encode(), check=True)
except FileNotFoundError:
# Fallback to xclip (X11)
try:
subprocess.run(['xclip', '-selection', 'clipboard'],
input=text.encode(), check=True)
subprocess.run(
["xclip", "-selection", "clipboard"], input=text.encode(), check=True
)
subprocess.run(
["xclip", "-selection", "primary"], input=text.encode(), check=True
)
except FileNotFoundError:
print("Error: Neither wl-copy nor xclip found. Install wl-clipboard or xclip.",
file=sys.stderr)
print(
"Error: Neither wl-copy nor xclip found. Install wl-clipboard or xclip.",
file=sys.stderr,
)
sys.exit(1)
@@ -55,9 +63,9 @@ def main():
format_type = sys.argv[1].lower()
formatters = {
'wd': get_weekday,
'3t': get_360time,
'uid': get_uid,
"wd": get_weekday,
"3t": get_360time,
"uid": get_uid,
}
if format_type not in formatters:
@@ -72,5 +80,5 @@ def main():
print(f"Copied to clipboard: {text}")
if __name__ == '__main__':
if __name__ == "__main__":
main()