home/wm: move myip script to the polybar
This commit is contained in:
parent
6485c3b9fb
commit
be710ef363
5 changed files with 46 additions and 23 deletions
|
@ -8,19 +8,8 @@ let
|
|||
|
||||
themeCfg = config.local.theme;
|
||||
|
||||
exchangerate_unwrapped = pkgs.writeShellScriptBin "exchangerate"
|
||||
(builtins.readFile (pkgs.substituteAll ({ src = ./scripts/exchangerate.sh; } // themeCfg.highlights)));
|
||||
|
||||
exchangerate = pkgs.symlinkJoin {
|
||||
name = "exchangerate";
|
||||
|
||||
paths = [ exchangerate_unwrapped ] ++ (with pkgs; [ curl gnugrep gnused coreutils ]);
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/exchangerate --prefix PATH : @out/bin
|
||||
'';
|
||||
};
|
||||
exchangerate = import ./scripts/exchangerate.nix { inherit themeCfg pkgs; };
|
||||
external_ip = import ./scripts/external_ip.nix { inherit themeCfg pkgs; };
|
||||
in
|
||||
{
|
||||
options.local.polybar = with lib; {
|
||||
|
@ -165,11 +154,10 @@ in
|
|||
|
||||
"module/external_ip" = {
|
||||
type = "custom/script";
|
||||
exec = "${pkgs.myip}/bin/myip";
|
||||
exec = "${external_ip}/bin/myip";
|
||||
interval = 60;
|
||||
format = {
|
||||
inherit padding;
|
||||
foreground = themeCfg.highlights.success;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
17
home/modules/window_manager/scripts/exchangerate.nix
Normal file
17
home/modules/window_manager/scripts/exchangerate.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ themeCfg, pkgs }:
|
||||
|
||||
let
|
||||
exchangerate_unwrapped = pkgs.writeShellScriptBin "exchangerate"
|
||||
(builtins.readFile (pkgs.substituteAll ({ src = ./exchangerate.sh; } // themeCfg.highlights)));
|
||||
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "exchangerate";
|
||||
|
||||
paths = [ exchangerate_unwrapped ] ++ (with pkgs; [ curl gnugrep gnused coreutils ]);
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/exchangerate --prefix PATH : @out/bin
|
||||
'';
|
||||
}
|
15
home/modules/window_manager/scripts/external_ip.nix
Normal file
15
home/modules/window_manager/scripts/external_ip.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ themeCfg, pkgs }:
|
||||
let
|
||||
external_ip_unwrapped = pkgs.writeShellScriptBin "external_ip"
|
||||
(builtins.readFile (pkgs.substituteAll ({ src = ./external_ip.sh; } // themeCfg.highlights)));
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "external_ip";
|
||||
|
||||
paths = [ external_ip_unwrapped ] ++ (with pkgs; [ bind.dnsutils ]);
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/external_ip --prefix PATH : @out/bin
|
||||
'';
|
||||
}
|
11
home/modules/window_manager/scripts/external_ip.sh
Executable file
11
home/modules/window_manager/scripts/external_ip.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
res=$(dig +timeout=1 +short myip.opendns.com @resolver1.opendns.com 2>/dev/null)
|
||||
if [ -z "$res" ]; then
|
||||
text="NO CONN"
|
||||
echo "%{F@error@}${text}%{F-}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "%{F@success@}${res}%{F-}"
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{ bind, writeShellApplication }:
|
||||
|
||||
writeShellApplication {
|
||||
name = "myip";
|
||||
text = ''
|
||||
${bind.dnsutils}/bin/dig +short myip.opendns.com @resolver1.opendns.com
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue