dotfiles/files/bin/website-link

27 lines
719 B
Text
Raw Permalink Normal View History

#!/usr/bin/env python
import json
import subprocess
import urllib.request
from collections import OrderedDict
2023-07-28 14:54:01 +01:00
URL = "https://theorangeone.net/api/page-links/?format=json"
def main():
with urllib.request.urlopen(URL) as response:
data = json.load(response)
url_mapping = OrderedDict([
2023-07-28 14:54:01 +01:00
(d['title'], d['full_url'])
for d in data
])
2021-09-19 16:40:50 +01:00
selected_page = subprocess.check_output(["rofi", "-dmenu", "-i", "-format", "s", "-p", "Post"], input="\n".join(url_mapping.keys()), universal_newlines=True)
selected_page = selected_page.strip()
subprocess.check_output(['xsel', '-bi'], input=url_mapping[selected_page], universal_newlines=True)
if __name__ == '__main__':
main()