diff options
24 files changed, 239 insertions, 217 deletions
diff --git a/kartei/palo/default.nix b/kartei/palo/default.nix index 4caf41f87..9d35c3808 100644 --- a/kartei/palo/default.nix +++ b/kartei/palo/default.nix @@ -1,5 +1,6 @@ with import ../../lib; -{ config, ... }: let +{ config, ... }: +let hostDefaults = hostName: host: flip recursiveUpdate host ({ ci = false; @@ -13,62 +14,15 @@ with import ../../lib; (krebs.genipv6 "wiregrill" "external" { inherit hostName; }).address; }); -in { +in +{ hosts = mapAttrs hostDefaults { - pepe = { - owner = config.krebs.users.palo; - nets = { - retiolum = { - ip4.addr = "10.243.23.1"; - tinc.port = 720; - aliases = [ "pepe.r" ]; - tinc.pubkey = builtins.readFile ./retiolum.pub; - }; - }; - }; - schasch = { - owner = config.krebs.users.palo; - nets = { - retiolum = { - ip4.addr = "10.243.23.2"; - tinc.port = 720; - aliases = [ "schasch.r" ]; - tinc.pubkey = builtins.readFile ./retiolum.pub; - }; - }; - syncthing.id = "FLY7DHI-TJLEQBJ-JZNC4YV-NBX53Z2-ZBRWADL-BKSFXYZ-L4FMDVH-MOSEVAQ"; - }; sterni = { owner = config.krebs.users.palo; nets = { retiolum = { - ip4.addr = "10.243.23.3"; - tinc.port = 720; - aliases = [ - "sterni.r" - ]; - tinc.pubkey = builtins.readFile ./retiolum.pub; - }; - }; - }; - workhorse = { - owner = config.krebs.users.palo; - nets = { - retiolum = { - ip4.addr = "10.243.23.5"; - tinc.port = 720; - aliases = [ "workhorse.r" ]; - tinc.pubkey = builtins.readFile ./retiolum.pub; - }; - }; - }; - workout = { - owner = config.krebs.users.palo; - nets = { - retiolum = { - ip4.addr = "10.243.23.4"; tinc.port = 720; - aliases = [ "workout.r" ]; + aliases = [ "sterni.r" ]; tinc.pubkey = builtins.readFile ./retiolum.pub; }; }; diff --git a/kartei/tv/wiregrill/ru.pub b/kartei/tv/wiregrill/ru.pub new file mode 100644 index 000000000..4a997c968 --- /dev/null +++ b/kartei/tv/wiregrill/ru.pub @@ -0,0 +1 @@ ++3GdhwFYmBr46bBwyqrY3UH9fU1b8c2Vqmx9JTY4syU= diff --git a/krebs/3modules/tinc.nix b/krebs/3modules/tinc.nix index f6727e4d4..52cdafe67 100644 --- a/krebs/3modules/tinc.nix +++ b/krebs/3modules/tinc.nix @@ -26,10 +26,7 @@ with import <stockholm/lib>; Port = ${toString tinc.config.host.nets.${netname}.tinc.port} ${tinc.config.extraConfig} ''; - "tinc-up" = pkgs.writeDash "${netname}-tinc-up" '' - ${tinc.config.iproutePackage}/sbin/ip link set ${netname} up - ${tinc.config.tincUp} - ''; + "tinc-up" = pkgs.writeDash "${netname}-tinc-up" tinc.config.tincUp; }); }; @@ -60,7 +57,8 @@ with import <stockholm/lib>; default = let net = tinc.config.host.nets.${netname}; iproute = tinc.config.iproutePackage; - in '' + in /* sh */ '' + ${tinc.config.iproutePackage}/sbin/ip link set ${netname} up ${optionalString (net.ip4 != null) /* sh */ '' ${iproute}/sbin/ip -4 addr add ${net.ip4.addr} dev ${netname} ${iproute}/sbin/ip -4 route add ${net.ip4.prefix} dev ${netname} @@ -69,14 +67,13 @@ with import <stockholm/lib>; ${iproute}/sbin/ip -6 addr add ${net.ip6.addr} dev ${netname} ${iproute}/sbin/ip -6 route add ${net.ip6.prefix} dev ${netname} ''} - ${tinc.config.tincUpExtra} ''; - defaultText = '' - ip -4 addr add ‹net.ip4.addr› dev ${netname} - ip -4 route add ‹net.ip4.prefix› dev ${netname} - ip -6 addr add ‹net.ip6.addr› dev ${netname} - ip -6 route add ‹net.ip6.prefix› dev ${netname} - ${tinc.config.tincUpExtra} + defaultText = /* sh */ '' + ip link set ‹netname› up + ip -4 addr add ‹net.ip4.addr› dev ‹netname› + ip -4 route add ‹net.ip4.prefix› dev ‹netname› + ip -6 addr add ‹net.ip6.addr› dev ‹netname› + ip -6 route add ‹net.ip6.prefix› dev ‹netname› ''; description = '' tinc-up script to be used. Defaults to setting the @@ -85,11 +82,6 @@ with import <stockholm/lib>; ''; }; - tincUpExtra = mkOption { - type = types.str; - default = ""; - }; - tincPackage = mkOption { type = types.package; default = pkgs.tinc_pre; @@ -128,9 +120,9 @@ with import <stockholm/lib>; default = pkgs.write "${tinc.config.netname}-tinc-hosts" (mapAttrs' - (_: host: (nameValuePair "/${host.name}" { + (_: host: nameValuePair "/${host.name}" { text = host.nets.${tinc.config.netname}.tinc.config; - })) + }) tinc.config.hosts); defaultText = "‹netname›-tinc-hosts"; description = '' diff --git a/krebs/5pkgs/override/default.nix b/krebs/5pkgs/override/default.nix index ae42bc1a3..f85f3f678 100644 --- a/krebs/5pkgs/override/default.nix +++ b/krebs/5pkgs/override/default.nix @@ -9,20 +9,6 @@ self: super: { }; }); - flameshot = super.flameshot.overrideAttrs (old: rec { - name = "flameshot-${version}"; - version = "0.10.2"; - src = self.fetchFromGitHub { - owner = "flameshot-org"; - repo = "flameshot"; - rev = "v${version}"; - sha256 = "sha256-rZUiaS32C77tFJmEkw/9MGbVTVscb6LOCyWaWO5FyR4="; - }; - patches = old.patches or [] ++ [ - ./flameshot/flameshot_imgur_0.10.2.patch - ]; - }); - # https://github.com/proot-me/PRoot/issues/106 proot = self.writeDashBin "proot" '' export PROOT_NO_SECCOMP=1 diff --git a/krebs/5pkgs/simple/q-power_supply.nix b/krebs/5pkgs/simple/q-power_supply.nix index 87f900194..627e3f905 100644 --- a/krebs/5pkgs/simple/q-power_supply.nix +++ b/krebs/5pkgs/simple/q-power_supply.nix @@ -8,7 +8,7 @@ writeDashBin "q-power_supply" '' s/^\([A-Z_]\+=[0-9A-Za-z_-]*\)$/export \1/p ' $uevent)" case $POWER_SUPPLY_NAME in - AC) + AC|Mains) exit # not battery ;; esac @@ -24,24 +24,41 @@ writeDashBin "q-power_supply" '' return sprintf("%dh%dm", h, m) } - function print_bar(n, r, t1, t2, t_col) { - t1 = int(r * n) - t2 = n - t1 - if (r >= .42) t_col = "1;32" - else if (r >= 23) t_col = "1;33" - else if (r >= 11) t_col = "1;31" - else t_col = "5;1;31" - return sgr(t_col) strdup("■", t1) sgr(";30") strdup("■", t2) sgr() + function print_bar(r) { + return \ + (r >= .1 ? bar_gradient[0] : bar_background) "■" \ + (r >= .2 ? bar_gradient[1] : bar_background) "■" \ + (r >= .3 ? bar_gradient[2] : bar_background) "■" \ + (r >= .4 ? bar_gradient[3] : bar_background) "■" \ + (r >= .5 ? bar_gradient[4] : bar_background) "■" \ + (r >= .6 ? bar_gradient[5] : bar_background) "■" \ + (r >= .7 ? bar_gradient[6] : bar_background) "■" \ + (r >= .8 ? bar_gradient[7] : bar_background) "■" \ + (r >= .9 ? bar_gradient[8] : bar_background) "■" \ + (r >= 1 ? bar_gradient[9] : bar_background) "■" \ + sgr() + } + + function rgb(r, g, b) { + return sgr("38;2;" r ";" g ";" b) } function sgr(p) { return "\x1b[" p "m" } - function strdup(s,n,t) { - t = sprintf("%"n"s","") - gsub(/ /,s,t) - return t + BEGIN { + bar_gradient[0] = rgb(216, 100, 83) + bar_gradient[1] = rgb(210, 113, 72) + bar_gradient[2] = rgb(201, 125, 65) + bar_gradient[3] = rgb(190, 137, 63) + bar_gradient[4] = rgb(178, 148, 67) + bar_gradient[5] = rgb(166, 158, 75) + bar_gradient[6] = rgb(153, 167, 88) + bar_gradient[7] = rgb(140, 174, 104) + bar_gradient[8] = rgb(127, 181, 122) + bar_gradient[9] = rgb(116, 187, 141) + bar_background = rgb( 64, 64, 64) } END { @@ -101,7 +118,7 @@ writeDashBin "q-power_supply" '' charge_ratio = charge_now / charge_full out = out name - out = out sprintf(" %s", print_bar(10, charge_ratio)) + out = out sprintf(" %s", print_bar(charge_ratio)) out = out sprintf(" %d%", charge_ratio * 100) out = out sprintf(" %.2f%s", charge_now, charge_unit) if (current_now != 0) { diff --git a/makefu/2configs/binary-cache/gum.nix b/makefu/2configs/binary-cache/gum.nix index fc54bd917..fc6e26fe0 100644 --- a/makefu/2configs/binary-cache/gum.nix +++ b/makefu/2configs/binary-cache/gum.nix @@ -2,11 +2,11 @@ { config, ... }: { - nix = { - binaryCaches = [ + nix.settings = { + substituters = [ "https://cache.euer.krebsco.de/" ]; - binaryCachePublicKeys = [ + trusted-public-keys = [ "gum:iIXIFlCAotib+MgI3V/i3HMlFXiVYOT/jfP0y54Zuvg=" ]; }; diff --git a/makefu/2configs/binary-cache/lass.nix b/makefu/2configs/binary-cache/lass.nix index 51b4a1afc..7d7549d8d 100644 --- a/makefu/2configs/binary-cache/lass.nix +++ b/makefu/2configs/binary-cache/lass.nix @@ -1,11 +1,11 @@ { config, ... }: { - nix = { - binaryCaches = [ + nix.settings = { + substituters = [ "https://cache.krebsco.de" ]; - binaryCachePublicKeys = [ + trusted-public-keys = [ "cache.prism-1:+S+6Lo/n27XEtvdlQKuJIcb1yO5NUqUCE2lolmTgNJU=" "cache.prism-2:YwmCm3/s/D+SxrPKN/ETjlpw/219pNUbpnluatp6FKI=" ]; diff --git a/makefu/2configs/binary-cache/nixos.nix b/makefu/2configs/binary-cache/nixos.nix index 2ff5e1307..299130059 100644 --- a/makefu/2configs/binary-cache/nixos.nix +++ b/makefu/2configs/binary-cache/nixos.nix @@ -1,11 +1,11 @@ { config, ... }: { - nix = { - binaryCaches = [ + nix.settings = { + substituters = [ "https://cache.nixos.org/" ]; - binaryCachePublicKeys = [ + trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; }; diff --git a/makefu/2configs/default.nix b/makefu/2configs/default.nix index ef4f8fbcd..2bfb42732 100644 --- a/makefu/2configs/default.nix +++ b/makefu/2configs/default.nix @@ -30,7 +30,7 @@ with import <stockholm/lib>; openssh.authorizedKeys.keys = [ config.krebs.users.makefu.pubkey ]; }; }; - nix.trustedUsers = [ config.krebs.build.user.name ]; + nix.settings.trusted-users = [ config.krebs.build.user.name ]; boot.kernelPackages = lib.mkDefault pkgs.linuxPackages; diff --git a/makefu/2configs/minimal.nix b/makefu/2configs/minimal.nix index 1761f65e2..0334422c8 100644 --- a/makefu/2configs/minimal.nix +++ b/makefu/2configs/minimal.nix @@ -8,13 +8,13 @@ time.timeZone = "Europe/Berlin"; networking.hostName = lib.mkIf (lib.hasAttr "host" config.krebs.build) config.krebs.build.host.name; - nix.buildCores = 0; # until https://github.com/NixOS/nixpkgs/pull/50440 is in stable # we use gpg if necessary (or nothing at all) programs.ssh.startAgent = false; # all boxes look the same - nix.useSandbox = true; + nix.settings.sandbox = true; + nix.settings.cores = 0; # until https://github.com/NixOS/nixpkgs/pull/50440 is in stable # we configure users via nix users.mutableUsers = false; diff --git a/tv/2configs/hw/winmax2.nix b/tv/2configs/hw/winmax2.nix index 0a207f231..49af7611c 100644 --- a/tv/2configs/hw/winmax2.nix +++ b/tv/2configs/hw/winmax2.nix @@ -1,7 +1,21 @@ { pkgs, ... }: { + + imports = [ + ../smartd.nix + ]; + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" ]; boot.initrd.kernelModules = [ "amdgpu" ]; - boot.kernelModules = [ "kvm-amd" ]; + boot.kernelModules = [ + "amd-pstate" + "kvm-amd" + ]; + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelParams = [ + "amd_pstate=passive" + ]; + + hardware.bluetooth.enable = true; hardware.cpu.amd.updateMicrocode = true; hardware.enableRedistributableFirmware = true; @@ -25,6 +39,10 @@ services.illum.enable = true; + services.logind.extraConfig = /* ini */ '' + HandlePowerKey=ignore + ''; + tv.lidControl.enable = true; tv.hw.screens.primary.width = 2560; diff --git a/tv/3modules/default.nix b/tv/3modules/default.nix index 8c1066b71..1a0971ec6 100644 --- a/tv/3modules/default.nix +++ b/tv/3modules/default.nix @@ -1,19 +1,8 @@ +with import ./lib; { - imports = [ - ./charybdis - ./dnsmasq.nix - ./ejabberd - ./focus.nix - ./hosts.nix - ./hw.nix - ./im.nix - ./iptables.nix - ./lidControl.nix - ./org.freedesktop.machine1.host-shell.nix - ./systemd.nix - ./slock.nix - ./x0vncserver.nix - ./Xresources.nix - ./wwan.nix - ]; + imports = + map + (name: ./. + "/${name}") + (attrNames + (filterAttrs isNixDirEntry (readDir ./.))); } diff --git a/tv/3modules/wwan.nix b/tv/3modules/wwan.nix index 03cd512e4..382f5a535 100644 --- a/tv/3modules/wwan.nix +++ b/tv/3modules/wwan.nix @@ -166,6 +166,7 @@ with import ./lib; interface=$(get-interface) + ip addr flush "$interface" ip link set dev "$interface" down uqmi --stop-network 0xFFFFFFFF --autoconnect uqmi --sync diff --git a/tv/5pkgs/override/flameshot/default.nix b/tv/5pkgs/override/flameshot/default.nix new file mode 100644 index 000000000..2f7c5236b --- /dev/null +++ b/tv/5pkgs/override/flameshot/default.nix @@ -0,0 +1,15 @@ +self: super: + +super.flameshot.overrideAttrs (old: rec { + name = "flameshot-${version}"; + version = "0.10.2"; + src = self.fetchFromGitHub { + owner = "flameshot-org"; + repo = "flameshot"; + rev = "v${version}"; + sha256 = "sha256-rZUiaS32C77tFJmEkw/9MGbVTVscb6LOCyWaWO5FyR4="; + }; + patches = old.patches or [] ++ [ + ./flameshot/flameshot_imgur_0.10.2.patch + ]; +}) diff --git a/krebs/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch b/tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch index c4c0bf38a..c4c0bf38a 100644 --- a/krebs/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch +++ b/tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch diff --git a/tv/5pkgs/override/iosevka-tv-1.nix b/tv/5pkgs/override/iosevka-tv-1.nix new file mode 100644 index 000000000..880160b3e --- /dev/null +++ b/tv/5pkgs/override/iosevka-tv-1.nix @@ -0,0 +1,20 @@ +self: super: + +let + srcpkg = super.iosevka-tv-1; + binpkg = self.fetchzip { + inherit (srcpkg) pname version; + stripRoot = false; + hash = "sha256-QIuTS70vUQSvDDXjY4uI6SCcu1XT4HjvzpthvrNX4h0="; + urls = [ + "https://c.krebsco.de/${srcpkg.name}.tar.gz" + "https://ni.krebsco.de/~tv/mirrors/iosevka/${srcpkg.name}.tar.gz" + ]; + }; +in + +if srcpkg.version == binpkg.version then + binpkg + +else + srcpkg diff --git a/tv/5pkgs/override/iosevka-tv-2.nix b/tv/5pkgs/override/iosevka-tv-2.nix new file mode 100644 index 000000000..2eecf3cff --- /dev/null +++ b/tv/5pkgs/override/iosevka-tv-2.nix @@ -0,0 +1,20 @@ +self: super: + +let + srcpkg = super.iosevka-tv-2; + binpkg = self.fetchzip { + inherit (srcpkg) pname version; + stripRoot = false; + hash = "sha256-PuIrW1ftYD5PW4du6gq1XpUM3v0potwmj+vAxJImF/A="; + urls = [ + "https://c.krebsco.de/${srcpkg.name}.tar.gz" + "https://ni.krebsco.de/~tv/mirrors/iosevka/${srcpkg.name}.tar.gz" + ]; + }; +in + +if srcpkg.version == binpkg.version then + binpkg + +else + srcpkg diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 1c7730a71..ddf2ca8df 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -53,10 +53,10 @@ let window.dimensions.lines = 9; }; variants.hidpi = { - font.normal.family = "iosevka-tv-1"; - font.bold.family = "iosevka-tv-1"; - font.italic.family = "iosevka-tv-1"; - font.bold_italic.family = "iosevka-tv-1"; + font.normal.family = "iosevka tv 2 Light"; + font.italic.family = "iosevka tv 2 Light"; + font.bold.family = "iosevka tv 2 Medium"; + font.bold_italic.family = "iosevka tv 2 Medium"; font.size = 5; key_bindings = [ { key = "Up"; mods = "Control"; action = "IncreaseFontSize"; } @@ -104,7 +104,7 @@ let ref=$(! test -e "$HOME"/ref || ${pkgs.coreutils}/bin/cat "$HOME"/ref) if test "$ref" != ${config-file}; then echo ${config-file} > "$HOME"/ref - ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml + ${pkgs.coreutils}/bin/install -m 644 ${config-file} "$HOME"/.alacritty.yml fi ''; in diff --git a/tv/5pkgs/simple/ff.nix b/tv/5pkgs/simple/ff.nix index 4ce9c3c75..b6022c6ca 100644 --- a/tv/5pkgs/simple/ff.nix +++ b/tv/5pkgs/simple/ff.nix @@ -1,5 +1,8 @@ { pkgs }: pkgs.writeDashBin "ff" '' + case $TOUCHSCREEN in 1) + export MOZ_USE_XINPUT2=1 + esac exec ${pkgs.firefox}/bin/firefox "$@" '' diff --git a/tv/5pkgs/simple/alacritty-font-size.nix b/tv/5pkgs/simple/font-size-alacritty.nix index 84bc3f616..d37f0f055 100644 --- a/tv/5pkgs/simple/alacritty-font-size.nix +++ b/tv/5pkgs/simple/font-size-alacritty.nix @@ -6,7 +6,7 @@ pkgs.writeDashBin "font-size-alacritty" '' set -efu - min_size=8 + min_size=5 op=''${1%%[0-9]*} op=''${op:-=} diff --git a/tv/5pkgs/simple/iosevka-tv-1.nix b/tv/5pkgs/simple/iosevka-tv-1.nix index f72565bc7..0f8b4d4b2 100644 --- a/tv/5pkgs/simple/iosevka-tv-1.nix +++ b/tv/5pkgs/simple/iosevka-tv-1.nix @@ -3,7 +3,7 @@ pkgs.iosevka.override { # https://typeof.net/Iosevka/customizer privateBuildPlan = { - family = "iosevka-tv-1"; + family = "iosevka tv 1"; spacing = "term"; serifs = "sans"; export-glyph-names = true; @@ -14,5 +14,5 @@ pkgs.iosevka.override { widths.normal.menu = 5; widths.normal.css = "normal"; }; - set = "iosevka-tv-1"; + set = "tv-1"; } diff --git a/tv/5pkgs/simple/iosevka-tv-2.nix b/tv/5pkgs/simple/iosevka-tv-2.nix new file mode 100644 index 000000000..888ba6a0c --- /dev/null +++ b/tv/5pkgs/simple/iosevka-tv-2.nix @@ -0,0 +1,20 @@ +{ pkgs }: + +pkgs.iosevka.override { + # https://typeof.net/Iosevka/customizer + privateBuildPlan = { + family = "iosevka tv 2"; + spacing = "term"; + serifs = "sans"; + export-glyph-names = true; + no-ligation = true; + no-cv-ss = false; + + variants.inherits = "ss10"; + + widths.normal.shape = 600; + widths.normal.menu = 5; + widths.normal.css = "normal"; + }; + set = "tv-2"; +} diff --git a/tv/5pkgs/simple/libinput-tv.nix b/tv/5pkgs/simple/libinput-tv.nix new file mode 100644 index 000000000..6f08689bb --- /dev/null +++ b/tv/5pkgs/simple/libinput-tv.nix @@ -0,0 +1,11 @@ +{ pkgs }: + +pkgs.libinput.overrideAttrs (old: { + patches = old.patches or [] ++ [ + (pkgs.fetchurl { + name = "libinput-winmax2.patch"; + url = "https://github.com/4z3/libinput/commit/2d0ff41.patch"; + sha256 = "0ipsxzjf98g9w2m163gp49zl14wbxs84s0psdnvk7wfiivgcnm1f"; + }) + ]; +}) diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index 2ae71db52..809e37e59 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -10,71 +10,44 @@ let 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 = /* sh */ ''{ - ${pkgs.gnused}/bin/sed ' - # rtrim - s/ *$// - - # delete last empty line - ''${/^$/d} - ' \ - | ${pkgs.gawk}/bin/awk '{printf "%-${toString calwidth}s\n", $0}' \ - | ${pkgs.gnused}/bin/sed ' - # colorize header - 1,2s/.*/[38;5;238;1m&[39;22m/ - - # colorize week number - s/^[ 1-9][0-9]/[38;5;238;1m&[39;22m/ - ' - }''; + need_width = n: assert n >= 1; n * calwidth + (n - 1) * hspace; + in /* sh */ '' cols=$(${pkgs.ncurses}/bin/tput cols) - ${pkgs.coreutils}/bin/paste \ - <(if test $cols -ge ${toString (need_width 3)}; then - ${pkgs.utillinux}/bin/cal -mw \ - $(${pkgs.coreutils}/bin/date +'%m %Y' -d 'last month') \ - | ${pad} - 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)"'\>/[31;1m&[39;22m/ - ' \ - | ${pad} - 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} - fi) \ - | ${pkgs.gnused}/bin/sed ' - s/^\t// - s/\t$// - s/\t/${lpad hspace " " ""}/g - ' + if test $cols -ge ${toString (need_width 3)}; then + ${pkgs.utillinux}/bin/cal --color=always -mw3 + elif test $cols -ge ${toString (need_width 2)}; then + ${pkgs.utillinux}/bin/cal --color=always -mw -n 2 + elif test $cols -ge ${toString (need_width 1)}; then + ${pkgs.utillinux}/bin/cal --color=always -mw1 + else + : + fi | + ${pkgs.gnused}/bin/sed -r ' + # dim week numbers + s/((^ *| )[ 1-5][0-9]( *)?)(([ 1-3][0-9])*)/[38;5;243m\1[m\4/g + # dim month and day names + s/^ *[A-Z].*/[38;5;243m&[m/ + # highlight current date + s/\[7m/[38;5;009;1m/ + s/\[27m/[m/ + ' ''; - q-isodate = /* sh */ '' + q-isodate = TZ: color: /* sh */ '' + TZ=${shell.escape TZ} \ ${pkgs.coreutils}/bin/date \ - '+[1m%Y-%m-%d[;30mT[;38;5;085m%H:%M[m:%S%:z' + '+[m%Y-%m-%d[38;5;243mT[;'${shell.escape color}'m%H:%M[38;5;243m:[m%S%:z' ''; + q-deudate = q-isodate "Europe/Berlin" "38;5;085"; + # Singapore's red is #ED2E38 - q-sgtdate = /* sh */ '' - TZ=Asia/Singapore \ - ${pkgs.coreutils}/bin/date \ - '+[1m%Y-%m-%d[;30mT[;38;5;088m%H:%M[m:%S%:z' - ''; + q-sgtdate = q-isodate "Asia/Singapore" "38;2;237;46;56"; - q-utcdate = /* sh */ '' - ${pkgs.coreutils}/bin/date -u \ - '+[1m%Y-%m-%d[;30mT[;38;5;065m%H:%M[m:%S%:z' - ''; + q-thadate = q-isodate "Asia/Bangkok" "38;5;226"; + + q-utcdate = q-isodate "UTC" "38;5;065"; q-gitdir = /* sh */ '' if test -d .git; then @@ -106,31 +79,34 @@ let echo "VT: $(${pkgs.systemd}/bin/systemd-detect-virt)" ''; - q-wireless = /* sh */ '' + q-net = /* sh */ '' for dev in $( - ${pkgs.iw}/bin/iw dev \ - | ${pkgs.gnused}/bin/sed -n 's/^\s*Interface\s\+\([0-9a-z]\+\)$/\1/p' + ${pkgs.iproute}/bin/ip a | + ${pkgs.gnused}/bin/sed -rn 's/^[0-9]+: ([^:]+):.*/\1/p' | + ${pkgs.gnugrep}/bin/grep -Ev '^(lo|retiolum|wiregrill)$' + # TODO wiregrill ping ni.w, retiolum ping ni.r ); do - inet=$(${pkgs.iproute}/bin/ip addr show $dev \ - | ${pkgs.gnused}/bin/sed -n ' - s/.*inet \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p - ') \ - || unset inet - ssid=$(${pkgs.iw}/bin/iw dev $dev link \ - | ${pkgs.gnused}/bin/sed -n ' - s/.*\tSSID: \(.*\)/\1/p - ') \ - || unset ssid - echo "$dev''${inet+ $inet}''${ssid+ $ssid}" + { + inet=$(${pkgs.iproute}/bin/ip addr show $dev \ + | ${pkgs.gnused}/bin/sed -n ' + s/.*inet \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p + ') + ssid=$(${pkgs.iw}/bin/iw dev $dev link \ + | ${pkgs.gnused}/bin/sed -n ' + s/.*\tSSID: \(.*\)/\1/p + ') + latency=$( + /run/wrappers/bin/ping -W .25 -c 1 -I "$dev" ni.i 2>&1 | + ${pkgs.gnused}/bin/sed -rn ' + s/.*time=([0-9.]+).*/online ni=[38;5;085m\1[m/p + s/.*Network is unreachable.*/offline/p + s/.*100% packet loss.*/offline/p + ' + ) + echo "$dev''${inet:+ $inet}''${ssid:+ $ssid} $latency" + } & done - ''; - - q-online = /* sh */ '' - if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then - echo '[32;1monline[m' - else - echo offline - fi + wait ''; q-thermal_zone = /* sh */ '' @@ -173,14 +149,13 @@ pkgs.writeBashBin "q" '' export PATH=/var/empty ${q-cal} ${q-utcdate} - ${q-isodate} + ${q-deudate} ${q-sgtdate} (${q-gitdir}) & (${q-intel_backlight}) & ${pkgs.q-power_supply}/bin/q-power_supply & (${q-virtualization}) & - (${q-wireless}) & - (${q-online}) & + (${q-net}) & (${q-thermal_zone}) & wait if test "$PWD" != "$HOME" && test -e "$HOME/TODO"; then |