From 1333078a48f5e326974e5a96eb1d1566071baf37 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 28 Aug 2022 17:20:22 +0300 Subject: [PATCH] home/polybar: add exchangerate module --- home/ui/bar/polybar/config.nix | 13 ++++++++++++- scripts/exchangerate.sh | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/home/ui/bar/polybar/config.nix b/home/ui/bar/polybar/config.nix index 08ade6f..ffd8b07 100644 --- a/home/ui/bar/polybar/config.nix +++ b/home/ui/bar/polybar/config.nix @@ -15,7 +15,7 @@ with lib; modules = { left = "xmonad"; center = "date wifi"; - right = "volume lang time"; + right = "exchangerate volume lang time"; }; }; @@ -76,6 +76,17 @@ with lib; tail = true; }; + "module/exchangerate" = { + type = "custom/script"; + exec = "~/scripts/exchangerate.sh"; + interval = 60; + format = { + prefix = "USD: "; + padding = 1; + }; + + }; + "global/wm" = { margin = { bottom = 0; diff --git a/scripts/exchangerate.sh b/scripts/exchangerate.sh index 06ac57f..bb2002c 100755 --- a/scripts/exchangerate.sh +++ b/scripts/exchangerate.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e @@ -24,6 +24,9 @@ curl_exchangerate () { sed -e "s#<\/\?\w\+>##g" } +# bar_name=xmobar +bar_name=polybar + cc=($(curl_cbr)) diff=$(echo ${cc[-1]} ${cc[-2]} | awk '{ print $1 - $2 }') @@ -35,7 +38,15 @@ if [ ${diff:0:1} == '-' ]; then color='#ff5555' fi -echo "${cc[-1]} (${arror}${diff})" +case $bar_name in + "xmobar") + echo "${cc[-1]} (${arror}${diff})" + ;; + + "polybar") + echo "${cc[-1]} (%{F${color}}${arror}%{O3}${diff}%{F-})" + ;; +esac exit 0