diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-09-04 23:21:01 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-09-04 23:21:01 -0400 |
commit | db49f683129771d95828b01594c69431a717e8e8 (patch) | |
tree | d2cb1c0b865e4d81ce81f9a3176b8ad93a864950 /home-config/waybar | |
download | dotfiles-guix-db49f683129771d95828b01594c69431a717e8e8.tar.gz dotfiles-guix-db49f683129771d95828b01594c69431a717e8e8.tar.bz2 dotfiles-guix-db49f683129771d95828b01594c69431a717e8e8.zip |
guix
Diffstat (limited to 'home-config/waybar')
-rw-r--r-- | home-config/waybar/config | 87 | ||||
-rwxr-xr-x | home-config/waybar/custom_cmus.lua | 58 | ||||
-rwxr-xr-x | home-config/waybar/custom_newsboat.sh | 12 | ||||
-rw-r--r-- | home-config/waybar/style.css | 148 |
4 files changed, 305 insertions, 0 deletions
diff --git a/home-config/waybar/config b/home-config/waybar/config new file mode 100644 index 0000000..43bf6a4 --- /dev/null +++ b/home-config/waybar/config @@ -0,0 +1,87 @@ +{ + "height": 24, + "spacing": 4, + "modules-left": [ + "sway/workspaces", + "sway/window" + ], + "modules-center": [], + "modules-right": [ + "custom/cmus", + "custom/newsboat", + "cpu", + "memory", + "temperature", + "battery", + "backlight", + "pulseaudio", + "network", + "clock", + "tray" + ], + "sway/workspaces": { + "disable-scroll": true, + "all-outputs": true, + "format": "{name}" + }, + "tray": { + "spacing": 10 + }, + "clock": { + "format": "{:%Y-%m-%d %a %H:%M}" + }, + "cpu": { + "format": " {usage}%", + "tooltip": false + }, + "memory": { + "format": " {}%", + "tooltip": false + }, + "temperature": { + "thermal-zone": 10, + "critical-threshold": 80, + "format": " {temperatureC}°" + }, + "battery": { + "states": { + "warning": 30, + "critical": 15 + }, + "format": " {capacity}%", + "format-charging": " {capacity}%", + "format-plugged": " {capacity}%", + "format-full": " {capacity}%", + "format-warning": " {capacity}%", + "format-critical": " {capacity}%" + }, + "backlight": { + "format": " {percent}%" + }, + "pulseaudio": { + "format": " {volume}%", + "format-bluetooth": " {volume}%", + "format-muted": " muted", + "scroll-step": 1, + "on-click": "pavucontrol", + "ignored-sinks": ["Easy Effects Sink"] + }, + "network": { + "interface": "wlp0s20f3", + "format": " disconnected", + "format-wifi": " {essid}", + "format-ethernet": "< {ipaddr}/{cidr}", + "format-disconnected": " disconnected", + "max-length": 50, + "on-click": "nm-connection-editor", + }, + "custom/cmus": { + "return-type": "json", + "exec": "$HOME/.config/waybar/custom_cmus.lua 2> /dev/null" + }, + "custom/newsboat": { + "format": " {}", + "exec": "$HOME/.config/waybar/custom_newsboat.sh 2> /dev/null", + "on-click": "alacritty -e newsboat -r" + } +} diff --git a/home-config/waybar/custom_cmus.lua b/home-config/waybar/custom_cmus.lua new file mode 100755 index 0000000..d03eb9c --- /dev/null +++ b/home-config/waybar/custom_cmus.lua @@ -0,0 +1,58 @@ +#!/usr/bin/lua + +json = require("dkjson") +posix = require("posix") + +function htmlescape(s) + s = string.gsub(s, "&", "&") + s = string.gsub(s, "<", "<") + s = string.gsub(s, ">", ">") + return s +end + +function timefmt(n) + local s = n % 60 + local m = math.floor(n / 60) + return string.format("%d:%02d", m, s) +end + +function output(text, tooltip) + text = htmlescape(text) + tooltip = htmlescape(tooltip) + print(json.encode{text=text, tooltip=tooltip, class="custom-cmus"}) +end + +function getstat(status, name) + for _, line in ipairs(status) do + if string.match(line, "^" .. name) then + return string.sub(line, string.len(name)+2) + end + end +end + +while true do + local pipe = io.popen("cmus-remote -Q") + local status = {} + for line in pipe:lines() do + table.insert(status, line) + end + local success = pipe:close() + if not success then + output(" Not running", "Not running") + elseif getstat(status, "status") == "stopped" then + output(" Not running", "Not running") + else + local playing = getstat(status, "status") + local symbol = ({playing="", paused=""})[playing] + local title = getstat(status, "tag title") + local artist = getstat(status, "tag artist") + local duration = getstat(status, "duration") + local position = getstat(status, "position") + local text = string.format("%s %s (%s)", symbol, title, timefmt(position)) + local tooltip = string.format("%s - %s (%s / %s)", + artist, title, timefmt(position), timefmt(duration) + ) + output(text, tooltip) + end + posix.sleep(1) +end diff --git a/home-config/waybar/custom_newsboat.sh b/home-config/waybar/custom_newsboat.sh new file mode 100755 index 0000000..1ac8428 --- /dev/null +++ b/home-config/waybar/custom_newsboat.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +while :; do + until newsboat -x reload >/dev/null; do + sleep 1; + done + until unread="$(newsboat -x print-unread)"; do + sleep 1; + done + echo "$unread" | awk '{ print $1 }' + sleep 300 +done diff --git a/home-config/waybar/style.css b/home-config/waybar/style.css new file mode 100644 index 0000000..2c716a4 --- /dev/null +++ b/home-config/waybar/style.css @@ -0,0 +1,148 @@ +* { + font-family: "Fira Mono", "Font Awesome 6 Pro", monospace; + font-size: 13.5px; + transition: none; +} + +/* +#waybar { + background-color: rgba(20, 23, 29, 0.85); + color: #c7c6c3; +} +*/ + +window#waybar { + background-color: rgba(20, 23, 29, 0.85); + color: #c7c6c3; +} + +/* +window#waybar > box { + margin-bottom: 8px; + color: #c7c6c3; + box-shadow: 0px 0px 3px 2px rgba(20, 23, 29, 0.70); +} +*/ + +button { + border: none; + border-radius: 0; +} + +#workspaces button { + padding: 0 5px; + color: #c7c6c3; + background-color: rgba(0, 0, 0, 0); +} + +#workspaces button:hover { + box-shadow: inherit; + text-shadow: inherit; +} + +#workspaces button.focused { + background-color: #789ebf; + color: #14171d; + box-shadow: inherit; + text-shadow: inherit; +} + +#workspaces button.urgent { + background-color: #cc5c5c; + box-shadow: inherit; + text-shadow: inherit; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#scratchpad, +#custom-cmus, +#custom-newsboat, +#mpd { + padding: 0 10px; + border-right: 1px solid #4d4754; + color: #c7c6c3; +} + +#tray { + border: none; +} + +#window { + padding: 0 10px; + border-left: 1px solid #4d4754; + color: #c7c6c3; +} + +#window, +#workspaces { + margin: 0 4px; +} + + +#battery { + color: #97bd5e; +} + +#battery.warning:not(.charging) { + color: #f0c767; +} + +#battery.critical:not(.charging) { + color: #cc5c5c; +} + +#network.disconnected, #pulseaudio.muted { + color: #cc5c5c; +} + +#network.wifi { + color: #789ebf; +} + +#pulseaudio { + color: #E0DB5F; +} + +#backlight { + color: #E05F91; +} + +#cpu { + color: #789ebf; +} + +#memory { + color: #a97fb3; +} + +#temperature { + color: #97bd5e; +} + +#temperature.critical { + color: #cc5c5c; +} + +#custom-newsboat { + color: #de7e54; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; +} |