Add bitcoin widget

This commit is contained in:
ItsDrike 2021-08-24 17:25:09 +02:00
parent 742f8f6382
commit ac3fd001aa
No known key found for this signature in database
GPG key ID: B5F6B41F708C3ADD
4 changed files with 66 additions and 34 deletions

View file

@ -44,16 +44,16 @@ commands = [
-- Battery information. This is likely to require some customization
-- based upon your specific hardware. Or, for a desktop you may want
-- to just remove this section entirely.
Run Battery [
"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
"--",
"-i", "<fc=#75c44c>AC</fc>",
"-O", "<fc=#75c44c>AC</fc>",
"-o", "<fc=#ff0000>AUX</fc>",
"-L", "12",
"-h", "green",
"-l", "red"
] 10,
--Run Battery [
--"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
--"--",
--"-i", "<fc=#75c44c>AC</fc>",
--"-O", "<fc=#75c44c>AC</fc>",
--"-o", "<fc=#ff0000>AUX</fc>",
--"-L", "12",
--"-h", "green",
--"-l", "red"
--] 10,
-- Time and date
Run Date "<fn=1>\xf017</fn> %H:%M %b %d %Y" "date" 50,
@ -68,6 +68,9 @@ commands = [
-- Get kernel version from uname -r
Run Com "uname" ["-r"] "" 3600,
-- Get bitcoin price from a custom script
Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300,
-- Add dynamic invisible XPM icon that resizes to accomodate trayer
-- this needs to be an absolute string path, env vars or relpaths aren't accepted
-- this should only be on 1 monitor (single file), so ignore this comment on others
@ -93,14 +96,18 @@ template = "\
\<icon=haskell_20.xpm/> \
\<fc=#666666>|</fc> %UnsafeStdinReader% }{ \
\<fc=#666666>|</fc> <fc=#b3afc2><fn=2></fn> %uname% </fc> \
\<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \
\<fc=#666666>|</fc> <fc=#ecbe7b> %cpu% </fc> \
\<fc=#666666>|</fc> <fc=#ff6c6b> %memory% </fc> \
\<fc=#666666>|</fc> <fc=#51afef> %disku% </fc> \
\<fc=#666666>|</fc> <fc=#efcb10><fn=2></fn> %bitcoin% </fc> \
\<fc=#666666>|</fc> <fc=#98be65> %wlp2s0% </fc> \
\<fc=#666666>|</fc> <fc=#46d9ff> %date% </fc> \
\<fc=#666666>|</fc> %trayerpad%\
\ "
}
-- Abandoned template strings
-- Network Ethernet:
-- \<fc=#666666>|</fc> <fc=#98be65> %enp3s0% </fc> \
-- Battery:
-- \<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \

View file

@ -44,16 +44,16 @@ commands = [
-- Battery information. This is likely to require some customization
-- based upon your specific hardware. Or, for a desktop you may want
-- to just remove this section entirely.
Run Battery [
"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
"--",
"-i", "<fc=#75c44c>AC</fc>",
"-O", "<fc=#75c44c>AC</fc>",
"-o", "<fc=#ff0000>AUX</fc>",
"-L", "12",
"-h", "green",
"-l", "red"
] 10,
--Run Battery [
--"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
--"--",
--"-i", "<fc=#75c44c>AC</fc>",
--"-O", "<fc=#75c44c>AC</fc>",
--"-o", "<fc=#ff0000>AUX</fc>",
--"-L", "12",
--"-h", "green",
--"-l", "red"
--] 10,
-- Time and date
Run Date "<fn=1>\xf017</fn> %H:%M %b %d %Y" "date" 50,
@ -68,6 +68,9 @@ commands = [
-- Get kernel version from uname -r
Run Com "uname" ["-r"] "" 3600,
-- Get bitcoin price from a custom script
Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300,
-- Add dynamic invisible XPM icon that resizes to accomodate trayer
-- this needs to be an absolute string path, env vars or relpaths aren't accepted
-- this should only be on 1 monitor (single file), so ignore this comment on others
@ -93,12 +96,18 @@ template = "\
\<icon=haskell_20.xpm/> \
\<fc=#666666>|</fc> %UnsafeStdinReader% }{ \
\<fc=#666666>|</fc> <fc=#b3afc2><fn=2></fn> %uname% </fc> \
\<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \
\<fc=#666666>|</fc> <fc=#ecbe7b> %cpu% </fc> \
\<fc=#666666>|</fc> <fc=#ff6c6b> %memory% </fc> \
\<fc=#666666>|</fc> <fc=#51afef> %disku% </fc> \
\<fc=#666666>|</fc> <fc=#efcb10><fn=2></fn> %bitcoin% </fc> \
\<fc=#666666>|</fc> <fc=#98be65> %wlp2s0% </fc> \
\<fc=#666666>|</fc> <fc=#46d9ff> %date% </fc> \
\<fc=#666666>|</fc> %trayerpad%\
\ "
}
-- Abandoned template strings
-- Network Ethernet:
-- \<fc=#666666>|</fc> <fc=#98be65> %enp3s0% </fc> \
-- Battery:
-- \<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \

View file

@ -44,16 +44,16 @@ commands = [
-- Battery information. This is likely to require some customization
-- based upon your specific hardware. Or, for a desktop you may want
-- to just remove this section entirely.
Run Battery [
"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
"--",
"-i", "<fc=#75c44c>AC</fc>",
"-O", "<fc=#75c44c>AC</fc>",
"-o", "<fc=#ff0000>AUX</fc>",
"-L", "12",
"-h", "green",
"-l", "red"
] 10,
--Run Battery [
--"-t", "<fn=1>\xf240</fn> <acstatus> <left>% - <timeleft>",
--"--",
--"-i", "<fc=#75c44c>AC</fc>",
--"-O", "<fc=#75c44c>AC</fc>",
--"-o", "<fc=#ff0000>AUX</fc>",
--"-L", "12",
--"-h", "green",
--"-l", "red"
--] 10,
-- Time and date
Run Date "<fn=1>\xf017</fn> %H:%M %b %d %Y" "date" 50,
@ -68,6 +68,9 @@ commands = [
-- Get kernel version from uname -r
Run Com "uname" ["-r"] "" 3600,
-- Get bitcoin price from a custom script
Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300,
-- Add dynamic invisible XPM icon that resizes to accomodate trayer
-- this needs to be an absolute string path, env vars or relpaths aren't accepted
-- this should only be on 1 monitor (single file), so ignore this comment on others
@ -92,11 +95,17 @@ template = "\
\<icon=haskell_20.xpm/> \
\<fc=#666666>|</fc> %UnsafeStdinReader% }{ \
\<fc=#666666>|</fc> <fc=#b3afc2><fn=2></fn> %uname% </fc> \
\<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \
\<fc=#666666>|</fc> <fc=#ecbe7b> %cpu% </fc> \
\<fc=#666666>|</fc> <fc=#ff6c6b> %memory% </fc> \
\<fc=#666666>|</fc> <fc=#51afef> %disku% </fc> \
\<fc=#666666>|</fc> <fc=#efcb10><fn=2></fn> %bitcoin% </fc> \
\<fc=#666666>|</fc> <fc=#98be65> %wlp2s0% </fc> \
\<fc=#666666>|</fc> <fc=#46d9ff> %date% </fc> \
\ "
}
-- Abandoned template strings
-- Network Ethernet:
-- \<fc=#666666>|</fc> <fc=#98be65> %enp3s0% </fc> \
-- Battery:
-- \<fc=#666666>|</fc> <fc=#9ce996> %battery% </fc> \

View file

@ -0,0 +1,7 @@
#!/bin/sh
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null)
BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float")
BTC_PRICE=$(printf "%.2f" "$BTC_PRICE")
echo \$"$BTC_PRICE"