Update configs
This commit is contained in:
		
							parent
							
								
									cc39076825
								
							
						
					
					
						commit
						b033291384
					
				
					 7 changed files with 54 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -1,14 +1,21 @@
 | 
			
		|||
import os
 | 
			
		||||
 | 
			
		||||
def init(c):
 | 
			
		||||
    c.unbind('d') # I prefer ctrl+w to close tabs. I hit d by mistake too often.
 | 
			
		||||
 | 
			
		||||
    c.bind(',v', 'spawn io.freetubeapp.FreeTube {url}')
 | 
			
		||||
    c.bind(',V', 'hint links spawn io.freetubeapp.FreeTube {hint-url}')
 | 
			
		||||
 | 
			
		||||
    # external
 | 
			
		||||
    c.bind(',eb', 'spawn chromium {url}')
 | 
			
		||||
    c.bind(',eB', 'hint links spawn chromium {hint-url}')
 | 
			
		||||
    browser_chromium = os.getenv('BROWSER_CHROMIUM', 'chromium')
 | 
			
		||||
    c.bind(',eb', f'spawn {browser_chromium} {{url}}')
 | 
			
		||||
    c.bind(',eB', f'hint links spawn {browser_chromium} {{hint-url}}')
 | 
			
		||||
    c.bind(',ef', 'spawn firefox {url}')
 | 
			
		||||
    c.bind(',eF', 'hint links spawn firefox {hint-url}')
 | 
			
		||||
    c.bind(',es', 'spawn xdg-open steam://openurl/{url}')
 | 
			
		||||
    c.bind(',ep', 'spawn kdeconnect-cli -n Fairphone3 --share {url}')
 | 
			
		||||
    c.bind(',et', 'spawn ts-control message {url}')
 | 
			
		||||
    c.bind(',eT', 'hint links spawn ts-control message {hint-url}')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    c.bind(',g', 'open {url:scheme}://github1s.com{url:path}{url:query}')
 | 
			
		||||
| 
						 | 
				
			
			@ -16,12 +23,11 @@ def init(c):
 | 
			
		|||
    c.bind(',rt', 'open {url:scheme}://teddit.net{url:path}{url:query}')
 | 
			
		||||
 | 
			
		||||
    gpg_key = '723B78C0BF8D8C721D2C4EEF41E544A54E2533B2'
 | 
			
		||||
 | 
			
		||||
    c.bind(',p', 'spawn --userscript qutebrowser-keepassxc --key ' + gpg_key, mode='normal')
 | 
			
		||||
    c.bind(',Pu', 'spawn --userscript qutebrowser-keepassxc --only-username --key ' + gpg_key, mode='normal')
 | 
			
		||||
    c.bind(',Pi', 'spawn --userscript qutebrowser-keepassxc --only-password --key ' + gpg_key, mode='normal')
 | 
			
		||||
    c.bind(',Po', 'spawn --userscript qutebrowser-keepassxc --only-otp --key ' + gpg_key, mode='normal')
 | 
			
		||||
    c.bind(',Pp', 'spawn --userscript qutebrowser-keepassxc --autotype --key ' + gpg_key, mode='normal')
 | 
			
		||||
    c.bind(',p',  f'spawn --userscript qutebrowser-keepassxc --key {gpg_key}', mode='normal')
 | 
			
		||||
    c.bind(',Pu', f'spawn --userscript qutebrowser-keepassxc --only-username --key {gpg_key}', mode='normal')
 | 
			
		||||
    c.bind(',Pi', f'spawn --userscript qutebrowser-keepassxc --only-password --key {gpg_key}', mode='normal')
 | 
			
		||||
    c.bind(',Po', f'spawn --userscript qutebrowser-keepassxc --only-otp --key {gpg_key}', mode='normal')
 | 
			
		||||
    c.bind(',Pp', f'spawn --userscript qutebrowser-keepassxc --autotype --key {gpg_key}', mode='normal')
 | 
			
		||||
 | 
			
		||||
    # output
 | 
			
		||||
    c.bind(',oq', 'spawn --userscript qr {url}')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ import urllib.request
 | 
			
		|||
linkwarden_url = os.environ.get('LINKWARDEN_URL')
 | 
			
		||||
linkwarden_token = os.environ.get('LINKWARDEN_TOKEN')
 | 
			
		||||
 | 
			
		||||
def get_links(cursor):
 | 
			
		||||
def get_links_part(cursor):
 | 
			
		||||
    request = urllib.request.Request(linkwarden_url + "/api/v1/links?sort=0&cursor=" + str(cursor), headers={
 | 
			
		||||
        'Authorization': 'Bearer ' + linkwarden_token
 | 
			
		||||
    })
 | 
			
		||||
| 
						 | 
				
			
			@ -15,33 +15,44 @@ def get_links(cursor):
 | 
			
		|||
    data = ' '.join(data.split())
 | 
			
		||||
    return json.loads(data).get("response", [])
 | 
			
		||||
 | 
			
		||||
def init():
 | 
			
		||||
    if linkwarden_url is None or linkwarden_token is None:
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    links = []
 | 
			
		||||
def get_links():
 | 
			
		||||
    cursor = 0
 | 
			
		||||
    links = []
 | 
			
		||||
 | 
			
		||||
    while True:
 | 
			
		||||
        new_links = get_links(cursor)
 | 
			
		||||
        new_links = get_links_part(cursor)
 | 
			
		||||
        links += new_links
 | 
			
		||||
        if len(new_links):
 | 
			
		||||
            cursor = new_links[-1]["id"]
 | 
			
		||||
        else:
 | 
			
		||||
            break
 | 
			
		||||
            return links
 | 
			
		||||
 | 
			
		||||
def format_links(links):
 | 
			
		||||
    formatted_links = []
 | 
			
		||||
    for link in links:
 | 
			
		||||
        url = link.get("url")
 | 
			
		||||
        if not url:
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        title = link.get("name")
 | 
			
		||||
        if not title:
 | 
			
		||||
            title = link.get("description")
 | 
			
		||||
        if not title:
 | 
			
		||||
            title = "<untitled>"
 | 
			
		||||
 | 
			
		||||
        collection = link.get("collection", {}).get("name")
 | 
			
		||||
        if not collection:
 | 
			
		||||
            collection = "<uncategorized>"
 | 
			
		||||
            
 | 
			
		||||
        formatted_links.append(f"{url} {collection}/{title}")
 | 
			
		||||
    return formatted_links
 | 
			
		||||
 | 
			
		||||
def init():
 | 
			
		||||
    if linkwarden_url is None or linkwarden_token is None:
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    links = format_links(get_links())
 | 
			
		||||
 | 
			
		||||
    with open(os.path.expanduser("~/.config/qutebrowser/bookmarks/urls"), "w+") as f:
 | 
			
		||||
        for link in links:
 | 
			
		||||
            url = link.get("url")
 | 
			
		||||
            if not url:
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            title = link.get("name")
 | 
			
		||||
            if not title:
 | 
			
		||||
                title = link.get("description")
 | 
			
		||||
            if not title:
 | 
			
		||||
                title = ""
 | 
			
		||||
 | 
			
		||||
            f.write(url + " " + title + "\n")
 | 
			
		||||
 | 
			
		||||
        f.write("\n".join(links))
 | 
			
		||||
        f.close()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue