From 264eec4c48c1b4ae3f0f661ddde126b2466d3cb8 Mon Sep 17 00:00:00 2001 From: cho Date: Sun, 18 Jun 2023 20:55:44 +0700 Subject: [PATCH] add notifications and emacs-status widget --- home/default/.config/waybar/config | 20 ++++++++++++++----- .../.config/waybar/scripts/emacs-status.sh | 7 +++++++ .../.config/waybar/scripts/notifications.sh | 6 ++++++ home/default/.config/waybar/style.css | 4 +++- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 home/default/.config/waybar/scripts/emacs-status.sh create mode 100755 home/default/.config/waybar/scripts/notifications.sh diff --git a/home/default/.config/waybar/config b/home/default/.config/waybar/config index b4d8ef9..d627a4d 100644 --- a/home/default/.config/waybar/config +++ b/home/default/.config/waybar/config @@ -6,7 +6,7 @@ // Choose the order of the modules "modules-left": ["sway/workspaces", "sway/mode", "custom/media"], "modules-center": [], - "modules-right": ["idle_inhibitor", "mpd", "pulseaudio", "bluetooth", "network", "cpu", "memory", "temperature", "battery", "clock", "tray"], + "modules-right": ["idle_inhibitor", "mpd", "pulseaudio", "network", "cpu", "memory", "temperature", "battery", "tray", "clock", "custom/swaync", "custom/emacsstatus"], "sway/workspaces": { "disable-scroll-wraparound": true }, @@ -52,7 +52,8 @@ "clock": { // "timezone": "America/New_York", "tooltip-format": "{:%Y %B}\n{calendar}", - "format": "{:%Y-%m-%d %I:%M:%S %p}", + "format": "{:%Y-%m-%d %H:%M:%S}", + //"format": "{:%Y-%m-%d %I:%M:%S %p}", "interval": 1 }, "cpu": { @@ -103,9 +104,9 @@ "on-click": "pavucontrol" }, "mpd": { - "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon} {artist} | {title} | {elapsedTime:%M:%S}/{totalTime:%M:%S}", + "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon} {artist} - {title} | {elapsedTime:%M:%S}/{totalTime:%M:%S}", // "max-length": 200, - "format-disconnected": "Disconnected", + "format-disconnected": "-", "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped", "interval": 2, "consume-icons": { @@ -139,6 +140,15 @@ "escape": true, "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name + }, + "custom/swaync": { + "exec": "~/.config/waybar/scripts/notifications.sh", + "on-click": "swaync-client -t", + "restart-interval": 1 + }, + "custom/emacsstatus": { + "exec": "~/.config/waybar/scripts/emacs-status.sh", + "on-click": "emacsclient -c || emacs", + "restart-interval": 3 } } - diff --git a/home/default/.config/waybar/scripts/emacs-status.sh b/home/default/.config/waybar/scripts/emacs-status.sh new file mode 100755 index 0000000..f912b1e --- /dev/null +++ b/home/default/.config/waybar/scripts/emacs-status.sh @@ -0,0 +1,7 @@ +pgrep emacs >/dev/null +if [ $? -eq 1 ] +then +echo 'X' +else +echo 'e+' +fi diff --git a/home/default/.config/waybar/scripts/notifications.sh b/home/default/.config/waybar/scripts/notifications.sh new file mode 100755 index 0000000..e2ff141 --- /dev/null +++ b/home/default/.config/waybar/scripts/notifications.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +count="$(swaync-client -c)" +none="-" +if [ "$count" == "0" ]; then echo "$none" ; fi +if [ "$count" != "0" ]; then echo "$count" ; fi diff --git a/home/default/.config/waybar/style.css b/home/default/.config/waybar/style.css index 5707b86..e6d274c 100644 --- a/home/default/.config/waybar/style.css +++ b/home/default/.config/waybar/style.css @@ -71,6 +71,8 @@ window#waybar.chromium { #mode, #idle_inhibitor, #bluetooth, +#custom-swaync, +#custom-emacsstatus, #mpd { padding: 0 6px; border-right: 2px solid #424242; @@ -208,7 +210,7 @@ label:focus { } #mpd.disconnected { - background-color: #f53c3c; + /*background-color: #f53c3c;*/ } #mpd.stopped {