From f4b04127fc1bd4dbdda28f81bc137c50635d5be7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 26 Jan 2015 16:09:30 +0100 Subject: 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 --- modules/i3/conky.nix | 12 ++++++++++-- modules/i3/default.nix | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'modules') 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 {} }: +{ pkgs ? import {}, 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; -- cgit 1.4.1