mirror of
https://github.com/ItsDrike/nixdots
synced 2024-12-25 19:24:34 +00:00
Add bitcoin script
This commit is contained in:
parent
41cd22ea33
commit
42155645b0
|
@ -3,5 +3,6 @@ _: {
|
||||||
./shared.nix
|
./shared.nix
|
||||||
./desktop.nix
|
./desktop.nix
|
||||||
./wayland.nix
|
./wayland.nix
|
||||||
|
./scripts
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
11
home/packages/cli/scripts/default.nix
Normal file
11
home/packages/cli/scripts/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
|
||||||
|
scriptPkgs = (import ./packages {inherit pkgs;});
|
||||||
|
in {
|
||||||
|
home.packages = with scriptPkgs; [
|
||||||
|
bitcoin
|
||||||
|
];
|
||||||
|
}
|
18
home/packages/cli/scripts/packages/bitcoin.nix
Normal file
18
home/packages/cli/scripts/packages/bitcoin.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{pkgs, ...}:
|
||||||
|
(pkgs.writeShellApplication {
|
||||||
|
name = "bitcoin";
|
||||||
|
runtimeInputs = with pkgs; [coreutils curl jq];
|
||||||
|
text = ''
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR')
|
||||||
|
|
||||||
|
if [ "$BTC_DATA" != "ERR" ]; then
|
||||||
|
BTC_PRICE=$(echo "$BTC_DATA" | jq -r ".bpi.USD.rate_float")
|
||||||
|
BTC_PRICE=$(printf "%.0f" "$BTC_PRICE")
|
||||||
|
echo \$"$BTC_PRICE"
|
||||||
|
else
|
||||||
|
echo "N/A"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
})
|
10
home/packages/cli/scripts/packages/default.nix
Normal file
10
home/packages/cli/scripts/packages/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
packages = {
|
||||||
|
bitcoin = pkgs.callPackage ./bitcoin.nix {};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
packages
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(defwidget bitcoin_module []
|
(defwidget bitcoin_module []
|
||||||
(eventbox
|
(eventbox
|
||||||
:onclick "~/.local/bin/scripts/cli/bitcoin | xargs -I_ ${EWW_CMD} update bitcoin=_"
|
:onclick "bitcoin | xargs -I_ ${EWW_CMD} update bitcoin=_"
|
||||||
:class "module bitcoin"
|
:class "module bitcoin"
|
||||||
|
|
||||||
(box
|
(box
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
(defpoll bitcoin
|
(defpoll bitcoin
|
||||||
:interval "5m"
|
:interval "5m"
|
||||||
:initial "$N/A"
|
:initial "$N/A"
|
||||||
`~/.local/bin/scripts/cli/bitcoin`)
|
`bitcoin`)
|
||||||
|
|
||||||
; TODO: Figure out how to store this one-time
|
; TODO: Figure out how to store this one-time
|
||||||
(defpoll kernel
|
(defpoll kernel
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
|
scriptPkgs = (import ../../../../packages/cli/scripts/packages {inherit pkgs;});
|
||||||
|
|
||||||
cfg = osConfig.myOptions.home-manager.programs.bars.eww;
|
cfg = osConfig.myOptions.home-manager.programs.bars.eww;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -36,6 +38,7 @@ in {
|
||||||
wireplumber
|
wireplumber
|
||||||
pulseaudio
|
pulseaudio
|
||||||
hyprland
|
hyprland
|
||||||
|
scriptPkgs.bitcoin
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
Unit = {
|
Unit = {
|
||||||
|
|
Loading…
Reference in a new issue