home/polybar: add exchangerate module

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-28 17:20:22 +03:00
parent 8b18f554ca
commit 1333078a48
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
2 changed files with 25 additions and 3 deletions

View file

@ -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;

View file

@ -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]} (<fc=${color}>${arror}<hspace=3/>${diff}</fc>)"
case $bar_name in
"xmobar")
echo "${cc[-1]} (<fc=${color}>${arror}<hspace=3/>${diff}</fc>)"
;;
"polybar")
echo "${cc[-1]} (%{F${color}}${arror}%{O3}${diff}%{F-})"
;;
esac
exit 0