Add cleanurl for qutebrowser yank
This commit is contained in:
		
							parent
							
								
									cdd396ac53
								
							
						
					
					
						commit
						568700f9a2
					
				
					 2 changed files with 53 additions and 0 deletions
				
			
		|  | @ -27,3 +27,12 @@ def init(c): | |||
| 
 | ||||
|     c.bind('<Ctrl-Tab>', 'tab-next') | ||||
|     c.bind('<Ctrl-Shift-Tab>', 'tab-prev') | ||||
| 
 | ||||
|     try: | ||||
|         import unalix | ||||
|         c.unbind('yy') | ||||
|         c.unbind('yY') | ||||
|         c.bind('yy', 'spawn --userscript qute-clear-url', mode='normal') | ||||
|         c.bind('yY', 'spawn --userscript qute-clear-url -s', mode='normal') | ||||
|     except: | ||||
|         pass | ||||
|  |  | |||
							
								
								
									
										44
									
								
								.local/share/qutebrowser/userscripts/qute-clear-url
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								.local/share/qutebrowser/userscripts/qute-clear-url
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,44 @@ | |||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| import os | ||||
| import argparse | ||||
| 
 | ||||
| import unalix | ||||
| 
 | ||||
| 
 | ||||
| def qute(cmd): | ||||
|     with open(os.environ['QUTE_FIFO'], 'w') as fifo: | ||||
|         fifo.write(cmd) | ||||
|         fifo.write('\n') | ||||
|         fifo.flush() | ||||
| 
 | ||||
| def error(msg): | ||||
|     print(msg, file=sys.stderr) | ||||
|     qute('message-error "{}"'.format(msg)) | ||||
| 
 | ||||
| def parse_args(): | ||||
|     parser = argparse.ArgumentParser(description="Full passwords from KeepassXC") | ||||
|     parser.add_argument('--selection', '-s', action='store_true', | ||||
|                         help='Yank to selection') | ||||
|     return parser.parse_args() | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     if 'QUTE_FIFO' not in os.environ: | ||||
|         print(f"No QUTE_FIFO found - {sys.argv[0]} must be run as a qutebrowser userscript") | ||||
|         sys.exit(-1) | ||||
| 
 | ||||
|     try: | ||||
|         args = parse_args() | ||||
| 
 | ||||
|         url = os.environ['QUTE_URL'] | ||||
|         clean_url = unalix.clear_url(url) | ||||
| 
 | ||||
| 
 | ||||
|         if args.selection: | ||||
|             qute('yank inline "{}" -s'.format(clean_url)) | ||||
|         else: | ||||
|             qute('yank inline "{}"'.format(clean_url)) | ||||
| 
 | ||||
|     except Exception as e: | ||||
|         error(str(e)) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue