diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-01-26 16:09:30 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-01-27 13:33:20 +0100 |
commit | f4b04127fc1bd4dbdda28f81bc137c50635d5be7 (patch) | |
tree | 9d6ee9454ab3d33fdaf4e35632dd080858cd45c7 /modules | |
parent | ef566bb5c4fb9443b32bb65eaa5ddded0c25326a (diff) |
modules/i3: Allow to set a network timeout.
For the primary network interface that is going to be displayed in the status bar, it's a good idea to have a timeout value. I'm sitting in the train right now and it's annoying to *not* have a working status bar. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/i3/conky.nix | 12 | ||||
-rw-r--r-- | modules/i3/default.nix | 9 |
2 files changed, 19 insertions, 2 deletions
diff --git a/modules/i3/conky.nix b/modules/i3/conky.nix index 90116cbf..77a63ea5 100644 --- a/modules/i3/conky.nix +++ b/modules/i3/conky.nix @@ -1,4 +1,4 @@ -{ pkgs ? import <nixpkgs> {} }: +{ pkgs ? import <nixpkgs> {}, timeout ? 300 }: with pkgs.lib; @@ -20,7 +20,8 @@ let TEXT ''; - cexpr = name: args: "\\\${${name} ${concatStringsSep " " args}}"; + optexpr = name: expr: "\${${name}_disabled:-\\\${${name} ${expr}\\}}"; + cexpr = name: args: "${optexpr name (concatStringsSep " " args)}"; mkNetInfo = iface: let upspeed = cexpr "upspeed" [ iface ]; @@ -71,10 +72,17 @@ let echo $(cputemp_collect) } + tries=0 while ! raw_netinfo="$(${ "${pkgs.iproute}/sbin/ip route get 8.8.8.8 2> /dev/null" })"; do + if [ $tries -ge ${toString timeout} ]; then + upspeed_disabled=N/A + downspeed_disabled=N/A + break + fi echo "Waiting for primary network interface to become available..." + tries=$(($tries + 1)) sleep 1 done diff --git a/modules/i3/default.nix b/modules/i3/default.nix index 7e2795d9..bca88cca 100644 --- a/modules/i3/default.nix +++ b/modules/i3/default.nix @@ -37,6 +37,7 @@ let conky = import ./conky.nix { inherit pkgs; + timeout = config.vuizvui.i3.networkTimeout; }; mkBar = output: statusCmd: singleton '' @@ -90,6 +91,14 @@ in the left head. ''; }; + + networkTimeout = mkOption { + type = types.int; + default = 300; + description = '' + Maximum number of seconds to wait for network device detection. + ''; + }; }; config.vuizvui.i3.workspaces = defaultWorkspaces; |