From ea303cfd559599463eab912277faed072ba82a0f Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 6 Mar 2017 12:45:56 +0100 Subject: tv q: respect terminal width when printing calenders --- tv/5pkgs/q/default.nix | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'tv') diff --git a/tv/5pkgs/q/default.nix b/tv/5pkgs/q/default.nix index a3a7cd739..2e7aa5cf2 100644 --- a/tv/5pkgs/q/default.nix +++ b/tv/5pkgs/q/default.nix @@ -1,7 +1,19 @@ { pkgs, ... }: +with import ; let q-cal = let - # XXX 23 is the longest line of cal's output + + # Maximum width of cal's output. + calwidth = 23; + + # Number of space characters between two calendars. + hspace = 2; + + # Return number of columns required to print n calenders side by side. + need_width = n: + assert n >= 1; + n * calwidth + (n - 1) * hspace; + pad = ''{ ${pkgs.gnused}/bin/sed ' # rtrim @@ -10,7 +22,7 @@ let # delete last empty line ''${/^$/d} ' \ - | ${pkgs.gawk}/bin/awk '{printf "%-23s\n", $0}' \ + | ${pkgs.gawk}/bin/awk '{printf "%-${toString calwidth}s\n", $0}' \ | ${pkgs.gnused}/bin/sed ' # colorize header 1,2s/.*/&/ @@ -20,23 +32,31 @@ let ' }''; in '' + cols=$(${pkgs.ncurses}/bin/tput cols) ${pkgs.coreutils}/bin/paste \ - <(${pkgs.utillinux}/bin/cal -mw \ + <(if test $cols -ge ${toString (need_width 3)}; then + ${pkgs.utillinux}/bin/cal -mw \ $(${pkgs.coreutils}/bin/date +'%m %Y' -d 'last month') \ | ${pad} - ) \ - <(${pkgs.utillinux}/bin/cal -mw \ + fi) \ + <(if test $cols -ge ${toString (need_width 1)}; then + ${pkgs.utillinux}/bin/cal -mw \ | ${pkgs.gnused}/bin/sed ' # colorize day of month s/\(^\| \)'"$(${pkgs.coreutils}/bin/date +%e)"'\>/&/ ' \ | ${pad} - ) \ - <(${pkgs.utillinux}/bin/cal -mw \ + fi) \ + <(if test $cols -ge ${toString (need_width 2)}; then + ${pkgs.utillinux}/bin/cal -mw \ $(${pkgs.coreutils}/bin/date +'%m %Y' -d 'next month') \ | ${pad} - ) \ - | ${pkgs.gnused}/bin/sed 's/\t/ /g' + fi) \ + | ${pkgs.gnused}/bin/sed ' + s/^\t// + s/\t$// + s/\t/${lpad hspace " " ""}/g + ' ''; q-isodate = '' -- cgit v1.2.3 From 0953240b832117aef4d2ee3cc9cb1ff0e606242e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 6 Mar 2017 13:11:21 +0100 Subject: tv pulse: talk about hijacking audio devices --- tv/2configs/pulse.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tv') diff --git a/tv/2configs/pulse.nix b/tv/2configs/pulse.nix index 2a3b5cbc1..418551213 100644 --- a/tv/2configs/pulse.nix +++ b/tv/2configs/pulse.nix @@ -76,6 +76,9 @@ in }; }; + # TODO assert that pulse is the only user with "audio" in group/extraGroups + # otherwise the audio device can be hijacked while the pulse service restarts + # (e.g. when mpv is running) and then the service will fail. users = { groups.pulse.gid = config.users.users.pulse.uid; users.pulse = { -- cgit v1.2.3 From c05db2409061f721ba454f4bf79e635ee13a6f11 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 7 Mar 2017 15:32:31 +0100 Subject: Revert "cd: hart eingeCACt" This reverts commit 3607bd0832d0f47a4bf56cae7e4cb14f6e257bc9. --- tv/1systems/cd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tv') diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index b718d19b8..108006f34 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -16,11 +16,11 @@ with import ; networking = { interfaces.enp2s1.ip4 = singleton { address = let - addr = "64.137.177.226"; + addr = "45.62.237.203"; in assert config.krebs.build.host.nets.internet.ip4.addr == addr; addr; prefixLength = 24; }; - defaultGateway = "64.137.177.1"; + defaultGateway = "45.62.237.1"; nameservers = ["8.8.8.8"]; }; -- cgit v1.2.3