summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/simple
diff options
context:
space:
mode:
Diffstat (limited to 'tv/5pkgs/simple')
-rw-r--r--tv/5pkgs/simple/alacritty-tv.nix100
-rw-r--r--tv/5pkgs/simple/ff.nix3
-rw-r--r--tv/5pkgs/simple/font-size-alacritty.nix (renamed from tv/5pkgs/simple/alacritty-font-size.nix)2
-rwxr-xr-xtv/5pkgs/simple/fzmenu/bin/otpmenu2
-rwxr-xr-xtv/5pkgs/simple/fzmenu/bin/passmenu2
-rw-r--r--tv/5pkgs/simple/fzmenu/default.nix14
-rw-r--r--tv/5pkgs/simple/iosevka-tv-1.nix18
-rw-r--r--tv/5pkgs/simple/iosevka-tv-2.nix20
-rw-r--r--tv/5pkgs/simple/libinput-tv.nix11
-rw-r--r--tv/5pkgs/simple/q/default.nix135
10 files changed, 202 insertions, 105 deletions
diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix
index d80c46cbb..ddf2ca8df 100644
--- a/tv/5pkgs/simple/alacritty-tv.nix
+++ b/tv/5pkgs/simple/alacritty-tv.nix
@@ -1,4 +1,6 @@
-{ pkgs }:
+{ pkgs
+, variant ? "x220"
+}:
let
lib = import ./lib;
@@ -6,7 +8,7 @@ let
program = "${pkgs.font-size-alacritty}/bin/font-size-alacritty";
args = [arg];
};
- config = {
+ configs.default = lib.recursiveUpdate variants.${variant} {
bell.animation = "EaseOut";
bell.duration = 50;
bell.color = "#ff00ff";
@@ -30,10 +32,6 @@ let
colors.bright.cyan = "#72fbfb";
colors.bright.white = "#fbfbfb";
draw_bold_text_with_bright_colors = true;
- font.normal.family = "Clean";
- font.bold.family = "Clean";
- font.bold.style = "Regular";
- font.size = 10;
hints.enabled = [
{
regex = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\\u0000-\\u001F\\u007F-\\u009F<>\"\\s{-}\\^⟨⟩`]+";
@@ -42,15 +40,73 @@ let
action = "Select";
}
];
+ scrolling.multiplier = 8;
+ };
+ configs.root = lib.recursiveUpdate configs.default {
+ colors.primary.background = "#230000";
+ colors.primary.foreground = "#e0c0c0";
+ colors.normal.black = "#800000";
+ };
+ configs.fzmenu = lib.recursiveUpdate configs.default {
+ colors.primary.background = "#2A172A";
+ window.dimensions.columns = 70;
+ window.dimensions.lines = 9;
+ };
+ variants.hidpi = {
+ 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"; }
+ { key = "Down"; mods = "Control"; action = "DecreaseFontSize"; }
+ { key = "Down"; mods = "Shift|Control"; action = "ResetFontSize"; }
+ ];
+ };
+ variants.x220 = {
+ font.normal.family = "Clean";
+ font.bold.family = "Clean";
+ font.bold.style = "Regular";
+ font.size = 10;
key_bindings = [
{ key = "Up"; mods = "Shift|Control"; command = font-size "=14"; }
{ key = "Up"; mods = "Control"; command = font-size "+1"; }
{ key = "Down"; mods = "Control"; command = font-size "-1"; }
{ key = "Down"; mods = "Shift|Control"; command = font-size "=0"; }
];
- scrolling.multiplier = 8;
};
- config-file = pkgs.writeJSON "alacritty-tv.json" config;
+ writeProfile = name: config: let
+ config-file =
+ assert lib.types.filename.check name;
+ pkgs.writeJSON "alacritty-tv-${name}.json" config;
+ in pkgs.writeText "alacritty-tv-${name}.profile" /* sh */ ''
+ # Use home so Alacritty can find the configuration without arguments.
+ # HOME will be reset once in Alacritty.
+ HOME=$XDG_RUNTIME_DIR/Alacritty-${name}
+ export HOME
+
+ # Tell Alacritty via XDG_RUNTIME_DIR where to create sockets.
+ # XDG_RUNTIME_DIR needs to be reset manually.
+ export ALACRITTY_XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR"
+ export BASH_EXTRA_INIT=${pkgs.writeDash "alacritty-tv.cleanup.sh" ''
+ XDG_RUNTIME_DIR=$ALACRITTY_XDG_RUNTIME_DIR
+ unset ALACRITTY_XDG_RUNTIME_DIR
+ unset BASH_EXTRA_INIT
+ ''}
+ export XDG_RUNTIME_DIR="$HOME"
+
+ # Install stored configuration if it has changed.
+ # This allows for both declarative updates and runtime modifications.
+ # rust-xdg requires XDG_RUNTIME_DIR to be secure:
+ # https://docs.rs/xdg/2.4.1/src/xdg/lib.rs.html#311
+ ${pkgs.coreutils}/bin/mkdir -m 0700 -p "$HOME"
+ 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/install -m 644 ${config-file} "$HOME"/.alacritty.yml
+ fi
+ '';
in
pkgs.symlinkJoin {
@@ -58,31 +114,35 @@ pkgs.symlinkJoin {
paths = [
(pkgs.writeDashBin "alacritty" ''
# usage:
- # alacritty [--singleton] [ARGS...]
+ # alacritty [--profile=PROFILE] [--singleton] [ARGS...]
+ # where
+ # PROFILE one of ${lib.toJSON (lib.attrNames configs)}
set -efu
- # Use home so Alacritty can find the configuration without arguments.
- # HOME will be reset once in Alacritty.
- HOME=$TMPDIR/Alacritty
- export HOME
+ case ''${1-} in
+ ${lib.concatMapStringsSep "\n" (name: /* sh */ ''
+ --${lib.shell.escape name}|--profile=${lib.shell.escape name})
+ shift
+ profile=${writeProfile name configs.${name}}
+ ;;
+ '') (lib.attrNames configs)}
+ *)
+ profile=${writeProfile "default" configs.default}
+ ;;
+ esac
- # Install stored configuration if it has changed.
- # This allows for both declarative updates and runtime modifications.
- ${pkgs.coreutils}/bin/mkdir -p "$HOME"
- if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then
- echo ${config-file} > "$HOME"/ref
- ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml
- fi
case ''${1-} in
--singleton)
shift
if ! ${pkgs.alacritty}/bin/alacritty msg create-window "$@"; then
+ . "$profile"
${pkgs.alacritty}/bin/alacritty "$@" &
fi
;;
*)
+ . "$profile"
exec ${pkgs.alacritty}/bin/alacritty "$@"
;;
esac
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/fzmenu/bin/otpmenu b/tv/5pkgs/simple/fzmenu/bin/otpmenu
index ad8a0fda9..12bd60a9d 100755
--- a/tv/5pkgs/simple/fzmenu/bin/otpmenu
+++ b/tv/5pkgs/simple/fzmenu/bin/otpmenu
@@ -6,7 +6,7 @@ set -efu
case ${FZMENU_PHASE-0} in
0)
export FZMENU_PHASE=1
- exec setsid -f urxvt -name fzmenu-urxvt -e dash "$0"
+ exec setsid -f terminal dash "$0"
;;
1)
if result=$(
diff --git a/tv/5pkgs/simple/fzmenu/bin/passmenu b/tv/5pkgs/simple/fzmenu/bin/passmenu
index 00b36c3af..da8e739ee 100755
--- a/tv/5pkgs/simple/fzmenu/bin/passmenu
+++ b/tv/5pkgs/simple/fzmenu/bin/passmenu
@@ -6,7 +6,7 @@ set -efu
case ${FZMENU_PHASE-0} in
0)
export FZMENU_PHASE=1
- exec setsid -f urxvt -name fzmenu-urxvt -e dash "$0"
+ exec setsid -f terminal dash "$0"
;;
1)
if result=$(
diff --git a/tv/5pkgs/simple/fzmenu/default.nix b/tv/5pkgs/simple/fzmenu/default.nix
index 634d8338b..7e19505c1 100644
--- a/tv/5pkgs/simple/fzmenu/default.nix
+++ b/tv/5pkgs/simple/fzmenu/default.nix
@@ -1,5 +1,15 @@
{ lib, pkgs, stdenv }:
+let
+ terminal = pkgs.writeDashBin "terminal" ''
+ # usage: terminal COMMAND [ARGS...]
+ exec ${pkgs.alacritty-tv}/bin/alacritty \
+ --profile=fzmenu \
+ --class AlacrittyFzmenuFloat \
+ -e "$@"
+ '';
+in
+
pkgs.runCommand "fzmenu" {
} /* sh */ ''
mkdir $out
@@ -16,9 +26,9 @@ pkgs.runCommand "fzmenu" {
(pkgs.pass.withExtensions (ext: [
ext.pass-otp
]))
- pkgs.rxvt_unicode
pkgs.utillinux
pkgs.xdotool
+ terminal
]}
substituteInPlace $out/bin/passmenu \
@@ -31,8 +41,8 @@ pkgs.runCommand "fzmenu" {
(pkgs.pass.withExtensions (ext: [
ext.pass-otp
]))
- pkgs.rxvt_unicode
pkgs.utillinux
pkgs.xdotool
+ terminal
]}
''
diff --git a/tv/5pkgs/simple/iosevka-tv-1.nix b/tv/5pkgs/simple/iosevka-tv-1.nix
new file mode 100644
index 000000000..0f8b4d4b2
--- /dev/null
+++ b/tv/5pkgs/simple/iosevka-tv-1.nix
@@ -0,0 +1,18 @@
+{ pkgs }:
+
+pkgs.iosevka.override {
+ # https://typeof.net/Iosevka/customizer
+ privateBuildPlan = {
+ family = "iosevka tv 1";
+ spacing = "term";
+ serifs = "sans";
+ export-glyph-names = true;
+ no-ligation = true;
+ no-cv-ss = false;
+
+ widths.normal.shape = 600;
+ widths.normal.menu = 5;
+ widths.normal.css = "normal";
+ };
+ 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;
+ 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/.*/&/
-
- # colorize week number
- s/^[ 1-9][0-9]/&/
- '
- }'';
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)"'\>/&/
- ' \
- | ${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])*)/\1\4/g
+ # dim month and day names
+ s/^ *[A-Z].*/&/
+ # highlight current date
+ s/\[7m//
+ s/\[27m//
+ '
'';
- q-isodate = /* sh */ ''
+ q-isodate = TZ: color: /* sh */ ''
+ TZ=${shell.escape TZ} \
${pkgs.coreutils}/bin/date \
- '+%Y-%m-%dT%H:%M:%S%:z'
+ '+%Y-%m-%dT[;'${shell.escape color}'m%H:%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 \
- '+%Y-%m-%dT%H:%M:%S%:z'
- '';
+ q-sgtdate = q-isodate "Asia/Singapore" "38;2;237;46;56";
- q-utcdate = /* sh */ ''
- ${pkgs.coreutils}/bin/date -u \
- '+%Y-%m-%dT%H:%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=\1/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 'online'
- 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