aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/i3blocks
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-07-23 02:55:53 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-07-23 02:55:53 -0500
commita73031d24b2a0d74f7fc24470f0415f476270dd6 (patch)
treee3045b70e1fdc92fdd23532417b1ee56ccb2006b /i3blocks
parent062c21e03cebeeeac9437f8d93da5f45770abfb1 (diff)
fix(i3blocks): clean up scripts
Diffstat (limited to 'i3blocks')
-rw-r--r--i3blocks/.config/i3blocks/config14
-rwxr-xr-xi3blocks/.local/lib/i3blocks/i3blocks-mic120
-rwxr-xr-xi3blocks/.local/lib/i3blocks/i3blocks-wttr2
3 files changed, 6 insertions, 130 deletions
diff --git a/i3blocks/.config/i3blocks/config b/i3blocks/.config/i3blocks/config
index 494fe1b..c2207ed 100644
--- a/i3blocks/.config/i3blocks/config
+++ b/i3blocks/.config/i3blocks/config
@@ -1,6 +1,4 @@
-interval=5
-
-[i3blocks-title]
+[i3blocks]
command=$SCRIPT_DIR/i3blocks-title
max_length=30
interval=persist
@@ -15,6 +13,7 @@ interval=30
[notmuch]
command=$SCRIPT_DIR/i3blocks-notmuch
+interval=5
[disk]
command=$SCRIPT_DIR/i3blocks-disk
@@ -22,16 +21,20 @@ interval=20
[memory]
command=$SCRIPT_DIR/i3blocks-memory
+interval=5
[cpu]
command=$SCRIPT_DIR/i3blocks-cpu
+interval=5
format=json
[gpu]
command=$SCRIPT_DIR/i3blocks-gpu
+interval=5
[net]
command=$SCRIPT_DIR/i3blocks-net
+interval=5
[mpris_icon]
command=i3blocks-mpris icon
@@ -63,11 +66,6 @@ command=i3blocks-mpris volume
interval=persist
format=json
-[mic]
-command=$SCRIPT_DIR/i3blocks-mic
-interval=persist
-format=json
-
[volume]
command=$SCRIPT_DIR/i3blocks-volume
interval=persist
diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-mic b/i3blocks/.local/lib/i3blocks/i3blocks-mic
deleted file mode 100755
index b91d55c..0000000
--- a/i3blocks/.local/lib/i3blocks/i3blocks-mic
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python3
-
-import asyncio
-import json
-import os
-import subprocess
-import sys
-from enum import StrEnum
-
-
-class Icon(StrEnum):
- ACTIVE = "\U000f036c" # 󰍬
- MUTE = "\U000f036d" # 󰍭
- IDLE = "\U000f036e" # 󰍮
-
-
-class Color(StrEnum):
- BLACK = f"#{os.environ.get("BASE16_COLOR_00_HEX")}"
- RED = f"#{os.environ.get("BASE16_COLOR_08_HEX")}"
- YELLOW = f"#{os.environ.get("BASE16_COLOR_0A_HEX")}"
- AQUA = f"#{os.environ.get("BASE16_COLOR_0C_HEX")}"
-
-
-def print_status():
- name = subprocess.run(
- ["pactl", "get-default-source"],
- capture_output=True,
- encoding="UTF-8",
- ).stdout.strip()
-
- stdout = subprocess.run(
- ["pactl", "--format=json", "list", "sources"],
- capture_output=True,
- encoding="UTF-8",
- ).stdout.strip()
-
- source = next(filter(lambda s: s["name"] == name, json.loads(stdout)), None)
-
- match source:
- case None | {"state": "SUSPENDED"}:
- output = {}
- case {"mute": True}:
- output = {
- "full_text": f" {Icon.MUTE} ",
- "color": Color.BLACK,
- "background": Color.YELLOW,
- }
- case {"state": "RUNNING"}:
- output = {"full_text": f" {Icon.ACTIVE} "}
- case {"state": "IDLE"}:
- output = {"full_text": f" {Icon.IDLE} "}
-
- print(json.dumps(output, ensure_ascii=False), flush=True)
-
-
-async def listener():
- process = await asyncio.create_subprocess_exec(
- "pactl",
- "--format=json",
- "subscribe",
- stdout=asyncio.subprocess.PIPE,
- )
-
- while True:
- line = await process.stdout.readline()
-
- if not line:
- await asyncio.sleep(1)
- continue
-
- match json.loads(line.decode("UTF-8")):
- case (
- {"event": "change", "on": "server"}
- | {"event": "change", "on": "source"}
- | {"event": "new", "on": "source-output"}
- | {"event": "remove", "on": "source-output"}
- ):
- print_status()
-
-
-async def button_handler():
- loop = asyncio.get_event_loop()
- reader = asyncio.StreamReader()
- protocol = asyncio.StreamReaderProtocol(reader)
- await loop.connect_read_pipe(lambda: protocol, sys.stdin)
-
- while True:
- line = await reader.readline()
-
- if not line:
- await asyncio.sleep(1)
- continue
-
- match json.loads(line):
- case {"button": 1}:
- pass
- case {"button": 2}:
- pass
- case {"button": 3}:
- subprocess.run(
- ["wpctl", "set-mute", "@DEFAULT_AUDIO_SOURCE@", "toggle"]
- )
- case {"button": 4}:
- pass
- case {"button": 5}:
- pass
-
-
-async def main():
- print_status()
- try:
- async with asyncio.TaskGroup() as task_group:
- task_group.create_task(listener())
- task_group.create_task(button_handler())
- except asyncio.CancelledError:
- return
-
-
-if __name__ == "__main__":
- asyncio.run(main())
diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-wttr b/i3blocks/.local/lib/i3blocks/i3blocks-wttr
index 1151a43..8ae4857 100755
--- a/i3blocks/.local/lib/i3blocks/i3blocks-wttr
+++ b/i3blocks/.local/lib/i3blocks/i3blocks-wttr
@@ -1,7 +1,5 @@
#!/usr/bin/env python3
-import os
-import subprocess
import time
import requests