From 0c4f3acb281be6290c55a6e96bc29fab5b5c7a11 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 11 Sep 2023 18:24:28 +0200 Subject: stockholm -> hrm --- pkgs/simple/alacritty-tv.nix | 155 ++++++++++++++ pkgs/simple/bash-fzf-history.nix | 107 ++++++++++ pkgs/simple/cr.nix | 16 ++ pkgs/simple/default.nix | 22 ++ pkgs/simple/diff-so-fancy.nix | 50 +++++ pkgs/simple/disko.nix | 13 ++ pkgs/simple/editor-input.nix | 18 ++ pkgs/simple/ff.nix | 8 + pkgs/simple/field.nix | 6 + pkgs/simple/flameshot-once-tv.nix | 48 +++++ pkgs/simple/font-size-alacritty.nix | 67 ++++++ pkgs/simple/fzmenu/bin/otpmenu | 44 ++++ pkgs/simple/fzmenu/bin/passmenu | 45 ++++ pkgs/simple/fzmenu/default.nix | 50 +++++ pkgs/simple/hc.nix | 39 ++++ pkgs/simple/iosevka-tv-1.nix | 18 ++ pkgs/simple/iosevka-tv-2.nix | 20 ++ pkgs/simple/libinput-tv.nix | 11 + pkgs/simple/mpvterm/default.nix | 8 + pkgs/simple/mpvterm/mpvterm.patch | 146 +++++++++++++ pkgs/simple/pinentry-urxvt/default.nix | 127 +++++++++++ pkgs/simple/q/default.nix | 176 +++++++++++++++ pkgs/simple/rox-filer.nix | 95 +++++++++ .../rxvt-unicode-256color-terminfo/default.nix | 16 ++ .../rxvt-unicode-256color.terminfo | Bin 0 -> 2239 bytes pkgs/simple/stardict/default.nix | 235 +++++++++++++++++++++ pkgs/simple/viljetic-pages/default.nix | 17 ++ pkgs/simple/viljetic-pages/index.html | 11 + pkgs/simple/viljetic-pages/logo.xpm | 24 +++ pkgs/simple/weechat-tv.nix | 9 + pkgs/simple/xdpytools/default.nix | 31 +++ pkgs/simple/xdpytools/src/xdpychvt | 11 + pkgs/simple/xdpytools/src/xdpysel | 49 +++++ pkgs/simple/xkiller.nix | 25 +++ pkgs/simple/xtoggledpms.nix | 16 ++ 35 files changed, 1733 insertions(+) create mode 100644 pkgs/simple/alacritty-tv.nix create mode 100644 pkgs/simple/bash-fzf-history.nix create mode 100644 pkgs/simple/cr.nix create mode 100644 pkgs/simple/default.nix create mode 100644 pkgs/simple/diff-so-fancy.nix create mode 100644 pkgs/simple/disko.nix create mode 100644 pkgs/simple/editor-input.nix create mode 100644 pkgs/simple/ff.nix create mode 100644 pkgs/simple/field.nix create mode 100644 pkgs/simple/flameshot-once-tv.nix create mode 100644 pkgs/simple/font-size-alacritty.nix create mode 100755 pkgs/simple/fzmenu/bin/otpmenu create mode 100755 pkgs/simple/fzmenu/bin/passmenu create mode 100644 pkgs/simple/fzmenu/default.nix create mode 100644 pkgs/simple/hc.nix create mode 100644 pkgs/simple/iosevka-tv-1.nix create mode 100644 pkgs/simple/iosevka-tv-2.nix create mode 100644 pkgs/simple/libinput-tv.nix create mode 100644 pkgs/simple/mpvterm/default.nix create mode 100644 pkgs/simple/mpvterm/mpvterm.patch create mode 100644 pkgs/simple/pinentry-urxvt/default.nix create mode 100644 pkgs/simple/q/default.nix create mode 100644 pkgs/simple/rox-filer.nix create mode 100644 pkgs/simple/rxvt-unicode-256color-terminfo/default.nix create mode 100644 pkgs/simple/rxvt-unicode-256color-terminfo/rxvt-unicode-256color.terminfo create mode 100644 pkgs/simple/stardict/default.nix create mode 100644 pkgs/simple/viljetic-pages/default.nix create mode 100644 pkgs/simple/viljetic-pages/index.html create mode 100644 pkgs/simple/viljetic-pages/logo.xpm create mode 100644 pkgs/simple/weechat-tv.nix create mode 100644 pkgs/simple/xdpytools/default.nix create mode 100755 pkgs/simple/xdpytools/src/xdpychvt create mode 100755 pkgs/simple/xdpytools/src/xdpysel create mode 100644 pkgs/simple/xkiller.nix create mode 100644 pkgs/simple/xtoggledpms.nix (limited to 'pkgs/simple') diff --git a/pkgs/simple/alacritty-tv.nix b/pkgs/simple/alacritty-tv.nix new file mode 100644 index 0000000..efbcc6e --- /dev/null +++ b/pkgs/simple/alacritty-tv.nix @@ -0,0 +1,155 @@ +{ lib +, pkgs +, variant ? "x220" +}: + +let + mylib = import ../../lib/pure.nix { + inherit lib; + }; + font-size = arg: { + program = "${pkgs.font-size-alacritty}/bin/font-size-alacritty"; + args = [arg]; + }; + configs.default = lib.recursiveUpdate variants.${variant} { + bell.animation = "EaseOut"; + bell.duration = 50; + bell.color = "#ff00ff"; + colors.cursor.cursor = "#f042b0"; + colors.primary.background = "#202020"; + colors.primary.foreground = "#d0d7d0"; + colors.normal.black = "#000000"; + colors.normal.red = "#cd0000"; + colors.normal.green = "#00cd00"; + colors.normal.yellow = "#bc7004"; + colors.normal.blue = "#4343be"; + colors.normal.magenta = "#cb06cb"; + colors.normal.cyan = "#04c9c9"; + colors.normal.white = "#bebebe"; + colors.bright.black = "#727272"; + colors.bright.red = "#fb6262"; + colors.bright.green = "#72fb72"; + colors.bright.yellow = "#fbfb72"; + colors.bright.blue = "#7272fb"; + colors.bright.magenta = "#fb53fb"; + colors.bright.cyan = "#72fbfb"; + colors.bright.white = "#fbfbfb"; + draw_bold_text_with_bright_colors = true; + hints.enabled = [ + { + regex = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\\u0000-\\u001F\\u007F-\\u009F<>\"\\s{-}\\^⟨⟩`]+"; + mouse.enabled = true; + post_processing = true; + 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"; } + ]; + }; + writeProfile = name: config: let + config-file = + assert mylib.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 { + name = "alacritty-tv"; + paths = [ + (pkgs.writeDashBin "alacritty" '' + # usage: + # alacritty [--profile=PROFILE] [--singleton] [ARGS...] + # where + # PROFILE one of ${builtins.toJSON (builtins.attrNames configs)} + + set -efu + + case ''${1-} in + ${lib.concatMapStringsSep "\n" (name: /* sh */ '' + --${mylib.shell.escape name}|--profile=${mylib.shell.escape name}) + shift + profile=${writeProfile name configs.${name}} + ;; + '') (builtins.attrNames configs)} + *) + profile=${writeProfile "default" configs.default} + ;; + esac + + + 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 + '') + pkgs.alacritty + ]; +} diff --git a/pkgs/simple/bash-fzf-history.nix b/pkgs/simple/bash-fzf-history.nix new file mode 100644 index 0000000..f35d5e8 --- /dev/null +++ b/pkgs/simple/bash-fzf-history.nix @@ -0,0 +1,107 @@ +{ lib +, pkgs + +, edit-key ? "ctrl-e" +, exec-key ? "enter" +, edit-mark ? "${mark-prefix}${edit-key}" +, exec-mark ? "${mark-prefix}${exec-key}" +, edit-command ? "\"\"" +, exec-command ? "accept-line" +, mark-prefix ? " #FZFKEY:" +, finish-keyseq ? "\\C-x\\C-p" +, rebind-keyseq ? "\\C-x\\C-o" + +, start-keyseq ? "\\C-f" +, load-keyseq ? start-keyseq +}: let + + mylib = import ../../lib/pure.nix { + inherit lib; + }; + + script = pkgs.writeBash "bash-fzf-history.sh" '' + if ! command -v fzf >/dev/null; then + # Alternatively rewrite ${pkgs.fzf}/share/fzf/* to use absolute paths. + fzf() { + ${pkgs.fzf}/bin/fzf "$@" + } + fi + + . ${pkgs.fzf}/share/fzf/key-bindings.bash + . ${pkgs.fzf}/share/fzf/completion.bash + + FZF_DEFAULT_OPTS='${toString [ + /* sh */ "--height=40%" + /* sh */ "--inline-info" + /* sh */ "--min-height=4" + /* sh */ "--reverse" + ]}' + + __fzf_history__() ( + IFS=$'\n' + result=( $( + # To add "unknown timestamps" to each line of the history: + # sed -i '/^#[0-9]/{n;b};s/^/#1\n/' "$HISTFILE" + HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | + ${pkgs.gnused}/bin/sed ' + s/\(\x1b\[[0-9;]*\)244m1970-[0-9T:-]*/\1237m????-??-??T??:??:??/ + ' | + FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--ansi" + /* sh */ "--tac" + /* sh */ "--sync" + /* sh */ "-n2..,.." + /* sh */ "--tiebreak=index" + /* sh */ "--bind=ctrl-r:toggle-sort" + /* sh */ "--expect=${edit-key},${exec-key}" + /* sh */ "$FZF_DEFAULT_OPTS" + /* sh */ "+m" + ]}" \ + ${pkgs.fzf}/bin/fzf | + ${pkgs.gnused}/bin/sed ' + /^ *[0-9]/{ + s/^ *// + s/ \+/\n/;# index + s/ \+/\n/;# date + } + ' + ) ) + if test -n "$result"; then + key=''${result[0]} + index=''${result[1]} + date=''${result[2]} + command=''${result[3]} + + echo "$command${mark-prefix}$key" + else + # Ensure no empty new line gets produced when fzf was aborted. + echo '${edit-mark}' + fi + ) + + __fzf_rebind_finish_keyseq__() { + local suffix= + case $READLINE_LINE in + *'${edit-mark}') + suffix='${edit-mark}' + bind '"${finish-keyseq}": ${edit-command}' + ;; + *'${exec-mark}') + suffix='${exec-mark}' + bind '"${finish-keyseq}": ${exec-command}' + ;; + esac + READLINE_LINE=${"\${READLINE_LINE:0:-\${#suffix}}"} + } + bind -x '"${rebind-keyseq}": __fzf_rebind_finish_keyseq__' + + bind '"\C-r": reverse-search-history' + bind '"${start-keyseq}": " \C-e\C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er\e^${rebind-keyseq}${finish-keyseq}"' + + echo '# fzf key bindings loaded:' >&2 + bind -s | ${pkgs.gnugrep}/bin/grep __fzf_ >&2 + ''; +in + script.overrideAttrs (old: rec { + bind = /* sh */ ''bind -x '"${load-keyseq}": . ${script}' ''; + }) diff --git a/pkgs/simple/cr.nix b/pkgs/simple/cr.nix new file mode 100644 index 0000000..048d779 --- /dev/null +++ b/pkgs/simple/cr.nix @@ -0,0 +1,16 @@ +{ pkgs }: + +pkgs.writeDashBin "cr" '' + set -efu + if test -n "''${XDG_RUNTIME_DIR-}"; then + cache_dir=$XDG_RUNTIME_DIR/chromium-disk-cache + else + cache_dir=/tmp/chromium-disk-cache_$LOGNAME + fi + export LC_TIME=de_DE.utf8 + exec ${pkgs.chromium}/bin/chromium \ + --ssl-version-min=tls1 \ + --disk-cache-dir="$cache_dir" \ + --disk-cache-size=50000000 \ + "$@" +'' diff --git a/pkgs/simple/default.nix b/pkgs/simple/default.nix new file mode 100644 index 0000000..1c4a53b --- /dev/null +++ b/pkgs/simple/default.nix @@ -0,0 +1,22 @@ +self: super: + +let + inherit (super) lib; + + mylib = import ../../lib/pure.nix { + inherit lib; + }; + + # This callPackage will try to detect obsolete overrides. + callPackage = path: args: let + override = self.callPackage path args; + upstream = lib.optionalAttrs (override ? "name") + (super.${(builtins.parseDrvName override.name).name} or {}); + in if upstream ? "name" && + override ? "name" && + builtins.compareVersions upstream.name override.name != -1 + then builtins.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override + else override; +in + + mylib.mapNixDir (path: callPackage path {}) ./. diff --git a/pkgs/simple/diff-so-fancy.nix b/pkgs/simple/diff-so-fancy.nix new file mode 100644 index 0000000..d57e6e7 --- /dev/null +++ b/pkgs/simple/diff-so-fancy.nix @@ -0,0 +1,50 @@ +{ fetchFromGitHub, lib, stdenv +, coreutils, git, makeWrapper, ncurses, perl +}: + +stdenv.mkDerivation rec { + name = "diff-so-fancy-${version}"; + version = "ed8cf17"; + + src = fetchFromGitHub { + owner = "so-fancy"; + repo = "diff-so-fancy"; + rev = "ed8cf1763d38bdd79ceb55a73b9ce7e30f1e184d"; + sha256 = "176qn0w2rn6mr5ymvkblyiznqq7yyibfsnnjfivcyhz69w6yr9r9"; + }; + + # Perl is needed here for patchShebangs + nativeBuildInputs = [ perl makeWrapper ]; + + buildPhase = null; + + installPhase = '' + mkdir -p $out/bin $out/lib/diff-so-fancy + + # diff-so-fancy executable searches for it's library relative to + # itself, so we are copying executable to lib, and only symlink it + # from bin/ + cp diff-so-fancy $out/lib/diff-so-fancy + cp -r lib $out/lib/diff-so-fancy + ln -s $out/lib/diff-so-fancy/diff-so-fancy $out/bin + + # ncurses is needed for `tput` + wrapProgram $out/lib/diff-so-fancy/diff-so-fancy \ + --prefix PATH : "${git}/share/git/contrib/diff-highlight" \ + --prefix PATH : "${git}/bin" \ + --prefix PATH : "${coreutils}/bin" \ + --prefix PATH : "${ncurses.out}/bin" + ''; + + meta = with lib; { + homepage = https://github.com/so-fancy/diff-so-fancy; + description = "Good-looking diffs filter for git"; + license = licenses.mit; + platforms = platforms.all; + longDescription = '' + diff-so-fancy builds on the good-lookin' output of git contrib's + diff-highlight to upgrade your diffs' appearances. + ''; + maintainers = with maintainers; [ fpletz ]; + }; +} diff --git a/pkgs/simple/disko.nix b/pkgs/simple/disko.nix new file mode 100644 index 0000000..de8f1df --- /dev/null +++ b/pkgs/simple/disko.nix @@ -0,0 +1,13 @@ +{ fetchgit }: + +let + src = fetchgit { + url = https://cgit.krebsco.de/disko; + rev = "16cd458af06d3caf687eb7d80ca3df26b71fe28c"; + sha256 = "16cd458af06d3caf687eb7d80ca3df26b71fe28c"; + }; +in + +{ + lib = import "${src}/lib"; +} diff --git a/pkgs/simple/editor-input.nix b/pkgs/simple/editor-input.nix new file mode 100644 index 0000000..931179a --- /dev/null +++ b/pkgs/simple/editor-input.nix @@ -0,0 +1,18 @@ +{ pkgs }: +pkgs.writeDashBin "editor-input" '' + exec \ + ${pkgs.utillinux}/bin/setsid -f \ + ${pkgs.with-tmpdir}/bin/with-tmpdir -t editor-input.XXXXXXXX \ + ${pkgs.writeDash "editor-input.sh" '' + f=$TMPDIR/input + ${pkgs.rxvt_unicode}/bin/urxvt -name editor-input-urxvt -e \ + ${pkgs.vim}/bin/vim --cmd ':set noeol binary' -c startinsert "$f" + if test -e "$f"; then + ${pkgs.xsel}/bin/xsel -ip < "$f" + ${pkgs.xsel}/bin/xsel -ib < "$f" + ${pkgs.xdotool}/bin/xdotool key --clearmodifiers shift+Insert + ${pkgs.xsel}/bin/xsel -dp + ${pkgs.xsel}/bin/xsel -db + fi + ''} +'' diff --git a/pkgs/simple/ff.nix b/pkgs/simple/ff.nix new file mode 100644 index 0000000..b6022c6 --- /dev/null +++ b/pkgs/simple/ff.nix @@ -0,0 +1,8 @@ +{ pkgs }: + +pkgs.writeDashBin "ff" '' + case $TOUCHSCREEN in 1) + export MOZ_USE_XINPUT2=1 + esac + exec ${pkgs.firefox}/bin/firefox "$@" +'' diff --git a/pkgs/simple/field.nix b/pkgs/simple/field.nix new file mode 100644 index 0000000..7136239 --- /dev/null +++ b/pkgs/simple/field.nix @@ -0,0 +1,6 @@ +{ gawk, writeDashBin }: + +writeDashBin "field" '' + set -u + exec ${gawk}/bin/awk -v n="$1" '{print$n}' +'' diff --git a/pkgs/simple/flameshot-once-tv.nix b/pkgs/simple/flameshot-once-tv.nix new file mode 100644 index 0000000..e3a9f9a --- /dev/null +++ b/pkgs/simple/flameshot-once-tv.nix @@ -0,0 +1,48 @@ +{ pkgs }: + +pkgs.flameshot-once.override { + name = "flameshot-once-tv"; + config.imgur.enable = true; + config.imgur.createUrl = "http://ni.r/image"; + config.imgur.deleteUrl = "http://ni.r/image/delete/%1"; + config.imgur.xdg-open.browser = "/etc/profiles/per-user/tv/bin/cr"; + config.settings.General = { + autoCloseIdleDaemon = true; + buttons = [ + "TYPE_ARROW" + "TYPE_CIRCLE" + "TYPE_CIRCLECOUNT" + "TYPE_COPY" + "TYPE_DRAWER" + "TYPE_IMAGEUPLOADER" + "TYPE_MARKER" + "TYPE_MOVESELECTION" + "TYPE_PENCIL" + "TYPE_PIXELATE" + "TYPE_RECTANGLE" + "TYPE_SAVE" + "TYPE_SELECTION" + "TYPE_TEXT" + ]; + checkForUpdates = false; + contrastOpacity = 220; + copyPathAfterSave = true; + disabledTrayIcon = true; + drawColor = "#E4002B"; + drawThickness = 8; + filenamePattern = "%FT%T%z_flameshot"; + fontFamily = "iosevka tv 2"; + savePath = "/tmp"; + savePathFixed = true; + showDesktopNotification = false; + showHelp = false; + showSidePanelButton = false; + showStartupLaunchMessage = false; + squareMagnifier = true; + uploadWithoutConfirmation = true; + }; + config.settings.Shortcuts = { + TYPE_COPY = "Return"; + TYPE_TOGGLE_PANEL = "`"; + }; +} diff --git a/pkgs/simple/font-size-alacritty.nix b/pkgs/simple/font-size-alacritty.nix new file mode 100644 index 0000000..d37f0f0 --- /dev/null +++ b/pkgs/simple/font-size-alacritty.nix @@ -0,0 +1,67 @@ +{ pkgs }: + +pkgs.writeDashBin "font-size-alacritty" '' + # usage: font-size-alacritty (+N|-N|=N) + # Increase by, decrease by, or set font size to the value N. + + set -efu + + min_size=5 + + op=''${1%%[0-9]*} + op=''${op:-=} + + value=''${1#[=+-]} + + window_id=$(${pkgs.xdotool}/bin/xdotool getactivewindow) + + current_size=$( + ${pkgs.xorg.xprop}/bin/xprop -notype -id $window_id FONT_SIZE | + ${pkgs.gnused}/bin/sed -rn 's/.* = ([0-9]+)$/\1/p' + ) + + # usage: set_font_size WINDOW_ID FONT_SIZE + set_font_size() { + ${pkgs.alacritty}/bin/alacritty msg config -w $1 font.size=$2 + ${pkgs.xorg.xprop}/bin/xprop -id $1 -f FONT_SIZE 32c -set FONT_SIZE $2 + } + + # usage: reset_font_size WINDOW_ID + reset_font_size() { + ${pkgs.alacritty}/bin/alacritty msg config -w $1 font.size=$min_size + ${pkgs.xorg.xprop}/bin/xprop -id $1 -remove FONT_SIZE + } + + # usage: make_next_size + make_next_size() { + case $op in + -) next_size=$(expr $current_size - $value) ;; + =) next_size=$value ;; + +) + next_size=$(expr $current_size + $value) + test $next_size -ge $min_size || next_size=$min_size + ;; + esac + } + + if test -z "$current_size"; then + current_size=0 + make_next_size + if test $next_size -ge $min_size; then + ${pkgs.alacritty}/bin/alacritty msg config -w $window_id \ + font.normal.family='Input Mono' \ + font.normal.style=Condensed \ + font.bold.family='Input Mono' \ + font.bold.style=Bold + set_font_size $window_id $next_size + fi + else + make_next_size + if test $next_size -ge $min_size; then + set_font_size $window_id $next_size + else + ${pkgs.alacritty}/bin/alacritty msg config -w $window_id -r + reset_font_size $window_id + fi + fi +'' diff --git a/pkgs/simple/fzmenu/bin/otpmenu b/pkgs/simple/fzmenu/bin/otpmenu new file mode 100755 index 0000000..273a408 --- /dev/null +++ b/pkgs/simple/fzmenu/bin/otpmenu @@ -0,0 +1,44 @@ +#! /bin/sh +set -efu + +#PATH= + +case ${FZMENU_PHASE-0} in + 0) + export FZMENU_PHASE=1 + exec setsid -f terminal dash "$0" + ;; + 1) + if result=$( + PASSWORD_STORE_DIR=${PASSWORD_STORE_DIR-$HOME/.password-store} + FZF_DEFAULT_OPTS=${FZMENU_FZF_DEFAULT_OPTS-} + if test -n "$FZF_DEFAULT_OPTS"; then + export FZF_DEFAULT_OPTS + fi + find -L "$PASSWORD_STORE_DIR" -type f -name 'otp.gpg' | + awk -F / -v PASSWORD_STORE_DIR="$PASSWORD_STORE_DIR" ' + { n = length(PASSWORD_STORE_DIR "/") } + $NF == "otp.gpg" { + print substr($0, 1 + n, length($0)-length("/otp.gpg")-n) + } + ' | + exec fzf \ + --history=/dev/null \ + --no-sort \ + --prompt='OTP: ' \ + ) + then + export FZMENU_PHASE=2 + export FZMENU_RESULT="$result" + setsid -f "$0" + fi + ;; + 2) + pass=$(pass otp code "$FZMENU_RESULT/otp") + printf %s "$pass" | + xdotool type -f - + ;; + *) + echo "$0: error: bad phase: $FZMENU_PHASE" >&2 + exit -1 +esac diff --git a/pkgs/simple/fzmenu/bin/passmenu b/pkgs/simple/fzmenu/bin/passmenu new file mode 100755 index 0000000..76153f5 --- /dev/null +++ b/pkgs/simple/fzmenu/bin/passmenu @@ -0,0 +1,45 @@ +#! /bin/sh +set -efu + +#PATH= + +case ${FZMENU_PHASE-0} in + 0) + export FZMENU_PHASE=1 + exec setsid -f terminal dash "$0" + ;; + 1) + if result=$( + PASSWORD_STORE_DIR=${PASSWORD_STORE_DIR-$HOME/.password-store} + FZF_DEFAULT_OPTS=${FZMENU_FZF_DEFAULT_OPTS-} + if test -n "$FZF_DEFAULT_OPTS"; then + export FZF_DEFAULT_OPTS + fi + find -L "$PASSWORD_STORE_DIR" -type f -name '*.gpg' | + awk -F / -v PASSWORD_STORE_DIR="$PASSWORD_STORE_DIR" ' + { n = length(PASSWORD_STORE_DIR "/") } + $NF == "otp.gpg" { next } + /.*\.gpg$/ { + print substr($0, 1 + n, length($0)-length(".gpg")-n) + } + ' | + exec fzf \ + --history=/dev/null \ + --no-sort \ + --prompt='pass: ' \ + ) + then + export FZMENU_PHASE=2 + export FZMENU_RESULT="$result" + setsid -f "$0" + fi + ;; + 2) + pass=$(pass show "$FZMENU_RESULT") + printf %s "$pass" | + xdotool type -f - + ;; + *) + echo "$0: error: bad phase: $FZMENU_PHASE" >&2 + exit -1 +esac diff --git a/pkgs/simple/fzmenu/default.nix b/pkgs/simple/fzmenu/default.nix new file mode 100644 index 0000000..1a285ee --- /dev/null +++ b/pkgs/simple/fzmenu/default.nix @@ -0,0 +1,50 @@ +{ 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 + + cp -r ${./bin} $out/bin + + substituteInPlace $out/bin/otpmenu \ + --replace '#! /bin/sh' '#! ${pkgs.dash}/bin/dash' \ + --replace '#PATH=' PATH=${lib.makeBinPath [ + pkgs.coreutils + pkgs.dash + pkgs.findutils + pkgs.fzf + pkgs.gawk + (pkgs.pass.withExtensions (ext: [ + ext.pass-otp + ])) + pkgs.utillinux + pkgs.xdotool + terminal + ]} + + substituteInPlace $out/bin/passmenu \ + --replace '#! /bin/sh' '#! ${pkgs.dash}/bin/dash' \ + --replace '#PATH=' PATH=${lib.makeBinPath [ + pkgs.coreutils + pkgs.dash + pkgs.findutils + pkgs.fzf + pkgs.gawk + (pkgs.pass.withExtensions (ext: [ + ext.pass-otp + ])) + pkgs.utillinux + pkgs.xdotool + terminal + ]} +'' diff --git a/pkgs/simple/hc.nix b/pkgs/simple/hc.nix new file mode 100644 index 0000000..086445e --- /dev/null +++ b/pkgs/simple/hc.nix @@ -0,0 +1,39 @@ +{ fetchgit, lib, makeWrapper, stdenv +, coreutils, findutils, gawk, gnugrep, qrencode, texlive, utillinux, zbar +}: + +stdenv.mkDerivation rec { + name = "hc-${meta.version}"; + + src = fetchgit { + url = "https://cgit.krebsco.de/hc"; + rev = "refs/tags/v${meta.version}"; + sha256 = "09349gja22p0j3xs082kp0fnaaada14bafszn4r3q7rg1id2slfb"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + buildPhase = null; + + installPhase = '' + mkdir -p $out/bin + + cp $src/bin/hc $out/bin/hc + + wrapProgram $out/bin/hc \ + --prefix PATH : ${lib.makeBinPath [ + coreutils + findutils + gawk + gnugrep + qrencode + texlive.combined.scheme-full + utillinux + zbar + ]} + ''; + + meta = { + version = "1.0.0"; + }; +} diff --git a/pkgs/simple/iosevka-tv-1.nix b/pkgs/simple/iosevka-tv-1.nix new file mode 100644 index 0000000..0f8b4d4 --- /dev/null +++ b/pkgs/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/pkgs/simple/iosevka-tv-2.nix b/pkgs/simple/iosevka-tv-2.nix new file mode 100644 index 0000000..888ba6a --- /dev/null +++ b/pkgs/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/pkgs/simple/libinput-tv.nix b/pkgs/simple/libinput-tv.nix new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/pkgs/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/pkgs/simple/mpvterm/default.nix b/pkgs/simple/mpvterm/default.nix new file mode 100644 index 0000000..66ad08a --- /dev/null +++ b/pkgs/simple/mpvterm/default.nix @@ -0,0 +1,8 @@ +{ pkgs }: + +pkgs.mpv-unwrapped.overrideAttrs (old: rec { + pname = "mpvterm"; + patches = old.patches or [] ++ [ + ./mpvterm.patch + ]; +}) diff --git a/pkgs/simple/mpvterm/mpvterm.patch b/pkgs/simple/mpvterm/mpvterm.patch new file mode 100644 index 0000000..1263688 --- /dev/null +++ b/pkgs/simple/mpvterm/mpvterm.patch @@ -0,0 +1,146 @@ +commit 5ded4dac370ce5d8d727c5d3891448f942edbfdf +Author: tv +Date: Sat Feb 27 22:54:55 2021 +0100 + + x11: add input forwarding support + +diff --git a/video/out/x11_common.c b/video/out/x11_common.c +index ac551fae8e..2e95451d7f 100644 +--- a/video/out/x11_common.c ++++ b/video/out/x11_common.c +@@ -25,6 +25,10 @@ + #include + #include + ++#include ++#include ++#include ++ + #include + #include + #include +@@ -1097,6 +1101,73 @@ static void release_all_keys(struct vo *vo) + x11->win_drag_button1_down = false; + } + ++ ++#define FORWARD_START 1 ++#define FORWARD_READY 2 ++#define FORWARD_ERROR 3 ++static int forward_state = FORWARD_START; ++static int forward_fd, forward_len; ++static struct sockaddr_un forward_un; ++static char forward_buf[BUFSIZ]; ++ ++static void forward_start(void) { ++ const char *socket_path = getenv("FORWARD_SOCKET"); ++ if (socket_path == NULL) { ++ fprintf(stderr, "forward_start: environment variable FORWARD_SOCKET not set\n"); ++ forward_state = FORWARD_ERROR; ++ return; ++ } ++ ++ if ((forward_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) { ++ perror("socket"); ++ } else { ++ memset(&forward_un, 0, sizeof(forward_un)); ++ forward_un.sun_family = AF_UNIX; ++ strcpy(forward_un.sun_path, socket_path); ++ forward_len = offsetof(struct sockaddr_un, sun_path) + strlen(socket_path); ++ forward_state = FORWARD_READY; ++ } ++} ++static void forward_send(const char *fmt, ...) { ++ if (forward_state != FORWARD_READY) return; ++ ++ va_list argp; ++ va_start(argp, fmt); ++ int n1 = vsnprintf(forward_buf, BUFSIZ, fmt, argp); ++ if (n1 < BUFSIZ + 1) { ++ forward_buf[n1++] = '\n'; ++ forward_buf[n1] = '\0'; ++ int n2 = sendto(forward_fd, forward_buf, n1, 0, (struct sockaddr *)&forward_un, forward_len); ++ if (n2 < 0) { ++ perror("sendto"); ++ } ++ } ++} ++static const char *forward_keyname(KeySym keySym) { ++ const char *name; ++ if (keySym == NoSymbol) { ++ name = "NoSymbol"; ++ } else if (!(name = XKeysymToString(keySym))) { ++ name = "NoName"; ++ } ++ return name; ++} ++static void forward_keydown(KeySym keySym) { ++ forward_send("xdotool keydown %s", forward_keyname(keySym)); ++} ++static void forward_keyup(KeySym keySym) { ++ forward_send("xdotool keyup %s", forward_keyname(keySym)); ++} ++static void forward_mousedown(int button) { ++ forward_send("xdotool mousedown %d", button); ++} ++static void forward_mouseup(int button) { ++ forward_send("xdotool mouseup %d", button); ++} ++static void forward_mousemove(int x, int y) { ++ forward_send("xdotool mousemove %d %d", x, y); ++} ++ + void vo_x11_check_events(struct vo *vo) + { + struct vo_x11_state *x11 = vo->x11; +@@ -1105,6 +1176,10 @@ void vo_x11_check_events(struct vo *vo) + + xscreensaver_heartbeat(vo->x11); + ++ if (forward_state == FORWARD_START) { ++ forward_start(); ++ } ++ + while (XPending(display)) { + XNextEvent(display, &Event); + MP_TRACE(x11, "XEvent: %d\n", Event.type); +@@ -1146,6 +1221,7 @@ void vo_x11_check_events(struct vo *vo) + if (mpkey) + mp_input_put_key(x11->input_ctx, mpkey | modifiers); + } ++ forward_keydown(XLookupKeysym(&Event.xkey, 0)); + break; + } + case FocusIn: +@@ -1161,6 +1237,7 @@ void vo_x11_check_events(struct vo *vo) + break; + case KeyRelease: + release_all_keys(vo); ++ forward_keyup(XLookupKeysym(&Event.xkey, 0)); + break; + case MotionNotify: + if (x11->win_drag_button1_down && !x11->fs && +@@ -1182,6 +1259,7 @@ void vo_x11_check_events(struct vo *vo) + Event.xmotion.y); + } + x11->win_drag_button1_down = false; ++ forward_mousemove(Event.xmotion.x, Event.xmotion.y); + break; + case LeaveNotify: + if (Event.xcrossing.mode != NotifyNormal) +@@ -1204,6 +1282,7 @@ void vo_x11_check_events(struct vo *vo) + get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN); + long msg[4] = {XEMBED_REQUEST_FOCUS}; + vo_x11_xembed_send_message(x11, msg); ++ forward_mousedown(Event.xbutton.button); + break; + case ButtonRelease: + if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT) +@@ -1213,6 +1292,7 @@ void vo_x11_check_events(struct vo *vo) + mp_input_put_key(x11->input_ctx, + (MP_MBTN_BASE + Event.xbutton.button - 1) | + get_mods(Event.xbutton.state) | MP_KEY_STATE_UP); ++ forward_mouseup(Event.xbutton.button); + break; + case MapNotify: + x11->window_hidden = false; diff --git a/pkgs/simple/pinentry-urxvt/default.nix b/pkgs/simple/pinentry-urxvt/default.nix new file mode 100644 index 0000000..7363f26 --- /dev/null +++ b/pkgs/simple/pinentry-urxvt/default.nix @@ -0,0 +1,127 @@ +{ lib, pkgs, ... }@args: + +let + mylib = import ../../../lib/pure.nix { + inherit lib; + }; + + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; + + cfg = eval.config; + + eval = lib.evalModules { + modules = lib.singleton { + _file = toString ./default.nix; + imports = lib.singleton config; + options = { + appName = lib.mkOption { + default = "pinentry-urxvt"; + type = lib.types.str; + }; + display = lib.mkOption { + default = null; + type = lib.types.nullOr lib.types.str; + }; + xwud.className = lib.mkOption { + default = "PinentryUrxvtXwudFloat"; + type = lib.types.str; + }; + }; + }; + }; + + +in + + # pinentry-urxvt - A mechanism for PIN entry utilizing rxvt-unicode + # + # This spawns a PIN entry terminal on top of a tinted screenshot of the + # current display's root window. The display for spawning the terminal can + # be predefined, in which case both the current and the predefined display + # will show the screenshot. + # + # The purpose of the screenshot, aside from looking nice, is to prevent entry + # of the PIN into the wrong window, e.g. by accidentally moving the cursor + # while typing. If necessary, the screenshot can be closed by sending 'q', + # 'Q', or ctrl-c while its focused. + # + pkgs.write "pinentry-urxvt" { + "/bin/pinentry".link = pkgs.writeDash "pinentry-urxvt-wrapper" '' + set -efu + + trap cleanup EXIT + + cleanup() { + ${pkgs.utillinux}/bin/kill -- $(${pkgs.coreutils}/bin/cat "$displayers") + rm "$displayers" + rm "$screenshot" + } + + displayers=$(${pkgs.coreutils}/bin/mktemp -t pinentry-urxvt.$$.displayers.XXXXXXXX) + screenshot=$(${pkgs.coreutils}/bin/mktemp -t pinentry-urxvt.$$.screenshot.XXXXXXXX) + + ${pkgs.xorg.xwd}/bin/xwd -root | + ${pkgs.imagemagick}/bin/convert xwd:- -fill \#424242 -colorize 80% xwd:"$screenshot" + + display_screenshot() { + ${pkgs.exec "pinentry-urxvt.display_screenshot" { + filename = "${pkgs.xorg.xwud}/bin/xwud"; + argv = [ + cfg.xwud.className + "-noclick" + ]; + }} < "$screenshot" & + wait_for_screenshot $! && echo $! >>"$displayers" + } + + # Wait for the xwud window by trying to intercept the call to munmap(). + # If it cannot be intercepted within 0.1s, assume that attaching strace + # wasn't fast enough or xwud doesn't call munmap() anymore. In either + # case fall back to search the window by class name, assuming there can + # be only one per display. + wait_for_screenshot() { + if ! \ + ${pkgs.coreutils}/bin/timeout 0.1 \ + ${pkgs.strace}/bin/strace -p "$1" -e munmap 2>&1 | + read -r _ + then + until ${pkgs.xdotool}/bin/xdotool search \ + --classname ${mylib.shell.escape cfg.xwud.className} + do + ${pkgs.coreutils}/bin/sleep 0.1 + done + fi + } + + display_screenshot + + ${lib.optionalString (cfg.display != null) /* sh */ '' + if test "$DISPLAY" != ${mylib.shell.escape cfg.display}; then + export DISPLAY=${mylib.shell.escape cfg.display} + display_screenshot + fi + ''} + + exec 3<&0 4>&1 5>&2 + ${pkgs.rxvt_unicode}/bin/urxvt \ + -name ${mylib.shell.escape cfg.appName} \ + -e ${pkgs.writeDash "pinentry-urxvt-tty" '' + set -efu + exec 2>&5 + TTY=$(${pkgs.coreutils}/bin/tty) + while read -r line <&3; do + case $line in + 'OPTION ttyname='*) + echo "OPTION ttyname=$TTY" + ;; + *) + echo "$line" + esac + done | ${pkgs.pinentry.tty}/bin/pinentry-tty "$@" >&4 + ''} \ + "$@" + ''; + } diff --git a/pkgs/simple/q/default.nix b/pkgs/simple/q/default.nix new file mode 100644 index 0000000..03e924e --- /dev/null +++ b/pkgs/simple/q/default.nix @@ -0,0 +1,176 @@ +{ lib +, pkgs +}: +let + mylib = import ../../../lib/pure.nix { + inherit lib; + }; + + q-cal = let + + # 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; + + in /* sh */ '' + cols=$(${pkgs.ncurses}/bin/tput cols) + 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])(( ..| \[7m..\[27m){7})/\1\3/g + # dim month and day names + s/^ *[A-Z].*/&/ + # highlight current date + s/\[7m// + s/\[27m// + ' + ''; + + q-isodate = TZ: color: /* sh */ '' + TZ=${mylib.shell.escape TZ} \ + ${pkgs.coreutils}/bin/date \ + '+%Y-%m-%dT[;'${mylib.shell.escape color}'m%H:%M:%S%:z' + ''; + + q-deudate = q-isodate "Europe/Berlin" "38;5;085"; + + # Singapore's red is #ED2E38 + q-sgtdate = q-isodate "Asia/Singapore" "38;2;237;46;56"; + + 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 + #git status --porcelain + branch=$( + ${pkgs.git}/bin/git branch \ + | ${pkgs.gnused}/bin/sed -rn 's/^\* (.*)/\1/p' + ) + echo "± $LOGNAME@''${HOSTNAME-$(${pkgs.nettools}/bin/hostname)}:$PWD .git $branch" + fi + ''; + + q-intel_backlight = /* sh */ '' + cd /sys/class/backlight/intel_backlight + &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 + wait + ''; + + 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) + printf '%s %s°C\n' $type $(echo $temp / 1000 | ${pkgs.bc}/bin/bc) + done + ''; + + q-todo = /* sh */ '' + TODO_file=$PWD/TODO + if test -e "$TODO_file"; then + ${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) | + + ($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 + ''} + else + echo "$TODO_file: no such file or directory" + fi + ''; + +in +# bash needed for <(...) +pkgs.writeBashBin "q" '' + set -eu + export PATH=/var/empty + ${q-cal} + ${q-utcdate} + ${q-deudate} + ${q-sgtdate} + (${q-gitdir}) & + (${q-intel_backlight}) & + ${pkgs.q-power_supply}/bin/q-power_supply & + (${q-virtualization}) & + (${q-net}) & + (${q-thermal_zone}) & + wait + if test "$PWD" != "$HOME" && test -e "$HOME/TODO"; then + TODO_home_entries=$(cd; (${q-todo}) | ${pkgs.coreutils}/bin/wc -l) + if test "$TODO_home_entries" = 1; then + TODO_format='There is %d entry in ~/TODO' + else + TODO_format='There are %d entries in ~/TODO' + fi + printf "\x1b[38;5;238m$TODO_format\x1b[m\n" "$TODO_home_entries" + fi + (${q-todo}) || : +'' diff --git a/pkgs/simple/rox-filer.nix b/pkgs/simple/rox-filer.nix new file mode 100644 index 0000000..b380bdf --- /dev/null +++ b/pkgs/simple/rox-filer.nix @@ -0,0 +1,95 @@ +{ fetchFromGitLab, lib, stdenv +, autoconf, pkgconfig, libxml2, libSM, shared-mime-info +, libxslt, docbook_xml_dtd_412, docbook_xsl +, gtk ? gtk2, gtk2 +}: + +stdenv.mkDerivation { + pname = "rox-filer"; + version = "2.11-tv"; + + src = fetchFromGitLab { + owner = "seirios"; + repo = "rox-filer"; + rev = "3c3ad5d85a1ab548574bf450f730886b60092587"; + sha256 = "0h743zpx1v9rrsaxn0q3nwpq8wkjf6icgzrg8jpqldsphw3ygkhr"; + }; + + nativeBuildInputs = [ + autoconf + docbook_xsl + libxslt + pkgconfig + ]; + + buildInputs = [ libxml2 gtk shared-mime-info libSM ]; + + # go to the source directory after unpacking the sources + setSourceRoot = "export sourceRoot=source/ROX-Filer"; + + # patch the main.c to disable the lookup of the APP_DIR environment variable, + # which is used to lookup the location for certain images when rox-filer + # starts; rather override the location with an absolute path to the directory + # where images are stored to prevent having to use a wrapper, which sets the + # APP_DIR environment variable prior to starting rox-filer + preConfigure = '' + (cd src && autoconf) + sed -i -e "s:g_strdup(getenv(\"APP_DIR\")):\"$out\":" src/main.c + mkdir build + cd build + ''; + + preBuild = '' + for f in \ + ../src/Docs/Manual.xml \ + ../src/Docs/Manual-fr.xml \ + ../src/Docs/Manual-it.xml ; + do + substituteInPlace "$f" \ + --replace \ + /usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd \ + ${docbook_xml_dtd_412}/xml/dtd/docbook/docbookx.dtd + done + make -C ../src/Docs MAN=.. || exit 1 + ''; + + configureScript = "../src/configure"; + + installPhase = '' + mkdir -p "$out" + cd .. + cp -av Help Messages Options.xml ROX images style.css .DirIcon "$out" + + mkdir -p "$out/share/man/man1" + cp -av src/rox.1 "$out/share/man/man1" + + # the main executable + mkdir "$out/bin/" + cp -v ROX-Filer "$out/bin/rox" + + # mime types + mkdir -p "$out/ROX/MIME" + cd "$out/ROX/MIME" + ln -sv text-x-{diff,patch}.png + ln -sv application-x-font-{afm,type1}.png + ln -sv application-xml{,-dtd}.png + ln -sv application-xml{,-external-parsed-entity}.png + ln -sv application-{,rdf+}xml.png + ln -sv application-x{ml,-xbel}.png + ln -sv application-{x-shell,java}script.png + ln -sv application-x-{bzip,xz}-compressed-tar.png + ln -sv application-x-{bzip,lzma}-compressed-tar.png + ln -sv application-x-{bzip-compressed-tar,lzo}.png + ln -sv application-x-{bzip,xz}.png + ln -sv application-x-{gzip,lzma}.png + ln -sv application-{msword,rtf}.png + ''; + + meta = with lib; { + description = "Fast, lightweight, gtk2 file manager"; + homepage = "http://rox.sourceforge.net/desktop"; + license = with licenses; [ gpl2 lgpl2 ]; + platforms = platforms.linux; + maintainers = [ maintainers.eleanor ]; + }; +} diff --git a/pkgs/simple/rxvt-unicode-256color-terminfo/default.nix b/pkgs/simple/rxvt-unicode-256color-terminfo/default.nix new file mode 100644 index 0000000..d2f6f46 --- /dev/null +++ b/pkgs/simple/rxvt-unicode-256color-terminfo/default.nix @@ -0,0 +1,16 @@ +# This package is mainly intended for cross-built systems for which we cannot +# or don't want to build pkgs.rxvt_unicode for some reason. +# +# ${./rxvt-unicode-256color.terminfo} was copied from a previously built +# /run/current-system/sw/share/terminfo/r/rxvt-unicode-256color +{ runCommand }: + +runCommand "rxvt-unicode-256color-terminfo" {} /* sh */ '' + mkdir -p $out/nix-support + mkdir -p $out/share/terminfo/r + + ln -s ${./rxvt-unicode-256color.terminfo} \ + $out/share/terminfo/r/rxvt-unicode-256color + + echo "$out" >> $out/nix-support/propagated-user-env-packages +'' diff --git a/pkgs/simple/rxvt-unicode-256color-terminfo/rxvt-unicode-256color.terminfo b/pkgs/simple/rxvt-unicode-256color-terminfo/rxvt-unicode-256color.terminfo new file mode 100644 index 0000000..3f43d0d Binary files /dev/null and b/pkgs/simple/rxvt-unicode-256color-terminfo/rxvt-unicode-256color.terminfo differ diff --git a/pkgs/simple/stardict/default.nix b/pkgs/simple/stardict/default.nix new file mode 100644 index 0000000..2135cc0 --- /dev/null +++ b/pkgs/simple/stardict/default.nix @@ -0,0 +1,235 @@ +{ lib, pkgs }: +let + classicsDictionaries = { + Pape = pkgs.fetchzip { + url = "http://tovotu.de/data/stardict/pape_gr-de.zip"; + sha256 = "1kmbdjqinrcxkc6jdyyrq5rl2wzhnrychyynnh91yhrjwjxlh44k"; + }; + Woodhouse = pkgs.fetchzip { + url = "https://c.krebsco.de/Woodhouse.zip"; + sha256 = "1dvnc2679yb048q2f3hr2h34acvhan0n3iir6h9ajlrdzz48mlkq"; + stripRoot = false; + }; + LSJ = pkgs.fetchzip { + url = "https://github.com/nikita-moor/latin-dictionary/releases/download/2020-02-14/LiddellScott1940-stardict.zip"; + sha256 = "13rprgd9jvnhxk9735c91xr6ywr0j5jiwkjnpm3qpvy93isyjbys"; + }; + GreekMorphology = pkgs.fetchzip { + url = "https://github.com/latin-dict/Morphologia-Graeca/releases/download/v0.5/morphology-mobile-goldendict.oxia.zip"; + sha256 = "0m75cppjjjmvv18cs7yh9f4p7ckqzxfznnndgkiw3yrfd50k8p96"; + }; + Frisk = pkgs.fetchzip { + url = "https://github.com/latin-dict/Frisk1960/releases/download/v1.1/Frisk1960-stardict.zip"; + sha256 = "1rk5a3n3fpfdcmg4bc5945m88s6ldxql8cjn4jqs33rgklh7n046"; + }; + Georges-De-Lat = pkgs.fetchzip { + url = "http://tovotu.de/data/stardict/georges_de-lat.zip"; + sha256 = "1gx4vv64bi9lxw2zgd861j469jvw4f2hhfwy1gglb12id8r7rdrl"; + }; + Georges-Lat-De = pkgs.fetchzip { # TODO find out why this does not work with sdcv + url = "http://tovotu.de/data/stardict/georges_lat-de.zip"; + sha256 = "0cc5xipn60anxvq8z2mw53d4gi1k92wbrj9m4ws3g9rh87fmkvgz"; + }; + LewisShort = pkgs.fetchzip { + url = "https://github.com/latin-dict/LewisShort1879/releases/download/v1.3/LewisShort1879-stardict.zip"; + sha256 = "1y3ans47iv8bzzb1paimdqvcid8ms04ikjbqy3iw077i2js3qbjk"; + }; + DoederleinSynonymes = pkgs.fetchzip { + url = "https://github.com/latin-dict/Doederlein1874/releases/download/v1.1/Doederlein1875-stardict.zip"; + sha256 = "0mhik7gjxl8ncr9g5z2l4pfk60k1c5n0gc1w0cnp2x1v6lqvb57h"; + }; + }; + + englishGermanDictionaries = { + Etymonline = pkgs.fetchzip { + url = "http://tovotu.de/data/stardict/etymonline.zip"; + sha256 = "1bjja3n3layfd08xa1r0a6375dxh5zi6hlv7chkhgnx800cx7hxn"; + }; + Roget = builtins.fetchTarball { + url = "http://download.huzheng.org/bigdict/stardict-Roget_s_II_The_New_Thesaurus_3th_Ed-2.4.2.tar.bz2"; + sha256 = "1szyny9497bpyyccf9l5kr3bnw0wvl4cnsd0n1zscxpyzlsrqqbz"; + }; + JargonFile = builtins.fetchTarball { + url = "http://download.huzheng.org/dict.org/stardict-dictd-jargon-2.4.2.tar.bz2"; + sha256 = "096phar9qpmm0fnaqv5nz8x9lpxwnfj78g4vjfcfyd7kqp7iqla4"; + }; + Oxford-Collocations = builtins.fetchTarball { + url = "http://download.huzheng.org/bigdict/stardict-Oxford_Collocations_Dictionary_2nd_Ed-2.4.2.tar.bz2"; + sha256 = "1zkfs0zxkcn21z2lhcabrs77v4ma9hpv7qm119hpyi1d8ajcw07q"; + }; + Langenscheidt-Deu-En = builtins.fetchTarball { + url = "http://download.huzheng.org/babylon/german/stardict-Handw_rterbuch_Deutsch_Englisc-2.4.2.tar.bz2"; + sha256 = "12q9i5azq7ylyrpb6jqbaf1rxalc3kzcwjvbinvb0yabdxb80y30"; + }; + Langenscheidt-En-Deu = builtins.fetchTarball { + url = "http://download.huzheng.org/babylon/german/stardict-Handw_rterbuch_Englisch_Deutsc-2.4.2.tar.bz2"; + sha256 = "087b05h155j5ldshfgx91pz81h6ijq2zaqjirg7ma8ig3l96zb59"; + }; + Duden_Das_Fremdworterbuch = builtins.fetchTarball { + url = "http://download.huzheng.org/babylon/german/stardict-Duden_Das_Fremdworterbuch-2.4.2.tar.bz2"; + sha256 = "1zrcay54ccl031s6dvjwsah5slhanmjab87d81rxlcy8fx0xd8wq"; + }; + Duden_De_De = builtins.fetchTarball { + url = "http://download.huzheng.org/babylon/german/stardict-Duden_De_De-2.4.2.tar.bz2"; + sha256 = "1fhay04w5aaj83axfmla2ql34nb60gb05dgv0k94ig7p8x4yxxlf"; + }; + ConciseOED = builtins.fetchTarball { + url = "http://download.huzheng.org/bigdict/stardict-Concise_Oxford_English_Dictionary-2.4.2.tar.bz2"; + sha256 = "19kpcxbhqzpmhi94mp48nalgmsh6s7rsx1gb4kwkhirp2pbjcyl7"; + }; + # Duden_Rechtschreibung = builtins.fetchTarball { + # url = "http://download.huzheng.org/babylon/german/stardict-Duden_Rechtschreibung-2.4.2.tar.bz2"; + # sha256 = "0xiprb45s88w62rn8rlbjrsagbiliay9hszsiy20glwabf6zsfji"; + # }; + Duden_Synonym = builtins.fetchTarball { + url = "http://download.huzheng.org/babylon/german/stardict-Duden_Synonym-2.4.2.tar.bz2"; + sha256 = "0cx086zvb86bmz7i8vnsch4cj4fb0cp165g4hig4982zakj6f2jd"; + }; + # Duden = builtins.fetchTarball { + # url = "http://download.huzheng.org/de/stardict-duden-2.4.2.tar.bz2"; + # sha256 = "049i4ynfqqxykv1nlkyks94mvn14s22qdax5gg7hx1ks5y4xw64j"; + # }; + # FreeOnlineDictionaryOfComputing = builtins.fetchTarball { + # url = "http://download.huzheng.org/dict.org/stardict-dictd_www.dict.org_foldoc-2.4.2.tar.bz2"; + # sha256 = "1lw2i8dzxpx929cpgvv0x366dnh4drr10wzqmrhcd0kvwglqawgm"; + # }; + }; + + sanskritDictionaries = { + BoehtlingkRoth = pkgs.fetchzip { + url = "https://c.krebsco.de/Bohtlingk-and-Roth-Grosses-Petersburger-Worterbuch.zip"; + sha256 = "13414a8rgd7hd5ffar6nl68nk3ys60wjkgb7m11hp0ahaasmf6ly"; + stripRoot = false; + }; + MonierWilliams = pkgs.fetchzip { + url = "https://c.krebsco.de/mw-cologne.zip"; + sha256 = "0p99ybxwxmmd94hf035hvm2hhnfy84av7qq79xf28bh2rbx6s9ng"; + stripRoot = false; + }; + MonierWilliamsEnglish = pkgs.fetchzip { + url = "https://c.krebsco.de/mw-english-sanskrit.zip"; + sha256 = "09a61hhii4b1m2fkrlh4rm2xnlgwrllh84iypbc6wyj00w9jkl3x"; + stripRoot = false; + }; + }; + + swahiliDictionaries = { + vickio = pkgs.fetchzip { + url = "http://swahili.vickio.net/files/Swahili-English.zip"; + sha256 = "0m6wkwc83fcim43ijn17lcsda4clkra587gxaz6m59qd0yfwzakw"; + stripRoot = false; + }; + }; + + makeStardictDataDir = dicts: pkgs.linkFarm "dictionaries" (lib.mapAttrsToList (name: path: { inherit name path; }) dicts); + + sdcvPager = pkgs.writeDash "sdcvPager" '' + export PATH=${lib.makeBinPath [pkgs.gnused pkgs.ncurses]} + sed " + s! style=\"color: #...\"!!g; + s!\([^<>]*\)!\1!g; + s!]*>!!g; + s!!!g; + s!\([^<>]*\)!\1 !g; + s!\([^<>]*\)!$(tput sitm)\2$(tput sgr0)!g; + s!\([^<>]*\)!\1!g; + s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g; + s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g; + s!]*>\([^<>]*\)!$(tput sitm)\1$(tput sgr0)!g; + s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0) !g; + s!\([^<>]*\)!$(tput sitm)\1$(tput sgr0) !g; + s!\([^<>]*\)!$(tput setaf 3)\1$(tput sgr0)!g; + s!\([^<>]*\)!$(tput bold)\1$(tput sgr0)\t!g; + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!$(tput sitm)!g + s!]*>!$(tput sgr0)!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!]*>!!g + s!!!g + s!]*>!$(tput setaf 245)!g + s!]*>!$(tput sgr0)!g + s/
/$(tput bold)/g; + s:
:$(tput sgr0):g; + s/
/\n/g; + s:
::g; + s/<[bB]>/$(tput bold)/g; + s::$(tput sgr0):g; + s:<[bB][rR]\s*/\?>:\n:g; + s:<[iI]>:$(tput sitm):g; + s::$(tput sgr0):g; + s:<[uU]>:$(tput smul):g; + s::$(tput sgr0):g; + s:]*>::g; + s:::g; + s!\([^<>]*\)!$(tput bold)\1$(tput sgr0)!g; + s!\([^<>]*\)!\2!g + s#
\(.*\)
#\\1#g; + s:\([^<>]*\):$(tput setaf 3)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput setaf 4)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput setaf 1)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput setaf 5)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput bold)\1$(tput sgr0):g + s:\([^<>]*\):$(tput setaf 3)\1$(tput sgr0):g + s:':':g + s:<:<:g + s:>:>:g + s:\([^<>]*\):$(tput setaf 2)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput setaf 2)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput setaf 4)\\1$(tput sgr0):g; + s:\([^<>]*\):$(tput bold)\\1$(tput sgr0):g; + s:]*>:ː:g; + s:]*>::g; + s!!!g + s!]*>!!g + s!!!g + s!]*>!!g + s!]*>!!g + s!\([^<>]*\)!$(tput setaf 245)\1$(tput sgr0)!g + s!]*>!!g + s! +! !g; + s!
!\n\n&!g + s!]*>!!g + s!]*>!!g + s!!!g # unbalanced in Frisk + s!^\s*[0-9])!$(tput setaf 5)&$(tput sgr0)!g + s#^\(-->.*\)\$#$(tput bold)\1$(tput sgr0)# + " + ''; + + mkDictBin = name: dicts: + pkgs.writers.writeDashBin name '' + set -efu + export SDCV_PAGER=${toString sdcvPager} + exec ${pkgs.sdcv}/bin/sdcv --data-dir ${makeStardictDataDir dicts} "$@" + ''; +in + +pkgs.symlinkJoin { + name = "stardict"; + paths = [ + (mkDictBin "sd-classics" classicsDictionaries) + (mkDictBin "sd-sanskrit" sanskritDictionaries) + (mkDictBin "sd-swahili" swahiliDictionaries) + (mkDictBin "sd" englishGermanDictionaries) + ]; +} diff --git a/pkgs/simple/viljetic-pages/default.nix b/pkgs/simple/viljetic-pages/default.nix new file mode 100644 index 0000000..ee07c92 --- /dev/null +++ b/pkgs/simple/viljetic-pages/default.nix @@ -0,0 +1,17 @@ +{ pkgs, stdenv, ... }: + +stdenv.mkDerivation { + name = "viljetic-pages-0"; + phases = [ + "installPhase" + ]; + buildInputs = with pkgs; [ + imagemagick + ]; + installPhase = '' + mkdir -p $out + cp ${./index.html} $out/index.html + convert ${./logo.xpm} $out/favicon.ico + convert ${./logo.xpm} $out/favicon2.png + ''; +} diff --git a/pkgs/simple/viljetic-pages/index.html b/pkgs/simple/viljetic-pages/index.html new file mode 100644 index 0000000..c268cb9 --- /dev/null +++ b/pkgs/simple/viljetic-pages/index.html @@ -0,0 +1,11 @@ + +blank page + +This page intentionally left blank. + diff --git a/pkgs/simple/viljetic-pages/logo.xpm b/pkgs/simple/viljetic-pages/logo.xpm new file mode 100644 index 0000000..bb263da --- /dev/null +++ b/pkgs/simple/viljetic-pages/logo.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *meh[] = { +/* columns rows colors chars-per-pixel */ +"16 16 2 1 ", +" c black", +". c None", +/* pixels */ +"................", +". ...... .", +". .. ...... .. .", +". .. ...... .. .", +". ...... .", +"................", +". . . .", +". .. . .. . .", +". .. . .. . .", +". . . .", +"................", +"...... . .", +"...... . .", +"...... . .", +"...... . .", +"................" +}; diff --git a/pkgs/simple/weechat-tv.nix b/pkgs/simple/weechat-tv.nix new file mode 100644 index 0000000..17d2863 --- /dev/null +++ b/pkgs/simple/weechat-tv.nix @@ -0,0 +1,9 @@ +{ lib, pkgs }: + +pkgs.wrapWeechat pkgs.weechat-unwrapped { + configure = { availablePlugins, ... }: { + scripts = [ + pkgs.weechatScripts.weechat-matrix + ]; + }; +} diff --git a/pkgs/simple/xdpytools/default.nix b/pkgs/simple/xdpytools/default.nix new file mode 100644 index 0000000..7d1ee07 --- /dev/null +++ b/pkgs/simple/xdpytools/default.nix @@ -0,0 +1,31 @@ +{ lib, pkgs }: + +let + install = name: { path }: /* sh */ '' + ( + mkdir -p $out/bin + touch $out/bin/${name} + chmod +x $out/bin/${name} + exec >$out/bin/${name} + + echo '#! ${pkgs.dash}/bin/dash' + echo export PATH=${lib.makeBinPath path} + sed 1d ${./src + "/${name}"} + ) + ''; +in + +pkgs.runCommand "xdpytools" {} + (toString + (lib.mapAttrsToList install { + xdpychvt.path = [ + "$out" + "/run/wrappers/'$LOGNAME'" + "/run/wrappers" + ]; + xdpysel.path = [ + "$out" + pkgs.findutils + pkgs.jq + ]; + })) diff --git a/pkgs/simple/xdpytools/src/xdpychvt b/pkgs/simple/xdpytools/src/xdpychvt new file mode 100755 index 0000000..84c1907 --- /dev/null +++ b/pkgs/simple/xdpytools/src/xdpychvt @@ -0,0 +1,11 @@ +#! /bin/sh +# usage: xdpychvt {prev,next} +# Changes to the VT based on the selected X display. +# +# This allows switching between X servers when display names and VT numbers +# correlate. A more sophisticated tool would try to determine the correct VT +# by e.g. looking at /proc, but this might not possible when e.g. using +# security.hideProcessInformation. +# + +chvt "$(xdpysel "$1")" diff --git a/pkgs/simple/xdpytools/src/xdpysel b/pkgs/simple/xdpytools/src/xdpysel new file mode 100755 index 0000000..e080155 --- /dev/null +++ b/pkgs/simple/xdpytools/src/xdpysel @@ -0,0 +1,49 @@ +#! /bin/sh +# usage: xdpysel {prev,next} +# Print the number of the selected X display. + +find /tmp/.X11-unix -mindepth 1 -maxdepth 1 | +jq -Rrs --arg command "$1" ' + ( + split("\n") | + map( + select(.!="") | + match("^.*/X([0-9]+)$").captures[0].string | + tonumber + ) + ) + as $all_displays | + + ( + env.DISPLAY | + match("^:([0-9]+)(?:[.][0-9]+)?$").captures[0].string | + tonumber + ) + as $current_display | + + ($all_displays | length) as $all_displays_count | + + ($all_displays|index($current_display)) + as $current_index | + + (($current_index + 1) % $all_displays_count) + as $next_index | + + (($all_displays_count + $current_index - 1) % $all_displays_count) + as $prev_index | + + $all_displays[$prev_index] as $prev_display | + $all_displays[$next_index] as $next_display | + + { + prev: $prev_display, + next: $next_display, + }[$command] + as $result | + + if $result | type == "number" then + $result + else + "xdpysel: bad argument: \($command)\n" | halt_error(-1) + end +' diff --git a/pkgs/simple/xkiller.nix b/pkgs/simple/xkiller.nix new file mode 100644 index 0000000..8d8f016 --- /dev/null +++ b/pkgs/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 +'' diff --git a/pkgs/simple/xtoggledpms.nix b/pkgs/simple/xtoggledpms.nix new file mode 100644 index 0000000..d164ad7 --- /dev/null +++ b/pkgs/simple/xtoggledpms.nix @@ -0,0 +1,16 @@ +{ pkgs }: + +let + grep = "${pkgs.gnugrep}/bin/grep"; + xset = "${pkgs.xorg.xset}/bin/xset"; +in + +pkgs.writeDashBin "xtoggledpms" '' + # usage: xtoggledpms + set -efu + if ${xset} q | ${grep} -qF 'DPMS is Disabled'; then + ${xset} dpms force off + else + ${xset} s off -dpms + fi +'' -- cgit v1.2.3