@@ -25,8 +25,16 @@ def copy_characters_to_clipboard(self, characters: str) -> None:
2525 )
2626
2727 def copy_paste_characters (self , characters : str , active_window : str , typer : Typer ) -> None :
28- old_clipboard_content = run (args = ["xclip" , "-o" , "-selection" , "clipboard" ], capture_output = True ).stdout
29- old_primary_content = run (args = ["xclip" , "-o" , "-selection" , "primary" ], capture_output = True ).stdout
28+ old_clipboard_content = run (
29+ args = ["xclip" , "-out" , "-selection" , "clipboard" , "-target" , "text/plain;charset=utf-8" ],
30+ capture_output = True ,
31+ encoding = "utf-8" ,
32+ )
33+ old_primary_content = run (
34+ args = ["xclip" , "-out" , "-selection" , "primary" , "-target" , "text/plain;charset=utf-8" ],
35+ capture_output = True ,
36+ encoding = "utf-8" ,
37+ )
3038
3139 run (
3240 args = ["xclip" , "-i" , "-selection" , "clipboard" ],
@@ -45,15 +53,19 @@ def copy_paste_characters(self, characters: str, active_window: str, typer: Type
4553
4654 typer .insert_from_clipboard (active_window )
4755
48- run (
49- args = ["xclip" , "-i" , "-selection" , "clipboard" ],
50- input = old_clipboard_content ,
51- stderr = subprocess .DEVNULL ,
52- stdout = subprocess .DEVNULL ,
53- )
54- run (
55- args = ["xclip" , "-i" , "-selection" , "primary" ],
56- input = old_primary_content ,
57- stderr = subprocess .DEVNULL ,
58- stdout = subprocess .DEVNULL ,
59- )
56+ if old_clipboard_content .returncode == 0 :
57+ run (
58+ args = ["xclip" , "-i" , "-selection" , "clipboard" ],
59+ input = old_clipboard_content .stdout ,
60+ stderr = subprocess .DEVNULL ,
61+ stdout = subprocess .DEVNULL ,
62+ encoding = "utf-8" ,
63+ )
64+ if old_primary_content .returncode == 0 :
65+ run (
66+ args = ["xclip" , "-i" , "-selection" , "primary" ],
67+ input = old_primary_content .stdout ,
68+ stderr = subprocess .DEVNULL ,
69+ stdout = subprocess .DEVNULL ,
70+ encoding = "utf-8" ,
71+ )
0 commit comments