From b29f4d00d43a725ef5b660b2e680cb8ec9a78718 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 22 Aug 2021 12:05:21 +0100 Subject: [PATCH] Add script to help easily grab URLs for website posts --- files/bin/website-link | 24 ++++++++++++++++++++++++ files/i3.conf | 1 + 2 files changed, 25 insertions(+) create mode 100755 files/bin/website-link diff --git a/files/bin/website-link b/files/bin/website-link new file mode 100755 index 0000000..f602bae --- /dev/null +++ b/files/bin/website-link @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import json +import subprocess +import urllib.request + +URL = "https://theorangeone.net/index.json" + +def main(): + with urllib.request.urlopen(URL) as response: + data = json.load(response) + + url_mapping = { + d['title']: d['url'] + for d in data + } + + selected_page = subprocess.check_output(["rofi", "-dmenu", "-i", "-format", "s"], 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() diff --git a/files/i3.conf b/files/i3.conf index e961042..232cc6d 100644 --- a/files/i3.conf +++ b/files/i3.conf @@ -59,6 +59,7 @@ bindsym XF86Eject exec --no-startup-id rofi-powermenu bindsym $mod+P exec --no-startup-id rofi-screenlayout bindsym $mod+Shift+c exec --no-startup-id vscode-project-list bindsym $mod+period exec --no-startup-id rofimoji --action type +bindsym $mod+Shift+w exec --no-startup-id website-link # Screenshots