From 2765fdd6cf4f059048388b47c96564a128107f8f Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Thu, 13 May 2021 23:48:21 +0200 Subject: [PATCH] waybar: update widgets style: add fontawesome as fallback mail: add tooltip with details mediaplayer: add tooltip card: add information about card --- bin/waybar_card.sh | 16 ++++++++++++ bin/{waybar_mail => waybar_mail.sh} | 9 ++++--- bin/waybar_mediaplayer.py | 6 +++++ waybar.d/config | 38 ++++++++++++++++++++--------- waybar.d/config_annoyance | 38 +++++++++++++++++++++-------- waybar.d/style.css | 4 +-- 6 files changed, 84 insertions(+), 27 deletions(-) create mode 100755 bin/waybar_card.sh rename bin/{waybar_mail => waybar_mail.sh} (59%) diff --git a/bin/waybar_card.sh b/bin/waybar_card.sh new file mode 100755 index 0000000..62ab7f4 --- /dev/null +++ b/bin/waybar_card.sh @@ -0,0 +1,16 @@ +#!/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_mail b/bin/waybar_mail.sh similarity index 59% rename from bin/waybar_mail rename to bin/waybar_mail.sh index f616df3..9597a68 100755 --- a/bin/waybar_mail +++ b/bin/waybar_mail.sh @@ -4,15 +4,16 @@ MAILDIR=$HOME/.mail ACCOUNTS=(posteo gmail xkonni) text="" +tooltip="" total=0 for acc in ${ACCOUNTS[@]}; do count=$(notmuch count folder:$acc/Inbox AND tag:unread AND NOT tag:killed) total=$((total+count)) - text+="$count" - [ ! $acc = ${ACCOUNTS[-1]} ] && text+=", " + tooltip+="$acc: $count" + [ ! $acc = ${ACCOUNTS[-1]} ] && tooltip+="\n" done alt=$( [ $total -gt 0 ] && echo "unread" || echo "read" ) -text="$total ($text)" -json="{\"text\": \"$text\", \"class\": \"mail\", \"alt\": \"$alt\"}" +text="$total" +json="{\"text\": \"$text\", \"tooltip\": \"$tooltip\", \"class\": \"mail\", \"alt\": \"$alt\"}" echo $json diff --git a/bin/waybar_mediaplayer.py b/bin/waybar_mediaplayer.py index cf3df4b..42b51e4 100755 --- a/bin/waybar_mediaplayer.py +++ b/bin/waybar_mediaplayer.py @@ -14,7 +14,13 @@ logger = logging.getLogger(__name__) def write_output(text, player): logger.info('Writing output') + m = dict(player.props.metadata) + title = m.get("xesam:title", "unknown") + artist = ",".join(x for x in m.get("xesam:artist")) + album = m.get("xesam:album") + tooltip = f"{artist}\n{title}\n{album}" output = {'text': text, + 'tooltip': tooltip, 'class': 'custom-' + player.props.player_name, 'alt': player.props.player_name} diff --git a/waybar.d/config b/waybar.d/config index 433f7c5..3f90e8a 100644 --- a/waybar.d/config +++ b/waybar.d/config @@ -13,10 +13,13 @@ "modules-center": [ ], "modules-right": [ + "custom/separator#right", + "custom/card", "custom/separator#right", "custom/mail", "custom/separator#right", "pulseaudio", + "custom/separator#right", "custom/media", "custom/separator#right", "network#wl0", @@ -26,8 +29,6 @@ "cpu", "memory", "custom/separator#right", - "backlight", - "custom/separator#right", "battery", "custom/separator#right", "custom/calendar", @@ -55,29 +56,48 @@ "exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null", "on-click": "foot -T float khal interactive" }, + "custom/card": { + "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, + "return-type": "json", + "min-length": 3, + "max-length": 3, + "interval": 10, + "format-icons": { + "available": "", + "missing": "" + }, + "escape": true, + "exec": "$HOME/.config/sway/bin/waybar_card.sh 2> /dev/null" + }, "custom/mail": { "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, "return-type": "json", - "min-length": 15, - "max-length": 15, + "min-length": 5, + "max-length": 5, "interval": 30, "format-icons": { "unread": " ", "read": " " }, "escape": true, - "exec": "$HOME/.config/sway/bin/waybar_mail 2> /dev/null" + "exec": "$HOME/.config/sway/bin/waybar_mail.sh 2> /dev/null" }, "custom/media": { "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, "return-type": "json", "min-length": 30, "max-length": 40, "format-icons": { "chromium": " ", "firefox": " ", - "Plexamp": " ", - "default": "♫ " + "Plexamp": "♫ ", + "default": "♪ " }, "escape": true, "exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null", @@ -103,10 +123,6 @@ }, "on-click": "foot -T float bashtop" }, - "backlight": { - "format": "{icon} {percent:3}%", - "format-icons": [""] - }, "battery": { "bat": "BAT0", "design-capacity": false, diff --git a/waybar.d/config_annoyance b/waybar.d/config_annoyance index 4c8ea4e..4161e72 100644 --- a/waybar.d/config_annoyance +++ b/waybar.d/config_annoyance @@ -13,10 +13,13 @@ "modules-center": [ ], "modules-right": [ + "custom/separator#right", + "custom/card", "custom/separator#right", "custom/mail", "custom/separator#right", "pulseaudio", + "custom/separator#right", "custom/media", "custom/separator#right", "network#en0", @@ -50,36 +53,55 @@ "exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null", "on-click": "foot -T float khal interactive" }, + "custom/card": { + "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, + "return-type": "json", + "min-length": 3, + "max-length": 3, + "interval": 10, + "format-icons": { + "available": "", + "missing": "" + }, + "escape": true, + "exec": "$HOME/.config/sway/bin/waybar_card.sh 2> /dev/null" + }, "custom/mail": { "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, "return-type": "json", - "min-length": 15, - "max-length": 15, + "min-length": 5, + "max-length": 5, "interval": 30, "format-icons": { "unread": " ", "read": " " }, "escape": true, - "exec": "$HOME/.config/sway/bin/waybar_mail 2> /dev/null" + "exec": "$HOME/.config/sway/bin/waybar_mail.sh 2> /dev/null" }, "custom/media": { "format": "{icon} {}", + "tooltip-format": "{}", + "tooltip": true, "return-type": "json", "min-length": 30, "max-length": 40, "format-icons": { "chromium": " ", "firefox": " ", - "Plexamp": " ", - "default": "♫ " + "Plexamp": "♫ ", + "default": "♪ " }, "escape": true, "exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null", "exec-if": "pgrep plexamp" }, "clock": { - "format": "{: %a, %b %d, %H:%M}", + "format": "{: %a, %b %d, %H:%M}", "on-click": "foot -T float khal interactive" }, "cpu": { @@ -98,10 +120,6 @@ }, "on-click": "foot -T float bashtop" }, - "backlight": { - "format": "{icon} {percent:3}%", - "format-icons": [""] - }, "battery": { "bat": "BAT0", "design-capacity": false, diff --git a/waybar.d/style.css b/waybar.d/style.css index ddab16a..a650220 100644 --- a/waybar.d/style.css +++ b/waybar.d/style.css @@ -9,8 +9,8 @@ * { border: none; border-radius: 0; - font-family: "Cascadia Code PL Regular"; - font-size: 12px; + font-family: "Cascadia Code PL", "Font Awesome 5 Free"; + font-size: 13px; min-height: 0; }