THIS MODULE IS DEPRECATED, AND SUPERSEDED BY THE ticker
MODULE.
Show Bitcoin (₿) value in the modeline.
Place the following in your ~/.stumpwmrc
file:
(load-module "bitcoin")
Then you can use %b
in your mode line
format:
(setf *screen-mode-line-format*
(list "[%n]" ; Groups
"%v" ; Windows
"^>" ; Push right
" | %b" ; Bitcoin
" | %d")) ; Clock
And define some parameters:
(setf bitcoin:*modeline-use-colors* t ; use colors
bitcoin:*threshold* 0.001 ; 0.001 is a 0.1% deviation from average
bitcoin:*time-delay* 30 ; seconds
bitcoin:*decimals* 2 ; number of decimal digits
bitcoin:*local-code* 2 ; formatting code to use
bitcoin:*modeline-gauge* t ; show gauge bar
bitcoin:*gauge-width* 9) ; width of the gauge bar in characters
It gets actual price through API, so needs dexador
and yason
. Also, the price getter is asynchronous with the lparallel
machinery.
(ql:quickload '("dexador" "yason" "lparallel"))
Price format is colorized depending on *modeline-use-colors*
flag. You can customize setting t
or nil
in ~/.stumpwmrc
:
(setf bitcoin:*modeline-use-colors* t) ; use colors
Colors depends on a comparison between actual value and the last values average:
Color | Code | Description |
---|---|---|
Bright yellow | ^B^3* | Price is higher than average |
Red | ^1* | Price is below average |
White | ^7* | Price is similar to average |
Default color | ^** | When modeline-use-colors is nil |
There is a threshold around average, so the increasing or decreasing
color is only applied if *threshold*
is passed, can be customized too:
(setf bitcoin:*threshold* 0.001) ; 0.001 is a 0.1% deviation from average
Last values average is calculated over a 3 hours values list
*values*
, where values are stored on every modeline refresh in a
FIFO fashion.
Connection to *url*
price server is limited by a *time-delay*
interval, in seconds. So connection attempts between interval time
are blocked. Interval can be customized too:
(setf bitcoin:*time-delay* 30) ; seconds
The number of decimal places is set by *decimals*
, when 0
there is
no decimals.
(setf bitcoin:*decimals* 2) ; number of decimal digits
The localization format is set by *local-code*
, when 0
there is no
thousand separator, gives 1234.56
and the *decimals*
parameter
does not work, when 1
the thousand separator is comma
and gives
1,234.56
, when 2
the thousand separator is period
and gives
1.234,56
, and when 3
the thousand separator is space
and gives
1 234,56
. Can be customized too:
(setf bitcoin:*local-code* 2) ; formatting code to use
It is possible to add a gauge bar with the tendency of the actual value
between the low and high in the last 24 hours with *modeline-gauge*
.
The gauge bar width is set by *gauge-width*
.
(setf bitcoin:*modeline-gauge* t) ; show gauge bar
(setf bitcoin:*gauge-width* 9) ; width of the gauge bar in characters
Try to use conditions’ handler-case
machinery to avoid the internet
timeouts or the computer sleeping process, to stuck the modeline.
The truncate
function is used when formatting the values, so some
precission loss is expected.