From 45359e7db5ec7fe9e33624e15e362c2b9e6ef9d9 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 29 Dec 2018 14:22:24 +0100 Subject: tv dhcpcd: set saner dbdir --- tv/5pkgs/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tv/5pkgs') diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index c5c800b55..605d827ef 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -24,6 +24,12 @@ foldl' mergeAttrs {} "$@" ''; + dhcpcd = overrideDerivation super.dhcpcd (old: { + configureFlags = old.configureFlags ++ [ + "--dbdir=/var/lib/dhcpcd" + ]; + }); + gitAndTools = super.gitAndTools // { inherit (self) diff-so-fancy; }; -- cgit v1.2.3 From e0bbedff27bd3ca6d69b147f2f3dbc183de72243 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 7 Jan 2019 15:29:48 +0100 Subject: tv xkiller: init --- tv/5pkgs/simple/xkiller.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tv/5pkgs/simple/xkiller.nix (limited to 'tv/5pkgs') diff --git a/tv/5pkgs/simple/xkiller.nix b/tv/5pkgs/simple/xkiller.nix new file mode 100644 index 000000000..8d8f01690 --- /dev/null +++ b/tv/5pkgs/simple/xkiller.nix @@ -0,0 +1,25 @@ +{ pkgs }: +pkgs.writeDash "xkiller" '' + set -efu + exec >&2 + ${pkgs.iproute}/bin/ss -lp src unix:/tmp/.X11-unix/X* | + ${pkgs.gnused}/bin/sed -n ' + s|.*/tmp/.X11-unix/X\([0-9]\+\)\>.*("X[^"]*",pid=\([0-9]\+\)\>.*|\1 \2|p + ' | + while read -r display pid; do + { + exit_code=$( + DISPLAY=:$display ${pkgs.coreutils}/bin/timeout 1 \ + ${pkgs.xorg.xset}/bin/xset q >/dev/null 2>&1 && + echo 0 || echo $? + ) + if test $exit_code = 124; then + echo "X on display :$display is locked up; killing PID $pid..." + ${pkgs.coreutils}/bin/kill -SIGKILL "$pid" + else + echo "X on display :$display is healthy" + fi + } & + done + wait +'' -- cgit v1.2.3 From 6c734674da365c2529505a78dea9317f74dec260 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 16 Jan 2019 20:24:53 +0100 Subject: tv q: add sigils --- tv/5pkgs/simple/q/default.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tv/5pkgs') diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index cbcec1bae..6c1876ab0 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -14,7 +14,7 @@ let assert n >= 1; n * calwidth + (n - 1) * hspace; - pad = ''{ + pad = /* sh */ ''{ ${pkgs.gnused}/bin/sed ' # rtrim s/ *$// @@ -31,7 +31,7 @@ let s/^[ 1-9][0-9]/&/ ' }''; - in '' + in /* sh */ '' cols=$(${pkgs.ncurses}/bin/tput cols) ${pkgs.coreutils}/bin/paste \ <(if test $cols -ge ${toString (need_width 3)}; then @@ -59,24 +59,24 @@ let ' ''; - q-isodate = '' + q-isodate = /* sh */ '' ${pkgs.coreutils}/bin/date \ '+%Y-%m-%dT%H:%M:%S%:z' ''; # Singapore's red is #ED2E38 - q-sgtdate = '' + q-sgtdate = /* sh */ '' TZ=Asia/Singapore \ ${pkgs.coreutils}/bin/date \ '+%Y-%m-%dT%H:%M:%S%:z' ''; - q-utcdate = '' + q-utcdate = /* sh */ '' ${pkgs.coreutils}/bin/date -u \ '+%Y-%m-%dT%H:%M:%S%:z' ''; - q-gitdir = '' + q-gitdir = /* sh */ '' if test -d .git; then #git status --porcelain branch=$( @@ -87,7 +87,7 @@ let fi ''; - q-intel_backlight = '' + q-intel_backlight = /* sh */ '' cd /sys/class/backlight/intel_backlight /dev/null; then echo 'online' else @@ -258,7 +258,7 @@ let fi ''; - q-thermal_zone = '' + q-thermal_zone = /* sh */ '' for i in /sys/class/thermal/thermal_zone*; do type=$(${pkgs.coreutils}/bin/cat $i/type) temp=$(${pkgs.coreutils}/bin/cat $i/temp) @@ -266,7 +266,7 @@ let done ''; - q-todo = '' + q-todo = /* sh */ '' TODO_file=$PWD/TODO if test -e "$TODO_file"; then ${pkgs.coreutils}/bin/cat "$TODO_file" \ -- cgit v1.2.3 From 0ef96fc0cf8bf85be36f2911923a91143a484fdc Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 16 Jan 2019 20:25:17 +0100 Subject: tv q-todo: awk,bash,cat,date -> jq --- tv/5pkgs/simple/q/default.nix | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'tv/5pkgs') diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index 6c1876ab0..0e2aecb27 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -269,26 +269,19 @@ let q-todo = /* sh */ '' TODO_file=$PWD/TODO if test -e "$TODO_file"; then - ${pkgs.coreutils}/bin/cat "$TODO_file" \ - | ${pkgs.gawk}/bin/gawk -v now=$(${pkgs.coreutils}/bin/date +%s) ' - BEGIN { print "remind=0" } - /^[0-9]/{ - x = $1 - gsub(".", "\\\\&", x) - rest = substr($0, index($0, " ")) - rest = $0 - sub(" *", "", rest) - gsub(".", "\\\\&", rest) - print "test $(${pkgs.coreutils}/bin/date +%s -d"x") -lt "now" && \ - echo \"\x1b[38;5;208m\""rest esc "\"\x1b[m\" && \ - (( remind++ ))" - } - END { print "test $remind = 0 && echo \"nothing to remind\"" } - ' \ - | { - # bash needed for (( ... )) - ${pkgs.bash}/bin/bash - } + ${pkgs.jq}/bin/jq -Rrs <"$TODO_file" -f ${pkgs.writeJq "q-todo.jq" '' + split("\n") | map( + (match("^([0-9]+-\\d{2}-\\d{2})\\s+(.*)$").captures | map(.string)) + as $captures | + ($captures[0] | strptime("%Y-%m-%d") | mktime) as $date | + $captures[1] as $text | + + select(now >= $date) | + + "\u001b[38;5;208m\(.)\u001b[m" + ) | + if length == 0 then "nothing to remind" else .[] end + ''} else echo "$TODO_file: no such file or directory" fi -- cgit v1.2.3 From ce1baf93f264a43971130abca4b3dd3f485a17d9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 16 Jan 2019 20:34:10 +0100 Subject: tv q-todo: highlight urgent stuff --- tv/5pkgs/simple/q/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tv/5pkgs') diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index 0e2aecb27..7906b968f 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -278,7 +278,11 @@ let select(now >= $date) | - "\u001b[38;5;208m\(.)\u001b[m" + ($text | test("\\[URGENT]"; "i")) as $urgent | + (if $urgent then "38;5;196" else "38;5;208" end) as $sgr | + if $urgent then sub("\\s*\\[URGENT]\\s*"; " "; "i") else . end | + + "\u001b[\($sgr)m\(.)\u001b[m" ) | if length == 0 then "nothing to remind" else .[] end ''} -- cgit v1.2.3