shit insert works
This commit is contained in:
@@ -8,6 +8,7 @@ Usage:
|
|||||||
datetime-clipboard.py 3t # 360-time format (0-359)
|
datetime-clipboard.py 3t # 360-time format (0-359)
|
||||||
datetime-clipboard.py uid # UUID first 8 chars
|
datetime-clipboard.py uid # UUID first 8 chars
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -15,18 +16,25 @@ import uuid
|
|||||||
|
|
||||||
|
|
||||||
def copy_to_clipboard(text):
|
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:
|
||||||
# Try wl-copy first (Wayland)
|
# 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:
|
except FileNotFoundError:
|
||||||
# Fallback to xclip (X11)
|
# Fallback to xclip (X11)
|
||||||
try:
|
try:
|
||||||
subprocess.run(['xclip', '-selection', 'clipboard'],
|
subprocess.run(
|
||||||
input=text.encode(), check=True)
|
["xclip", "-selection", "clipboard"], input=text.encode(), check=True
|
||||||
|
)
|
||||||
|
subprocess.run(
|
||||||
|
["xclip", "-selection", "primary"], input=text.encode(), check=True
|
||||||
|
)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("Error: Neither wl-copy nor xclip found. Install wl-clipboard or xclip.",
|
print(
|
||||||
file=sys.stderr)
|
"Error: Neither wl-copy nor xclip found. Install wl-clipboard or xclip.",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@@ -55,9 +63,9 @@ def main():
|
|||||||
format_type = sys.argv[1].lower()
|
format_type = sys.argv[1].lower()
|
||||||
|
|
||||||
formatters = {
|
formatters = {
|
||||||
'wd': get_weekday,
|
"wd": get_weekday,
|
||||||
'3t': get_360time,
|
"3t": get_360time,
|
||||||
'uid': get_uid,
|
"uid": get_uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if format_type not in formatters:
|
if format_type not in formatters:
|
||||||
@@ -72,5 +80,5 @@ def main():
|
|||||||
print(f"Copied to clipboard: {text}")
|
print(f"Copied to clipboard: {text}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user