From 7df4667af8324d0ff83021d87aa1e4b1f2dc5e3c Mon Sep 17 00:00:00 2001 From: lelgenio Date: Sat, 10 Oct 2020 03:35:37 -0300 Subject: [PATCH] add bling to waybar --- dotfiles/waybar/style.css | 17 ++++++++++++----- funcs.py | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/dotfiles/waybar/style.css b/dotfiles/waybar/style.css index 8e47116..f785328 100644 --- a/dotfiles/waybar/style.css +++ b/dotfiles/waybar/style.css @@ -1,3 +1,4 @@ +{%@@ set bg_rgb = hex2rgb(color.bg) @@%} * { font: 14px {{@@ font.interface @@}}, Font Awesome, Fira Code Nerd Font; border-radius:0; @@ -6,10 +7,14 @@ transition-duration:0; } +window#waybar.empty * { + color: {{@@ color.txt @@}}; +} + window#waybar { /* background-color: rgba(30,30,30,.9); */ - opacity: 0.9; - background-color: {{@@ color.bg @@}}; + transition-duration: .5s; + background-color: rgba({{@@ bg_rgb @@}}, .9); {%@@ if bar_pos == "top" @@%} border-bottom: {%@@ else @@%} @@ -19,13 +24,15 @@ window#waybar { } window#waybar.solo { - opacity: 1; background-color: {{@@ color.bg @@}}; } window#waybar.empty { - opacity: .5; - background-color: {{@@ color.bg @@}}; + {%@@ if color.type == "dark" @@%} + background-color: transparent; + {%@@ else @@%} + background-color: rgba({{@@ bg_rgb @@}}, 0.3); + {%@@ endif @@%} border:none; } diff --git a/funcs.py b/funcs.py index 1af0f99..789ca77 100644 --- a/funcs.py +++ b/funcs.py @@ -14,3 +14,20 @@ def ordered_path(): newPATH.append(i) return ':'.join(newPATH) + + +def hex2rgb(e): + assert e.startswith("#") + e = e.strip("#").lower() + assert len(e) == 6 + for i in e: + assert (i in "0123456789abcdef") + + def h2r(i): + return str(eval('0x{}'.format(i))) + + r = e[0:2] + g = e[2:4] + b = e[4:6] + + return ", ".join([h2r(i) for i in (r, g, b)])