From fd245c77582ccf758c71ab0612b3710a74d28a8a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 01:01:59 +0200 Subject: [PATCH] Add a script for easy linking to articles on my page --- home/.local/bin/scripts/dmenu/website-link | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 home/.local/bin/scripts/dmenu/website-link diff --git a/home/.local/bin/scripts/dmenu/website-link b/home/.local/bin/scripts/dmenu/website-link new file mode 100755 index 0000000..c7a525f --- /dev/null +++ b/home/.local/bin/scripts/dmenu/website-link @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import feedparser +import subprocess + + +URL = "https://itsdrike.com/posts/index.xml" + + +def main(): + feed = feedparser.parse(URL) + titles = {entry['title']: entry['link'] for entry in feed['entries']} + + selected_page = subprocess.check_output( + ["dmenu", "-i", "-p", "Post"], + input="\n".join(titles.keys()), universal_newlines=True + ) + link = titles[selected_page.strip()] + + subprocess.check_output(["xsel", "-bi"], input=link, universal_newlines=True) + + +if __name__ == '__main__': + main()