From dd6cfb63ad85d0164cbe4ac04f7aea9f6a842f02 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Tue, 28 May 2024 15:27:15 -0500 Subject: feat!: remove unused configs and cleanup paths --- i3blocks/.local/bin/i3blocks-dunst | 38 -------------------- i3blocks/.local/bin/i3blocks-miniflux | 26 -------------- i3blocks/.local/bin/i3blocks-notmuch | 33 ----------------- i3blocks/.local/bin/i3blocks-title | 49 -------------------------- i3blocks/.local/lib/i3blocks/i3blocks-dunst | 38 ++++++++++++++++++++ i3blocks/.local/lib/i3blocks/i3blocks-miniflux | 26 ++++++++++++++ i3blocks/.local/lib/i3blocks/i3blocks-notmuch | 33 +++++++++++++++++ i3blocks/.local/lib/i3blocks/i3blocks-title | 49 ++++++++++++++++++++++++++ 8 files changed, 146 insertions(+), 146 deletions(-) delete mode 100755 i3blocks/.local/bin/i3blocks-dunst delete mode 100755 i3blocks/.local/bin/i3blocks-miniflux delete mode 100755 i3blocks/.local/bin/i3blocks-notmuch delete mode 100755 i3blocks/.local/bin/i3blocks-title create mode 100755 i3blocks/.local/lib/i3blocks/i3blocks-dunst create mode 100755 i3blocks/.local/lib/i3blocks/i3blocks-miniflux create mode 100755 i3blocks/.local/lib/i3blocks/i3blocks-notmuch create mode 100755 i3blocks/.local/lib/i3blocks/i3blocks-title (limited to 'i3blocks') diff --git a/i3blocks/.local/bin/i3blocks-dunst b/i3blocks/.local/bin/i3blocks-dunst deleted file mode 100755 index b21042f..0000000 --- a/i3blocks/.local/bin/i3blocks-dunst +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess - - -def muted(): - """Returns True if Dunst is muted""" - cmd = ["dunstctl", "is-paused"] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) - output = proc.communicate()[0] - return "true" == output.strip().decode("UTF-8") - - -def notif(t): - """Returns notification count""" - cmd = ["dunstctl", "count", t] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) - output = proc.communicate()[0] - return int(output.strip().decode("UTF-8")) - - -button = os.environ.get("BLOCK_BUTTON", None) - -if button == "1": - subprocess.run(["dunstctl", "history-pop"], check=True) -elif button == "3": - subprocess.run(["dunstctl", "set-paused", "toggle"], check=True) - - -if notif("waiting") > 0: - print("\uf1f6") -elif notif("displayed") > 0: - print("\uf0f3") -elif muted(): - print("\uf1f7") -else: - print("\uf0a2") diff --git a/i3blocks/.local/bin/i3blocks-miniflux b/i3blocks/.local/bin/i3blocks-miniflux deleted file mode 100755 index 05224e2..0000000 --- a/i3blocks/.local/bin/i3blocks-miniflux +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 - -import os - -import requests - -ICON = "\U0000f09e" - - -def main(): - url = "https://miniflux.tobyvin.dev/v1/feeds/counters" - headers = {"X-Auth-Token": os.environ.get("MINIFLUX_TOKEN")} - resp = requests.get(url, headers=headers) - count = sum(resp.json().get("unreads").values()) - - print(f" {ICON} {count} \n") - if count > 50: - print(os.environ.get("black")) - print(os.environ.get("red")) - elif count > 0: - print(os.environ.get("black")) - print(os.environ.get("yellow")) - - -if __name__ == "__main__": - main() diff --git a/i3blocks/.local/bin/i3blocks-notmuch b/i3blocks/.local/bin/i3blocks-notmuch deleted file mode 100755 index b25c971..0000000 --- a/i3blocks/.local/bin/i3blocks-notmuch +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - -import notmuch -import os - -ICON = "\U000f01ee" # 󰇮 - - -def main(): - # Workaround for bug in the notmuch module's default config resolution - if os.environ.get("NOTMUCH_CONFIG") is None: - os.environ["NOTMUCH_CONFIG"] = os.path.join( - os.environ.get( - "XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config") - ), - "notmuch", - os.environ.get("NOTMUCH_PROFILE", "default"), - "config", - ) - - count = notmuch.Database().create_query("tag:unread").count_messages() - - print(f" {ICON} {count} \n") - if count > 50: - print(os.environ.get("black")) - print(os.environ.get("red")) - elif count > 0: - print(os.environ.get("black")) - print(os.environ.get("yellow")) - - -if __name__ == "__main__": - main() diff --git a/i3blocks/.local/bin/i3blocks-title b/i3blocks/.local/bin/i3blocks-title deleted file mode 100755 index 9cd6abe..0000000 --- a/i3blocks/.local/bin/i3blocks-title +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 - -import os -from typing import Union - -import i3ipc -from i3ipc import Event -from i3ipc.events import WindowEvent, WorkspaceEvent - - -class Connection(i3ipc.Connection): - def handle( - self, - *events: Union[Event, str], - ): - def wrapped(handler): - for event in events: - self.on(event, handler) - return handler - - return wrapped - - -max_length = int(os.environ.get("max_length", 30)) - - -sway = Connection() - - -@sway.handle( - Event.WINDOW_FOCUS, - Event.WINDOW_TITLE, - Event.WINDOW_NEW, - Event.WINDOW_CLOSE, - Event.WORKSPACE_FOCUS, -) -def on_window_event(sway: i3ipc.Connection, event: WindowEvent | WorkspaceEvent): - focused = sway.get_tree() - while focused is not None and focused.ipc_data["type"] != "con": - focused = focused.find_focused() - - if focused: - print(focused.ipc_data["name"][:max_length], flush=True) - else: - print("", flush=True) - - -if __name__ == "__main__": - sway.main() diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-dunst b/i3blocks/.local/lib/i3blocks/i3blocks-dunst new file mode 100755 index 0000000..b21042f --- /dev/null +++ b/i3blocks/.local/lib/i3blocks/i3blocks-dunst @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import os +import subprocess + + +def muted(): + """Returns True if Dunst is muted""" + cmd = ["dunstctl", "is-paused"] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = proc.communicate()[0] + return "true" == output.strip().decode("UTF-8") + + +def notif(t): + """Returns notification count""" + cmd = ["dunstctl", "count", t] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = proc.communicate()[0] + return int(output.strip().decode("UTF-8")) + + +button = os.environ.get("BLOCK_BUTTON", None) + +if button == "1": + subprocess.run(["dunstctl", "history-pop"], check=True) +elif button == "3": + subprocess.run(["dunstctl", "set-paused", "toggle"], check=True) + + +if notif("waiting") > 0: + print("\uf1f6") +elif notif("displayed") > 0: + print("\uf0f3") +elif muted(): + print("\uf1f7") +else: + print("\uf0a2") diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-miniflux b/i3blocks/.local/lib/i3blocks/i3blocks-miniflux new file mode 100755 index 0000000..05224e2 --- /dev/null +++ b/i3blocks/.local/lib/i3blocks/i3blocks-miniflux @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import os + +import requests + +ICON = "\U0000f09e" + + +def main(): + url = "https://miniflux.tobyvin.dev/v1/feeds/counters" + headers = {"X-Auth-Token": os.environ.get("MINIFLUX_TOKEN")} + resp = requests.get(url, headers=headers) + count = sum(resp.json().get("unreads").values()) + + print(f" {ICON} {count} \n") + if count > 50: + print(os.environ.get("black")) + print(os.environ.get("red")) + elif count > 0: + print(os.environ.get("black")) + print(os.environ.get("yellow")) + + +if __name__ == "__main__": + main() diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-notmuch b/i3blocks/.local/lib/i3blocks/i3blocks-notmuch new file mode 100755 index 0000000..b25c971 --- /dev/null +++ b/i3blocks/.local/lib/i3blocks/i3blocks-notmuch @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import notmuch +import os + +ICON = "\U000f01ee" # 󰇮 + + +def main(): + # Workaround for bug in the notmuch module's default config resolution + if os.environ.get("NOTMUCH_CONFIG") is None: + os.environ["NOTMUCH_CONFIG"] = os.path.join( + os.environ.get( + "XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config") + ), + "notmuch", + os.environ.get("NOTMUCH_PROFILE", "default"), + "config", + ) + + count = notmuch.Database().create_query("tag:unread").count_messages() + + print(f" {ICON} {count} \n") + if count > 50: + print(os.environ.get("black")) + print(os.environ.get("red")) + elif count > 0: + print(os.environ.get("black")) + print(os.environ.get("yellow")) + + +if __name__ == "__main__": + main() diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-title b/i3blocks/.local/lib/i3blocks/i3blocks-title new file mode 100755 index 0000000..9cd6abe --- /dev/null +++ b/i3blocks/.local/lib/i3blocks/i3blocks-title @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import os +from typing import Union + +import i3ipc +from i3ipc import Event +from i3ipc.events import WindowEvent, WorkspaceEvent + + +class Connection(i3ipc.Connection): + def handle( + self, + *events: Union[Event, str], + ): + def wrapped(handler): + for event in events: + self.on(event, handler) + return handler + + return wrapped + + +max_length = int(os.environ.get("max_length", 30)) + + +sway = Connection() + + +@sway.handle( + Event.WINDOW_FOCUS, + Event.WINDOW_TITLE, + Event.WINDOW_NEW, + Event.WINDOW_CLOSE, + Event.WORKSPACE_FOCUS, +) +def on_window_event(sway: i3ipc.Connection, event: WindowEvent | WorkspaceEvent): + focused = sway.get_tree() + while focused is not None and focused.ipc_data["type"] != "con": + focused = focused.find_focused() + + if focused: + print(focused.ipc_data["name"][:max_length], flush=True) + else: + print("", flush=True) + + +if __name__ == "__main__": + sway.main() -- cgit v1.2.3-70-g09d2