From 6c50990ed659cd4d347ebac176ec1da71c38667f Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Fri, 3 Jan 2025 13:50:38 +0100 Subject: [PATCH] sway: cleanup, remove old files --- bin/waybar_card.sh | 16 ---- bin/waybar_khal.py | 70 --------------- bin/waybar_mail.py | 54 ----------- waybar.d/config_bslxkos02 | 185 -------------------------------------- 4 files changed, 325 deletions(-) delete mode 100755 bin/waybar_card.sh delete mode 100755 bin/waybar_khal.py delete mode 100755 bin/waybar_mail.py delete mode 100644 waybar.d/config_bslxkos02 diff --git a/bin/waybar_card.sh b/bin/waybar_card.sh deleted file mode 100755 index 8be4c23..0000000 --- a/bin/waybar_card.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -CMD="/usr/bin/gpg --card-status" - - -text="" -tooltip="" -alt="missing" -ret=$($CMD 2> /dev/null) -if [ $? -eq 0 ]; then - tooltip="S/N $(echo $ret | grep -oE 'Serial number[.:0-9 ]*' | grep -oE '[0-9]*')" - alt="available" -fi - -json="{\"text\": \"$text\", \"tooltip\": \"$tooltip\", \"class\": \"card\", \"alt\": \"$alt\"}" -echo $json diff --git a/bin/waybar_khal.py b/bin/waybar_khal.py deleted file mode 100755 index feeff52..0000000 --- a/bin/waybar_khal.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -import subprocess -from datetime import date, datetime, timedelta -import json -from html import escape - -TEXT_MAX_LEN = 40 - -today = date.today().strftime("%Y-%m-%d") -days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Today", - "Tomorrow" ] - -next_week = (date.today() + timedelta(days=10)).strftime("%Y-%m-%d") - -title = subprocess.check_output("khal list --format \"{title}\" now "+next_week, - shell=True).decode("UTF-8").split("\n") -start = subprocess.check_output("khal list --format \"{start}\" now "+next_week, - shell=True).decode("UTF-8").split("\n") -end = subprocess.check_output("khal list --format \"{end}\" now "+next_week, - shell=True).decode("UTF-8").split("\n") - -text = "-" -tooltip = "" -alt = "idle" -for i in range(len(title)): - t = escape(title[i]) - s = escape(start[i]) - e = escape(end[i]) - line = "" - ## header - if len(t) and t.split(",")[0] in days: - line = f"\n{t}" - ## event - else: - t_start = s.split(" ") - t_end = e.split(" ") - ## all day - if len(t_start) == 1 or len(t_end) == 1: - line = f"{t}" - ## start - end - else: - ts_start = datetime.timestamp(datetime.strptime(s, '%Y-%m-%d %H:%M')) - ts_end = datetime.timestamp(datetime.strptime(e, '%Y-%m-%d %H:%M')) - ts_now = datetime.timestamp(datetime.now()) - ## today - if t_start[0] == today: - ## upcoming or ongoing - if ts_now < ts_end: - ## ongoing - if ts_start < ts_now: - if ts_start < ts_now and ts_now < ts_end: - text = f"{t_start[1]}-{t_end[1]} {t}" - alt = "now" - ## upcoming - elif text == "-": - text = f"{t_start[1]}-{t_end[1]} {t}" - alt = "today" - line = f"{t_start[1]} - {t_end[1]}: {t}" - tooltip += f"\n{line}" - - -data = {} - -if len(text) > TEXT_MAX_LEN: - text = f"{text[0:TEXT_MAX_LEN]}…" -data["text"] = text -data["alt"] = alt -data["tooltip"] = tooltip - -print(json.dumps(data)) diff --git a/bin/waybar_mail.py b/bin/waybar_mail.py deleted file mode 100755 index 262d829..0000000 --- a/bin/waybar_mail.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -import json -import subprocess -import re - -ACCOUNTS = ["posteo", "gmail", "xkonni"] -l_acc = max([len(a) for a in ACCOUNTS]) -SERVICES = ["mbsync@ykonni", "muchsync@ykonni"] -l_ser = max([len(s) for s in SERVICES]) - -tooltip="accounts\n" -total = 0 - -for a in ACCOUNTS: - cmd = f"notmuch count folder:{a}/Inbox AND tag:unread AND NOT tag:killed" - ret = subprocess.check_output(cmd, shell=True).decode("UTF-8").replace("\n", "") - count = int(ret) - tooltip += f" - {a:<{l_acc}}: {count}\n" - total += count - -tooltip += "\nservices\n" -for s_name in SERVICES: - cmd = f"/usr/bin/systemctl --user status {s_name}" - ret = "" - s_status = "" - s_time = "" - try: - ret = subprocess.run(cmd, capture_output=True, check=False, shell=True) - except Exception as ex: - print(ex) - pass - - s_status = 0 - for line in ret.stdout.decode("UTF-8").split("\n"): - if "since" in line: - m = re.search("[a-z0-9 ]* ago", line) - if m: - s_time = m.group(0) - if ("Process" in line) or ("Main PID" in line): - m = re.search("status=[0-9]*", line) - if m: - tmp = int(m.group(0).replace("status=", "")) - if not tmp == 0 and not tmp == s_status: - s_status = tmp - - tooltip += f" - {s_name:<{l_ser}}: status={s_status}, {s_time}\n" - -text = f"{total}" -alt = "read" if total == 0 else "unread" - -j = { "alt": alt, "class": "mail", - "text": text, "tooltip": tooltip } -print(json.dumps(j)) - diff --git a/waybar.d/config_bslxkos02 b/waybar.d/config_bslxkos02 deleted file mode 100644 index 1f8863e..0000000 --- a/waybar.d/config_bslxkos02 +++ /dev/null @@ -1,185 +0,0 @@ -// vi: ft=jsonc -// normal #ebdbb2 -// blue #268bd2 -// red #fb4934 -// green #b8bb26 -{ - "layer": "top", - "height": 26, - "modules-left": [ - "sway/workspaces", - "custom/separator#left", - "custom/separator#space" - ], - "modules-center": [ - "custom/separator#right", - "clock", - "custom/separator#center", - "custom/media", - "custom/separator#center", - "pulseaudio", - "custom/separator#left" - ], - "modules-right": [ - "custom/separator#right", - "network#en0", - "network#wl0", - "custom/separator#center", - "cpu", - "custom/separator#center", - "memory", - "custom/separator#center", - "temperature", - "custom/separator#space", - "custom/separator#center", - // "battery", - // "custom/separator#center", - "custom/separator#space", - "tray" - ], - "custom/separator#left": { - "format": "" - }, - "custom/separator#space": { - "format": " " - }, - "custom/separator#center": { - "format": "|" - }, - "custom/separator#right": { - "format": "" - }, - "custom/calendar": { - "format": "{icon} {}", - "tooltip-format": "{}", - "tooltip": true, - "return-type": "json", - "min-length": 25, - "max-length": 40, - "interval": 300, - "format-icons": { - "now": "", - "today": "", - "idle": "" - }, - "escape": false, - "exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null", - "on-click": "foot -T float khal interactive" - }, - "custom/media": { - "format": "{icon} {}", - "tooltip-format": "{}", - "tooltip": true, - "return-type": "json", - "min-length": 10, - "max-length": 30, - "format-icons": { - "chromium": " ", - "firefox": " ", - "Plexamp": "♫ ", - "default": "♪ " - }, - "escape": true, - "exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null" - }, - "clock": { - "format": "{: %H:%M, %b %d }", - // "on-click": "foot -T float khal interactive" - }, - "cpu": { - "format": "{usage:3}%", - "min-length": 6, - "max-length": 10, - "states": { - "warning": 70, - "critical": 90 - }, - "on-click": "foot -T float bashtop" - }, - "memory": { - "format": "{}%", - "min-length": 6, - "max-length": 10, - "states": { - "warning": 70, - "critical": 90 - }, - "on-click": "foot -T float bashtop" - }, - "battery": { - "bat": "BAT0", - "design-capacity": false, - "states": { - "warning": 30, - "critical": 15 - }, - "format": "{icon}{capacity:3}%", - "format-charging": "{capacity:3}%", - "format-icons": ["", "", "", "", ""] - }, - "temperature": { - "thermal-zone": 2, - "critical-threshold": 60, - "format-icons": ["", ""], - "format": "{icon}{temperatureC:3}°C" - }, - "network#en0": { - "interval": 2, - "interface": "en0", - "format": "{ifname}", - "format-wifi": "{ifname}", - "format-linked": "{ifname}", - "format-disconnected": "{ifname}", - "min-length": 8, - "max-length": 30, - "tooltip-format": "{ifname}\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-ethernet": "{ifname}\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-wifi": "{ifname} {essid} ({signalStrength:3}%)\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-disconnected": "{ifname} disconnected", - "on-click": "foot -T float nmtui" - }, - "network#wl0": { - "interval": 2, - "interface": "wl0", - "format": "{ifname}", - "format-wifi": "{ifname}", - "format-linked": "{ifname}", - "format-disconnected": "{ifname}", - "min-length": 8, - "max-length": 30, - "tooltip-format": "{ifname}\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-ethernet": "{ifname}\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-wifi": "{ifname} {essid} ({signalStrength:3}%)\n\t{ipaddr}/{cidr}\n  \t{bandwidthDownBits}\n  \t{bandwidthUpBits}", - "tooltip-format-disconnected": "{ifname} disconnected", - "on-click": "foot -T float nmtui" - }, - "pulseaudio": { - "format": "{icon} {volume}% {format_source}", - "format-muted": "{format_source}", - "format-bluetooth": "{icon} {volume}% {format_source}", - "format-bluetooth-muted": "{icon}{format_source}", - "format-source": "", - "format-source-muted": "", - "format-icons": { - "headphone": "🎧", - "hands-free": "", - "headset": "", - "phone": "", - "portable": "", - "car": "", - "default": ["", "", ""] - }, - "min-length": 7, - "max-length": 12, - "on-click": "$HOME/.config/sway/bin/sway_volume mute", - "on-click-middle": "$HOME/.config/sway/bin/sway_volume source-mute", - "on-click-right": "$HOME/.config/sway/bin/sway_volume gui", - "on-scroll-up": "$HOME/.config/sway/bin/sway_volume increase", - "on-scroll-down": "$HOME/.config/sway/bin/sway_volume decrease-mute" - }, - "tray": { - "padding": 10, - "spacing": 10 - } -} -