From f4d47c96946775c9cbcd93e21565ccf01d85c6a3 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Fri, 12 Jul 2024 22:04:09 +0200 Subject: Make waybar more similar to previous polybar config --- tw/gexp.scm | 9 ++++---- tw/services/desktop.scm | 50 +++++++++++++++++++++++++++----------------- tw/services/files/waybar.css | 10 ++++++--- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/tw/gexp.scm b/tw/gexp.scm index 0770f250..49021ebd 100644 --- a/tw/gexp.scm +++ b/tw/gexp.scm @@ -22,9 +22,10 @@ '#$files))))))) (define-public (json-file name value) + "A file called NAME containing the JSON-serialised VALUE." (computed-file name (with-extensions (list guile-json-4) - #~(begin - (use-modules (json) (srfi srfi-26)) - (call-with-output-file #$output - (cut scm->json '#$value <> #:unicode #t)))))) + #~(call-with-output-file #$output + (lambda (port) + (set-port-encoding! port "UTF-8") + ((@ (json) scm->json) '#$value port #:unicode #t)))))) diff --git a/tw/services/desktop.scm b/tw/services/desktop.scm index a602fdf3..4e73bb56 100644 --- a/tw/services/desktop.scm +++ b/tw/services/desktop.scm @@ -429,31 +429,40 @@ display.")) `((reload_style_on_change . #t) (layer . "top") ; put top bar above other windows' shadows - (modules-left . #("sway/mode" "sway/workspaces" "sway/window")) + (modules-left . #("sway/mode" "sway/workspaces" "custom/separator" + "sway/window")) (modules-center . #()) - (modules-right . #("network" "memory" "cpu" "temperature" - "keyboard-state" "privacy" "pulseaudio" "battery" - "clock" "custom/dunst" "tray")) + (modules-right . #("network" "custom/separator" + "memory" "custom/separator" + "cpu" "custom/separator" + "temperature" "custom/separator" + "pulseaudio" "custom/separator" + "battery" "custom/separator" + "clock" "custom/dunst" "custom/separator" + "tray")) + + (custom/separator (format . "ยท") (interval . "once") (tooltip . #f)) (sway/workspaces (all-outputs . #t) (format . "{name}")) (sway/window (max-length . 80) (icon . #t) (icon-size . 16)) (network (interval . 10) - (icons . #("๐Ÿ“ถ" - "๐Ÿ“ถ" - "๐Ÿ“ถ")) (format . "{ifname}") - (format-ethernet . "๐ŸŒ โ†“ {bandwidthDownBytes} โ†‘ {bandwidthUpBytes}") - (format-wifi . "{icon} {essid} โ†“ {bandwidthDownBytes} โ†‘ {bandwidthUpBytes}") + (format-ethernet . "๐ŸŒ โ‡… {bandwidthTotalBytes}") + (format-wifi . "{icon} {essid} โ‡… {bandwidthTotalBytes}") + (format-icons . #("๐Ÿ“ถ" + "๐Ÿ“ถ" + "๐Ÿ“ถ")) (tooltip-format . "{ifname}") (tooltip-format-wifi . "{ifname}: {ipaddr} ({signalStrength}%, {frequency}GHz)") - (tooltip-format-ethernet . "{ifname}: {ipaddr} ({bandwidthTotalBytes}B/s)")) + (tooltip-format-ethernet . "{ifname}: {ipaddr} ({bandwidthTotalBytes})")) (cpu (interval . 2) - (format . ,(apply string-append (map (cut format #f "{icon~d}" <>) - (iota num-cores)))) + (format . ,(apply string-append "CPU " + (map (cut format #f "{icon~d}" <>) + (iota num-cores)))) (format-icons . #("โ–" "โ–‚" "โ–ƒ" @@ -463,14 +472,18 @@ display.")) "โ–‡" "โ–ˆ"))) + (temperature + (format . "๐ŸŒก {temperatureC}ยฐC") + (format-critical . "๐ŸŒก {temperatureC}ยฐC")) + (memory (interval . 5) - (format . "RAM {used} GiB")) + (format . "RAM {used} GiB")) (battery (states (medium . 80) (critical . 20)) - (format-discharging . "{icon} {capacity}% {power}W {time}") - (format-charging . "๐Ÿ”Œ {capacity}% {power}W {time}") + (format-discharging . "{icon} {capacity}% {power:.1f}W {time}") + (format-charging . "๐Ÿ”Œ {capacity}% {power:.1f}W {time}") (format-full . "") (format-icons . #("๐Ÿ”‹" "๐Ÿ”‹" @@ -480,8 +493,9 @@ display.")) (pulseaudio (scroll-step . 1) - (format . "{icon} {volume}%") - (format-muted . "๐Ÿ”‡") + (format . "{icon} {volume}%") + (format-bluetooth . "{icon} {volume}%") + (format-muted . "๐Ÿ”‡") (format-icons (default . #("๐Ÿ”ˆ" "๐Ÿ”‰" "๐Ÿ”Š"))) @@ -489,8 +503,6 @@ display.")) (on-click . "volume toggle-mute") (on-click-right . "foot pulsemixer")) - (keyboard-state (capslock . #t)) - (custom/dunst (exec . "echo '{\"alt\": \"'$(dunstctl is-paused)'\"}'") (return-type . "json") diff --git a/tw/services/files/waybar.css b/tw/services/files/waybar.css index c03025fe..0475fde1 100644 --- a/tw/services/files/waybar.css +++ b/tw/services/files/waybar.css @@ -17,11 +17,13 @@ tooltip { label.module { padding: 5px; + margin: 0; background: transparent; border-top: 3px solid transparent; } box.module { margin: 0 5px; /* vertical, then horizontal */ + padding: 0; background: transparent; } @@ -30,9 +32,6 @@ box.module { background: transparent; border-top: 3px solid transparent; } -#workspaces button { - border-top: 3px solid @base; -} #workspaces button.urgent { border-top: 3px solid @yellow; } @@ -75,3 +74,8 @@ box.module { #custom-dunst { border-top: 3px solid @red; } + +#custom-separator { + color: @overlay2; + padding: 5px 3px; +} -- cgit v1.2.3