mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat: fix secrets permissions, move ./packages to flake outputs
This commit is contained in:
16
packages/betacode.nix
Normal file
16
packages/betacode.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
writers,
|
||||
haskell,
|
||||
haskellPackages,
|
||||
}:
|
||||
writers.writeHaskellBin "betacode" {
|
||||
libraries = [
|
||||
(haskell.lib.unmarkBroken (haskell.lib.doJailbreak haskellPackages.betacode))
|
||||
haskellPackages.text
|
||||
];
|
||||
} ''
|
||||
import qualified Data.Text.IO as T
|
||||
import qualified Data.Text as T
|
||||
import Text.BetaCode
|
||||
main = T.interact (either (error . T.unpack) id . fromBeta)
|
||||
''
|
||||
9
packages/cheat-sh.nix
Normal file
9
packages/cheat-sh.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
# https://nitter.net/igor_chubin/status/1557793569104183298
|
||||
{
|
||||
writers,
|
||||
curl,
|
||||
}:
|
||||
writers.writeDashBin "so" ''
|
||||
IFS=+
|
||||
${curl}/bin/curl -sSL http://cht.sh/"$*"
|
||||
''
|
||||
18
packages/closest/default.nix
Normal file
18
packages/closest/default.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
writers,
|
||||
fetchurl,
|
||||
haskellPackages,
|
||||
}:
|
||||
writers.writeDashBin "closest" ''
|
||||
${
|
||||
writers.writeHaskellBin "closest" {
|
||||
libraries = with haskellPackages; [parallel optparse-applicative edit-distance];
|
||||
ghcArgs = ["-O3" "-threaded"];
|
||||
} (builtins.readFile ./distance.hs)
|
||||
}/bin/closest +RTS -N4 -RTS --dictionary ${
|
||||
fetchurl {
|
||||
url = "https://gist.github.com/MarvinJWendt/2f4f4154b8ae218600eb091a5706b5f4/raw/36b70dd6be330aa61cd4d4cdfda6234dcb0b8784/wordlist-german.txt";
|
||||
sha256 = "0vr4lmlckgvj4s8sk502sknq9pf3297rvasj5sqqm05zzbdgpppj";
|
||||
}
|
||||
} "$@"
|
||||
''
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
pandoc,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "daybook";
|
||||
src = fetchFromGitHub {
|
||||
owner = "kmein";
|
||||
repo = "daybook";
|
||||
rev = "db2c34830e09183c80f3381bf5e4c44d52f05d53";
|
||||
sha256 = "0nbsv8f12qh5spq7zhimhdf3p7msk33xrb0ilqvlc6jmlkpislmv";
|
||||
};
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
buildInputs = [pandoc];
|
||||
buildPhase = ''
|
||||
mkdir -p $out/man/man1
|
||||
pandoc --standalone --to man daybook.1.md -o $out/man/man1/daybook.1
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
install daybook $out/bin
|
||||
wrapProgram $out/bin/daybook --prefix PATH ":" ${pandoc}/bin ;
|
||||
'';
|
||||
meta = with lib; {
|
||||
homepage = https://github.com/kmein/daybook;
|
||||
description = "A diary writing utility in sh";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
8
packages/default-gateway.nix
Normal file
8
packages/default-gateway.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
writers,
|
||||
iproute2,
|
||||
jq,
|
||||
}:
|
||||
writers.writeDashBin "default-gateway" ''
|
||||
${iproute2}/bin/ip -json route | ${jq}/bin/jq --raw-output '.[0].gateway'
|
||||
''
|
||||
24
packages/dirmir.nix
Normal file
24
packages/dirmir.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{writers}:
|
||||
writers.writeDashBin "dirmir" ''
|
||||
SOURCE="$1"
|
||||
TARGET="$2"
|
||||
|
||||
if [ ! -d "$SOURCE" ] || [ $# -ne 2 ]; then
|
||||
echo >/dev/stderr "Usage: dirmir SOURCE TARGET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$TARGET" ]; then
|
||||
echo >/dev/stderr "$TARGET" already exists. Please use a different name.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find "$SOURCE" | while read -r entry; do
|
||||
if [ -d "$entry" ]; then
|
||||
mkdir -p "$TARGET/$entry"
|
||||
else
|
||||
# create a file with the same permissions as $entry
|
||||
install -m "$(stat -c %a "$entry")" /dev/null "$TARGET/$entry"
|
||||
fi
|
||||
done
|
||||
''
|
||||
64
packages/dmenu-bluetooth.nix
Normal file
64
packages/dmenu-bluetooth.nix
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
writers,
|
||||
libnotify,
|
||||
dmenu,
|
||||
bluez5,
|
||||
lib,
|
||||
}:
|
||||
writers.writeDashBin "dmenu-bluetooth" ''
|
||||
# UI for connecting to bluetooth devices
|
||||
set -efu
|
||||
PATH=$PATH=${lib.makeBinPath [libnotify dmenu bluez5]}
|
||||
|
||||
bluetooth_notify() {
|
||||
notify-send --app-name=" Bluetooth" "$@"
|
||||
}
|
||||
|
||||
chose_device() {
|
||||
# the output from `bluetoothctl {paired-,}devices` has a first column which always contains `Device` followed by a MAC address and the device name
|
||||
cut -d ' ' -f2- | dmenu -i -l 5 -p "Bluetooth device"
|
||||
}
|
||||
|
||||
bluetoothctl scan on &
|
||||
|
||||
case "$(printf "pair\nconnect\ndisconnect" | dmenu -i)" in
|
||||
pair)
|
||||
chosen="$(bluetoothctl devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Pairing ..."
|
||||
|
||||
if bluetoothctl pair "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Paired with device."
|
||||
else
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to pair with device."
|
||||
fi
|
||||
;;
|
||||
|
||||
connect)
|
||||
chosen="$(bluetoothctl paired-devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Trying to connect ..."
|
||||
|
||||
if bluetoothctl connect "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Connected to device."
|
||||
else # something was selected but it didn't work
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to connect to device."
|
||||
fi
|
||||
;;
|
||||
|
||||
disconnect)
|
||||
chosen="$(bluetoothctl paired-devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Disconnecting ..."
|
||||
|
||||
if bluetoothctl disconnect "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Disconnected from device."
|
||||
else # something was selected but it didn't work
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to disconnect from device."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
''
|
||||
42
packages/dmenu-scrot.nix
Normal file
42
packages/dmenu-scrot.nix
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
writers,
|
||||
lib,
|
||||
dmenu,
|
||||
scrot,
|
||||
libnotify,
|
||||
xclip,
|
||||
screenshotsDirectory ? "/tmp",
|
||||
}:
|
||||
writers.writeDashBin "dmenu-scrot" ''
|
||||
# ref https://gitlab.com/dwt1/dotfiles/-/blob/master/.dmenu/dmenu-scrot.sh
|
||||
PATH=$PATH:${lib.makeBinPath [dmenu scrot libnotify xclip]}
|
||||
|
||||
APP_NAME="📸 Scrot"
|
||||
IMG_PATH="${screenshotsDirectory}"
|
||||
TIME=3000 #Miliseconds notification should remain visible
|
||||
|
||||
cmd=$(printf "fullscreen\nsection\nupload_fullscreen\nupload_section\n" | dmenu -p 'Screenshot')
|
||||
|
||||
cd "$IMG_PATH" || exit
|
||||
case ''${cmd%% *} in
|
||||
fullscreen)
|
||||
scrot -d 1 \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (full screen) saved.'
|
||||
;;
|
||||
|
||||
section)
|
||||
scrot -s \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (section) saved.'
|
||||
;;
|
||||
|
||||
upload_fullscreen)
|
||||
scrot -d 1 -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (full screen) uploaded: $(xclip -selection clipboard -out)"
|
||||
;;
|
||||
|
||||
upload_section)
|
||||
scrot -s -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (section) uploaded: $(xclip -selection clipboard -out)"
|
||||
;;
|
||||
esac
|
||||
''
|
||||
7
packages/dns-sledgehammer.nix
Normal file
7
packages/dns-sledgehammer.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
writers,
|
||||
coreutils,
|
||||
}:
|
||||
writers.writeDashBin "dns-sledgehammer" ''
|
||||
${coreutils}/bin/printf '%s\n' 'nameserver 1.1.1.1' 'options edns0' > /etc/resolv.conf
|
||||
''
|
||||
22
packages/fkill.nix
Normal file
22
packages/fkill.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
writers,
|
||||
lib,
|
||||
procps,
|
||||
gawk,
|
||||
gnused,
|
||||
fzf,
|
||||
}:
|
||||
writers.writeBashBin "fkill" ''
|
||||
PATH=$PATH:${lib.makeBinPath [procps gawk gnused fzf]}
|
||||
|
||||
if [ "$UID" != "0" ]; then
|
||||
pid=$(ps -f -u "$UID" | sed 1d | fzf -m | awk '{print $2}')
|
||||
else
|
||||
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
|
||||
fi
|
||||
|
||||
if [ "x$pid" != "x" ]
|
||||
then
|
||||
echo "$pid" | xargs kill "-''${1:-9}"
|
||||
fi
|
||||
''
|
||||
53
packages/fzfmenu.nix
Normal file
53
packages/fzfmenu.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
st,
|
||||
fzf,
|
||||
writers,
|
||||
dash,
|
||||
lib,
|
||||
}:
|
||||
writers.writeBashBin "fzfmenu" ''
|
||||
# fzfmenu - fzf as dmenu replacement
|
||||
# https://github.com/junegunn/fzf/wiki/Examples#fzf-as-dmenu-replacement
|
||||
set -efu
|
||||
|
||||
PATH=$PATH:${lib.makeBinPath [st fzf dash]}
|
||||
|
||||
input=$(mktemp -u --suffix .fzfmenu.input)
|
||||
output=$(mktemp -u --suffix .fzfmenu.output)
|
||||
mkfifo "$input"
|
||||
mkfifo "$output"
|
||||
chmod 600 "$input" "$output"
|
||||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
-p)
|
||||
PROMPT="$2"
|
||||
shift
|
||||
shift
|
||||
break ;;
|
||||
-l)
|
||||
# no reason to filter number of lines
|
||||
shift
|
||||
shift
|
||||
break ;;
|
||||
-i)
|
||||
# we do this anyway
|
||||
shift
|
||||
break ;;
|
||||
*)
|
||||
echo "Unknown option $1" >&2
|
||||
shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# it's better to use st here (starts a lot faster than pretty much everything else)
|
||||
st -c fzfmenu -n fzfmenu -g 85x10 \
|
||||
-e dash \
|
||||
-c "cat $input | fzf --reverse --prompt="''${PROMPT+> }" --print-query $* | tee $output" & disown
|
||||
|
||||
# handle ctrl+c outside child terminal window
|
||||
trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT
|
||||
|
||||
cat > "$input"
|
||||
cat "$output"
|
||||
''
|
||||
28
packages/genius.nix
Normal file
28
packages/genius.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
writers,
|
||||
curl,
|
||||
coreutils,
|
||||
gnused,
|
||||
pandoc,
|
||||
}:
|
||||
writers.writeDashBin "genius" ''
|
||||
${coreutils}/bin/test "$#" -eq 2 || (
|
||||
echo "usage: $0 <artist> <song>"
|
||||
exit 1
|
||||
)
|
||||
|
||||
normalize() {
|
||||
${coreutils}/bin/tr -d -c '0-9A-Za-z ' | ${coreutils}/bin/tr ' ' - | ${coreutils}/bin/tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
ARTIST=$(echo "$1" | normalize | ${gnused}/bin/sed 's/./\U&/')
|
||||
TITLE=$(echo "$2" | normalize)
|
||||
GENIUS_URL="https://genius.com/$ARTIST-$TITLE-lyrics"
|
||||
|
||||
${curl}/bin/curl -s "$GENIUS_URL" \
|
||||
| ${gnused}/bin/sed -ne '/class="lyrics"/,/<\/p>/p' \
|
||||
| ${pandoc}/bin/pandoc -f html -s -t plain \
|
||||
| ${gnused}/bin/sed 's/^_/\x1b[3m/g;s/_$/\x1b[0m/g;s/^\[/\n\x1b\[1m\[/g;s/\]$/\]\x1b[0m/g'
|
||||
|
||||
printf "\n%s\n" "$GENIUS_URL" >/dev/stderr
|
||||
''
|
||||
@@ -1,14 +0,0 @@
|
||||
# { stdenv, python }:
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
with pkgs;
|
||||
with pkgs.python2Packages;
|
||||
buildPythonApplication rec {
|
||||
pname = "gourmet";
|
||||
version = "0.17.4";
|
||||
src = builtins.fetchTarball {
|
||||
url = "https://github.com/thinkle/gourmet/archive/${version}.tar.gz";
|
||||
};
|
||||
buildInputs = [distutils_extra intltool];
|
||||
propagatedBuildInputs = [sqlalchemy reportlab lxml];
|
||||
meta = with stenv.lib; {maintainers = with maintainers; [kmein];};
|
||||
}
|
||||
13
packages/heuretes.nix
Normal file
13
packages/heuretes.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
writers,
|
||||
fetchurl,
|
||||
xsv,
|
||||
}: let
|
||||
database = fetchurl {
|
||||
url = "http://c.krebsco.de/greek.csv";
|
||||
hash = "sha256-SYL10kerNI0HzExG6JXh765+CBBCHLO95B6OKErQ/sU=";
|
||||
};
|
||||
in
|
||||
writers.writeDashBin "heuretes" ''
|
||||
${xsv}/bin/xsv search -s simple "^$*$" ${database} | ${xsv}/bin/xsv table
|
||||
''
|
||||
7
packages/image-convert-favicon.nix
Normal file
7
packages/image-convert-favicon.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
writers,
|
||||
imagemagick,
|
||||
}:
|
||||
writers.writeDashBin "image-convert-favicon" ''
|
||||
${imagemagick}/bin/convert "$1" -define icon:auto-resize=64,48,32,16 "''${2-favicon.ico}"
|
||||
''
|
||||
14
packages/image-convert-tolino.nix
Normal file
14
packages/image-convert-tolino.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
writers,
|
||||
imagemagick,
|
||||
}:
|
||||
writers.writeDashBin "image-convert-tolino" ''
|
||||
source_image="$1"
|
||||
|
||||
if [ -e "$source_image" ]; then
|
||||
${imagemagick}/bin/convert -type Grayscale -resize 758x1024 "$source_image" "suspend.jpg"
|
||||
else
|
||||
echo >/dev/stderr "$1 must exist."
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
13
packages/infschmv.nix
Normal file
13
packages/infschmv.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
writers,
|
||||
pup,
|
||||
curl,
|
||||
pandoc,
|
||||
man,
|
||||
}:
|
||||
writers.writeDashBin "InfSchMV" ''
|
||||
${curl}/bin/curl -sSL https://www.berlin.de/corona/massnahmen/verordnung/ \
|
||||
| ${pup}/bin/pup .textile \
|
||||
| ${pandoc}/bin/pandoc -f html -t man -s \
|
||||
| ${man}/bin/man -l -
|
||||
''
|
||||
1
packages/scripts/ipa.py → packages/ipa.py
Executable file → Normal file
1
packages/scripts/ipa.py → packages/ipa.py
Executable file → Normal file
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
# https://www.phon.ucl.ac.uk/home/sampa/x-sampa.htm
|
||||
17
packages/kirciuoklis.nix
Normal file
17
packages/kirciuoklis.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
writers,
|
||||
curl,
|
||||
jq,
|
||||
}:
|
||||
writers.writeDashBin "kirciuoklis" ''
|
||||
${curl}/bin/curl -sSL 'https://kalbu.vdu.lt/wp-admin/admin-ajax.php' -F action=text_accents -F body="$(cat)" \
|
||||
| ${jq}/bin/jq -r .message \
|
||||
| if [ "$1" = "--json" ]
|
||||
then ${jq}/bin/jq .textParts
|
||||
else ${jq}/bin/jq -r '
|
||||
.textParts
|
||||
| map(if has("accented") then .accented else .string end)
|
||||
| join("")
|
||||
'
|
||||
fi
|
||||
''
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
pkg-config,
|
||||
fetchFromGitHub,
|
||||
automake,
|
||||
autoconf,
|
||||
which,
|
||||
libtool,
|
||||
stdenv,
|
||||
gnutls,
|
||||
doxygen,
|
||||
asciidoc,
|
||||
tls ? false,
|
||||
docs ? true,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "libcoap";
|
||||
version = "unstable-2021-05-28";
|
||||
src = fetchFromGitHub {
|
||||
repo = "libcoap";
|
||||
owner = "obgm";
|
||||
rev = "62b2be4da1d0fdf4b7217487ee83dc5920174425";
|
||||
sha256 = "1igjv0hbwmakdccp5in4gw9w2p5swxdwsdx0glyna2s29sh1d37x";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
buildInputs =
|
||||
[which pkg-config automake autoconf libtool]
|
||||
++ lib.optionals docs [doxygen asciidoc]
|
||||
++ lib.optional tls gnutls;
|
||||
# preConfigure = "./autogen.sh";
|
||||
# configureFlags = lib.optional (!docs) "--disable-documentation" ++ lib.optional tls "--enable-dtls";
|
||||
configurePhase = ''
|
||||
./autogen.sh || :
|
||||
./configure --enable-dtls --prefix=$out
|
||||
'';
|
||||
buildPhase = "make";
|
||||
installPhase = "make install";
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/obgm/libcoap";
|
||||
description = "A CoAP (RFC 7252) implementation in C";
|
||||
platforms = platforms.linux;
|
||||
license = licenses.bsd2;
|
||||
maintainers = [maintainers.kmein];
|
||||
};
|
||||
}
|
||||
19
packages/literature-quote.nix
Normal file
19
packages/literature-quote.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
writers,
|
||||
lib,
|
||||
xsv,
|
||||
curl,
|
||||
gnused,
|
||||
}:
|
||||
writers.writeDashBin "literature-quote" ''
|
||||
PATH=$PATH:${lib.makeBinPath [xsv curl gnused]}
|
||||
ROW=$(curl -Ls http://kmein.github.io/logotheca/quotes.csv | shuf -n1)
|
||||
|
||||
(
|
||||
printf '%s\n\n— %s: _%s_, %s\n' \
|
||||
"$(echo "$ROW" | xsv select 4)" \
|
||||
"$(echo "$ROW" | xsv select 1)" \
|
||||
"$(echo "$ROW" | xsv select 2)" \
|
||||
"$(echo "$ROW" | xsv select 3 | tr : ,)"
|
||||
) | sed 's/ | /\n/g;s/ || /\n\n/g;s/"\(.*\)"/\1/'
|
||||
''
|
||||
10
packages/man-pdf.nix
Normal file
10
packages/man-pdf.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
writers,
|
||||
ghostscript,
|
||||
man-db,
|
||||
gnused,
|
||||
}:
|
||||
writers.writeDashBin "man-pdf" ''
|
||||
set -efu
|
||||
${man-db}/bin/man -t "$@" | ${ghostscript}/bin/ps2pdf - "$(echo "$*" | ${gnused}/bin/sed 's/\s\+/_/g').pdf"
|
||||
''
|
||||
18
packages/mansplain.nix
Normal file
18
packages/mansplain.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
# https://www.youtube.com/watch?v=8E8sUNHdzG8
|
||||
{
|
||||
writers,
|
||||
man-db,
|
||||
dmenu,
|
||||
gnused,
|
||||
findutils,
|
||||
coreutils,
|
||||
zathura,
|
||||
}:
|
||||
writers.writeDashBin "mansplain" ''
|
||||
${man-db}/bin/man -k . \
|
||||
| ${coreutils}/bin/cut -d" " -f1,2 \
|
||||
| ${dmenu}/bin/dmenu -l 5 \
|
||||
| ${gnused}/bin/sed 's/\(.*\) (\(.*\))/\2 \1/' \
|
||||
| ${findutils}/bin/xargs -r ${man-db}/bin/man -t \
|
||||
| ${zathura}/bin/zathura -
|
||||
''
|
||||
30
packages/manual-sort.nix
Normal file
30
packages/manual-sort.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{writers}:
|
||||
writers.writeHaskellBin "manual-sort" {} ''
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
import Data.Char (toLower)
|
||||
import System.Environment (getArgs)
|
||||
import System.IO (BufferMode(NoBuffering), hSetBuffering, stdout)
|
||||
|
||||
insertionSortM :: Monad f => (a -> a -> f Ordering) -> [a] -> f [a]
|
||||
insertionSortM cmp = foldr ((=<<) . insertByM cmp) (pure [])
|
||||
where
|
||||
insertByM cmp x = \case
|
||||
[] -> pure [x]
|
||||
yys@(y : ys) -> cmp x y >>= \case
|
||||
GT -> (y :) <$> insertByM cmp x ys
|
||||
_ -> pure (x : yys)
|
||||
|
||||
ask :: Show a => a -> a -> IO Ordering
|
||||
ask a b = do
|
||||
putStr (show a ++ " > " ++ show b ++ "? (y/n) ")
|
||||
map toLower <$> getLine >>= \case
|
||||
'y' : _ -> return GT
|
||||
_ -> return LT
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
hSetBuffering stdout NoBuffering
|
||||
argv <- getArgs
|
||||
sorted <- insertionSortM ask argv
|
||||
mapM_ (\(place, thing) -> putStrLn (show place ++ ". " ++ show thing)) $ zip [1 ..] (reverse sorted)
|
||||
''
|
||||
21
packages/menu-calc.nix
Normal file
21
packages/menu-calc.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
writers,
|
||||
gnused,
|
||||
pari,
|
||||
dmenu,
|
||||
xclip,
|
||||
}:
|
||||
writers.writeDashBin "=" ''
|
||||
# https://github.com/onespaceman/menu-calc
|
||||
|
||||
answer=$(echo "$@" | ${pari}/bin/gp -q | ${gnused}/bin/sed '/\./ s/\.\{0,1\}0\{1,\}$//')
|
||||
|
||||
action=$(printf "copy\nclear" | ${dmenu}/bin/dmenu -p "= $answer")
|
||||
|
||||
case $action in
|
||||
"clear") $0 ;;
|
||||
"copy") printf %s "$answer" | ${xclip}/bin/xclip -selection clipboard;;
|
||||
"") ;;
|
||||
*) $0 "$answer $action" ;;
|
||||
esac
|
||||
''
|
||||
89
packages/meteo.nix
Normal file
89
packages/meteo.nix
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
writers,
|
||||
lib,
|
||||
jq,
|
||||
curl,
|
||||
xdotool,
|
||||
nsxiv,
|
||||
gnused,
|
||||
defaultStation ? 103840,
|
||||
}:
|
||||
writers.writeDashBin "meteo" ''
|
||||
# usage: meteo --list
|
||||
# usage: meteo --update
|
||||
# usage: meteo STATION
|
||||
set -efu
|
||||
|
||||
PATH=$PATH:${lib.makeBinPath [jq curl xdotool nsxiv gnused]}
|
||||
|
||||
# TODO XDG
|
||||
CONFIG_DIR=$HOME/.config/wetter
|
||||
STATIONS_FILE=$CONFIG_DIR/stations.json
|
||||
|
||||
case ''${1-} in
|
||||
--list)
|
||||
sed -n 's/^\s*\(--[^)]\+\))$/\1/p' "$0"
|
||||
jq -r -n \
|
||||
--slurpfile stations_file "$STATIONS_FILE" \
|
||||
'
|
||||
$stations_file[0] as $known_stations |
|
||||
|
||||
$known_stations | keys[]
|
||||
'
|
||||
exit
|
||||
;;
|
||||
--update)
|
||||
mkdir -p "$(dirname "$STATIONS_FILE")"
|
||||
exec >"$STATIONS_FILE"
|
||||
|
||||
curl -fsSL http://wetterstationen.meteomedia.de/ |
|
||||
jq -Rrs '
|
||||
def decodeHTML:
|
||||
gsub("ä";"ä") |
|
||||
gsub("ö";"ö") |
|
||||
gsub("ü";"ü") |
|
||||
gsub("Ä";"Ä") |
|
||||
gsub("Ö";"Ö") |
|
||||
gsub("Ü";"Ü") |
|
||||
gsub("ß";"ß")
|
||||
;
|
||||
[
|
||||
match(".*<option value=\"/\\?map=Deutschland&station=(?<station>[0-9]+)\">(?<name>[^<]+)</option>";"g")
|
||||
.captures |
|
||||
map({"\(.name)":(.string)}) |
|
||||
add |
|
||||
{"\(.name|decodeHTML)":(.station|tonumber)}
|
||||
] |
|
||||
add
|
||||
'
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# set -x
|
||||
|
||||
station=''${1-${toString defaultStation}}
|
||||
station=$(jq -e -n \
|
||||
--arg station "$station" \
|
||||
--slurpfile stations_file "$STATIONS_FILE" \
|
||||
'
|
||||
$stations_file[0] as $known_stations |
|
||||
|
||||
$station |
|
||||
if test("^[0-9]+$") then
|
||||
tonumber
|
||||
else
|
||||
$known_stations[.]
|
||||
end
|
||||
')
|
||||
cache="/tmp/''${LOGNAME}_wetter_$station.png"
|
||||
curl -sSL \
|
||||
"http://wetterstationen.meteomedia.de/messnetz/vorhersagegrafik/$station.png" \
|
||||
-o "$cache"
|
||||
|
||||
if window_id=$(xdotool search --name "^nsxiv - $cache$"); then
|
||||
xdotool key --window "$window_id" r
|
||||
else
|
||||
nsxiv "$cache" &
|
||||
fi
|
||||
''
|
||||
29
packages/mpv-radio.nix
Normal file
29
packages/mpv-radio.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
writeText,
|
||||
lib,
|
||||
writers,
|
||||
mpv,
|
||||
dmenu,
|
||||
coreutils,
|
||||
gnused,
|
||||
di-fm-key-file,
|
||||
}: let
|
||||
streams = import ../lib/streams.nix {
|
||||
di-fm-key = "%DI_FM_KEY%";
|
||||
};
|
||||
streams-tsv = writeText "streams.tsv" (lib.concatMapStringsSep "\n" ({
|
||||
desc ? "",
|
||||
stream,
|
||||
station,
|
||||
...
|
||||
}: "${station}\t${desc}\t${stream}")
|
||||
streams);
|
||||
in
|
||||
writers.writeDashBin "mpv-radio" ''
|
||||
export DI_FM_KEY=$(cat "${di-fm-key-file}")
|
||||
exec ${mpv}/bin/mpv --force-window=yes "$(
|
||||
${dmenu}/bin/dmenu -i -l 5 < ${streams-tsv} \
|
||||
| ${coreutils}/bin/cut -f3 \
|
||||
| ${gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/
|
||||
)"
|
||||
''
|
||||
@@ -30,7 +30,6 @@ stdenvNoCC.mkDerivation rec {
|
||||
meta = with lib; {
|
||||
description = "various audio visualization";
|
||||
homepage = "https://github.com/mfcc64/mpv-scripts";
|
||||
license = licenses.unfree;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [kmein];
|
||||
};
|
||||
|
||||
23
packages/new-mac.nix
Normal file
23
packages/new-mac.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
openssl,
|
||||
writers,
|
||||
gnused,
|
||||
iproute2,
|
||||
jq,
|
||||
}:
|
||||
writers.writeDashBin "new-mac" ''
|
||||
random_mac() {
|
||||
${openssl}/bin/openssl rand -hex 6 | ${gnused}/bin/sed 's/\(..\)/\1:/g; s/.$//'
|
||||
}
|
||||
|
||||
change_mac() {
|
||||
old_mac="$(${iproute2}/bin/ip -j link show "$interface" | ${jq}/bin/jq -r '.[].address')"
|
||||
new_mac="$(random_mac)"
|
||||
${iproute2}/bin/ip link set "$interface" address "$new_mac" 2>/dev/null && echo "$old_mac -> $new_mac"
|
||||
}
|
||||
|
||||
interface="''${1:-wlp3s0}"
|
||||
${iproute2}/bin/ip link set "$interface" down
|
||||
until change_mac; do :; done
|
||||
${iproute2}/bin/ip link set "$interface" up
|
||||
''
|
||||
9
packages/nix-git.nix
Normal file
9
packages/nix-git.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
writers,
|
||||
nix-prefetch-git,
|
||||
jq,
|
||||
}:
|
||||
writers.writeDashBin "nix-git" ''
|
||||
${nix-prefetch-git}/bin/nix-prefetch-git "$@" 2> /dev/null \
|
||||
| ${jq}/bin/jq -r '"rev = \"\(.rev)\";\nsha256 = \"\(.sha256)\";"'
|
||||
''
|
||||
13
packages/nix-index-update.nix
Normal file
13
packages/nix-index-update.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
writers,
|
||||
wget,
|
||||
system,
|
||||
}:
|
||||
writers.writeDashBin "nix-index-update" ''
|
||||
filename="index-${system}"
|
||||
mkdir -p ~/.cache/nix-index
|
||||
cd ~/.cache/nix-index
|
||||
# -N will only download a new version if there is an update.
|
||||
${wget}/bin/wget -q -N https://github.com/Mic92/nix-index-database/releases/latest/download/$filename
|
||||
ln -f $filename files
|
||||
''
|
||||
25
packages/scripts/pls.nix → packages/pls.nix
Executable file → Normal file
25
packages/scripts/pls.nix → packages/pls.nix
Executable file → Normal file
@@ -1,12 +1,15 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
writers,
|
||||
miller,
|
||||
gnused,
|
||||
curl,
|
||||
nur,
|
||||
}: let
|
||||
playlistAPI = "https://radio.lassul.us";
|
||||
|
||||
sendIRC = pkgs.writers.writeDash "send-irc" ''
|
||||
${config.nur.repos.mic92.ircsink}/bin/ircsink \
|
||||
sendIRC = writers.writeDash "send-irc" ''
|
||||
${nur.repos.mic92.ircsink}/bin/ircsink \
|
||||
--nick musikkritiker \
|
||||
--server irc.hackint.org \
|
||||
--port 6697 \
|
||||
@@ -48,14 +51,14 @@
|
||||
"idk man"
|
||||
];
|
||||
in
|
||||
pkgs.writers.writeDashBin "pls" ''
|
||||
writers.writeDashBin "pls" ''
|
||||
case "$1" in
|
||||
good|like|cool|nice|noice|top|yup|yass|yes|+)
|
||||
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/good"
|
||||
${curl}/bin/curl -sS -XPOST "${playlistAPI}/good"
|
||||
echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1 | ${sendIRC}
|
||||
;;
|
||||
skip|next|bad|sucks|no|nope|flop|-)
|
||||
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/skip"
|
||||
${curl}/bin/curl -sS -XPOST "${playlistAPI}/skip"
|
||||
echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1 | ${sendIRC}
|
||||
;;
|
||||
0|meh|neutral)
|
||||
@@ -66,12 +69,12 @@ in
|
||||
echo "$@" | ${sendIRC}
|
||||
;;
|
||||
recent)
|
||||
${pkgs.curl}/bin/curl -sS -XGET "${playlistAPI}/recent" | tac | head
|
||||
${curl}/bin/curl -sS -XGET "${playlistAPI}/recent" | tac | head
|
||||
;;
|
||||
*)
|
||||
${pkgs.curl}/bin/curl -sS -XGET "${playlistAPI}/current" \
|
||||
| ${pkgs.miller}/bin/mlr --ijson --oxtab cat \
|
||||
| ${pkgs.gnused}/bin/sed -n '/artist\|title\|youtube/p'
|
||||
${curl}/bin/curl -sS -XGET "${playlistAPI}/current" \
|
||||
| ${miller}/bin/mlr --ijson --oxtab cat \
|
||||
| ${gnused}/bin/sed -n '/artist\|title\|youtube/p'
|
||||
;;
|
||||
esac
|
||||
wait
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
fetchPypi,
|
||||
buildPythonPackage,
|
||||
pygtrie,
|
||||
...
|
||||
}:
|
||||
buildPythonPackage rec {
|
||||
pname = "betacode";
|
||||
version = "0.2";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "08fnjzjvnm9m6p4ddyr8qgfb9bs2nipv4ls50784v0xazgxx7siv";
|
||||
};
|
||||
preBuild = ''echo > README.rst'';
|
||||
propagatedBuildInputs = [pygtrie];
|
||||
doCheck = false;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
buildPythonApplication,
|
||||
fetchPypi,
|
||||
requests,
|
||||
}: let
|
||||
in
|
||||
buildPythonApplication rec {
|
||||
pname = "instaloader";
|
||||
version = "4.2.4";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "02zqb02idk2pzks7dv42vigcmmpjpfhfdyjp911yr0ix7dy3q0b9";
|
||||
};
|
||||
propagatedBuildInputs = [requests];
|
||||
doCheck = false;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
fetchPypi,
|
||||
buildPythonPackage,
|
||||
...
|
||||
}:
|
||||
buildPythonPackage rec {
|
||||
pname = "pygtrie";
|
||||
version = "2.3";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "00x7q4p9r75zdnw3a8vd0d0w0i5l28w408g5bsfl787yv6b1h9i8";
|
||||
};
|
||||
doCheck = false;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
buildPythonPackage,
|
||||
buildPythonApplication,
|
||||
fetchPypi,
|
||||
pytestrunner,
|
||||
six,
|
||||
beautifulsoup4,
|
||||
requests,
|
||||
dbus-python,
|
||||
}: let
|
||||
lyricwikia = buildPythonPackage rec {
|
||||
pname = "lyricwikia";
|
||||
version = "0.1.9";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0sa5wkbgp5bpgkl8hgn7byyz9zj0786647ikf2l0k8m4fimq623y";
|
||||
};
|
||||
buildInputs = [pytestrunner];
|
||||
propagatedBuildInputs = [six beautifulsoup4 requests];
|
||||
doCheck = false;
|
||||
};
|
||||
in
|
||||
buildPythonApplication rec {
|
||||
pname = "spotify-cli-linux";
|
||||
version = "1.4.2";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "1gxich3v2i4lmh60abbw3mw15399afvvqflv8g6plvvbmvxmbgp0";
|
||||
};
|
||||
propagatedBuildInputs = [lyricwikia dbus-python];
|
||||
doCheck = false;
|
||||
}
|
||||
16
packages/qrpaste.nix
Normal file
16
packages/qrpaste.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
writers,
|
||||
mktemp,
|
||||
qrencode,
|
||||
xclip,
|
||||
nsxiv,
|
||||
}:
|
||||
writers.writeDashBin "qrpaste" ''
|
||||
file="$(${mktemp}/bin/mktemp --tmpdir)"
|
||||
trap clean EXIT
|
||||
clean() {
|
||||
rm "$file"
|
||||
}
|
||||
${qrencode}/bin/qrencode "$(${xclip}/bin/xclip -selection clipboard -out)" -o "$file"
|
||||
${nsxiv}/bin/nsxiv "$file"
|
||||
''
|
||||
@@ -1,28 +0,0 @@
|
||||
regex: https://www.radioeins.de/musik/cd_der_woche/
|
||||
selectors:
|
||||
httpsettings:
|
||||
cookie: {}
|
||||
header: {}
|
||||
useragent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
|
||||
Chrome/90.0.4430.72 Safari/537.36
|
||||
insecure: false
|
||||
feed:
|
||||
title: .boxhead h2
|
||||
description: .manualteaserShortText
|
||||
authorname: ""
|
||||
authoremail: ""
|
||||
item:
|
||||
container: .doctyperezension
|
||||
title: h2 a.rezension
|
||||
link: a.rezension
|
||||
linkattr: href
|
||||
created: .manualteaserDateTime
|
||||
createdformat: 02.01.2006
|
||||
description: .manualteaserShortText
|
||||
content: ""
|
||||
image: picture > img
|
||||
imageattr: src
|
||||
nextpage: ""
|
||||
nextpageattr: href
|
||||
nextpagecount: 0
|
||||
sort: ""
|
||||
23
packages/rfc.nix
Normal file
23
packages/rfc.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
writers,
|
||||
curl,
|
||||
pup,
|
||||
gawk,
|
||||
gnused,
|
||||
gnugrep,
|
||||
less,
|
||||
fzf,
|
||||
}:
|
||||
writers.writeDashBin "rfc" ''
|
||||
set -efu
|
||||
selection=$(
|
||||
${curl}/bin/curl -sSL https://www.rfc-editor.org/rfc-index.txt \
|
||||
| ${gawk}/bin/awk '/^$/{print;} /./{printf("%s ", $0);}' \
|
||||
| ${gnused}/bin/sed 's/\s\+/ /g' \
|
||||
| ${gnused}/bin/sed -n '/^[0-9]\+ /,$p' \
|
||||
| ${fzf}/bin/fzf \
|
||||
| ${gawk}/bin/awk '{print $1}'
|
||||
)
|
||||
|
||||
${curl}/bin/curl -sSL "https://www.rfc-editor.org/rfc/rfc$selection.txt" | ${less}/bin/less
|
||||
''
|
||||
17
packages/scanned.nix
Normal file
17
packages/scanned.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
# ref https://tex.stackexchange.com/a/502542
|
||||
{
|
||||
writers,
|
||||
imagemagick,
|
||||
}:
|
||||
writers.writeDashBin "scanned" ''
|
||||
[ $# -eq 1 -a -f "$1" -a -r "$1" ] || exit 1
|
||||
|
||||
${imagemagick}/bin/convert \
|
||||
-density 150 \
|
||||
"$1" \
|
||||
-rotate 0.5 \
|
||||
-attenuate 0.25 \
|
||||
+noise Multiplicative \
|
||||
-colorspace Gray \
|
||||
"scanned-$1"
|
||||
''
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env -S sed -f
|
||||
s/ā̊/𐬃/g
|
||||
s/t̰/𐬝/g
|
||||
s/ṣ̌/𐬴/g
|
||||
s/š́/𐬳/g
|
||||
s/ą̄/𐬅/g
|
||||
s/ŋᵛ/𐬤/g
|
||||
s/ə̄/𐬇/g
|
||||
s/ŋ́/𐬣/g
|
||||
s/x́/𐬒/g
|
||||
s/xᵛ/𐬓/g
|
||||
s/a/𐬀/g
|
||||
s/ā/𐬁/g
|
||||
s/å/𐬂/g
|
||||
s/ą/𐬄/g
|
||||
s/ə/𐬆/g
|
||||
s/e/𐬈/g
|
||||
s/ē/𐬉/g
|
||||
s/o/𐬊/g
|
||||
s/ō/𐬋/g
|
||||
s/i/𐬌/g
|
||||
s/ī/𐬍/g
|
||||
s/u/𐬎/g
|
||||
s/ū/𐬏/g
|
||||
s/k/𐬐/g
|
||||
s/x/𐬑/g
|
||||
s/g/𐬔/g
|
||||
s/ġ/𐬕/g
|
||||
s/γ/𐬖/g
|
||||
s/c/𐬗/g
|
||||
s/j/𐬘/g
|
||||
s/t/𐬙/g
|
||||
s/θ/𐬚/g
|
||||
s/d/𐬛/g
|
||||
s/δ/𐬜/g
|
||||
s/p/𐬞/g
|
||||
s/f/𐬟/g
|
||||
s/b/𐬠/g
|
||||
s/β/𐬡/g
|
||||
s/ŋ/𐬢/g
|
||||
s/n/𐬥/g
|
||||
s/ń/𐬦/g
|
||||
s/ṇ/𐬧/g
|
||||
s/m/𐬨/g
|
||||
s/m̨/𐬩/g
|
||||
s/ẏ/𐬫/g
|
||||
s/y/𐬪/g
|
||||
s/v/𐬬/g
|
||||
s/r/𐬭/g
|
||||
s/s/𐬯/g
|
||||
s/z/𐬰/g
|
||||
s/š/𐬱/g
|
||||
s/ž/𐬲/g
|
||||
s/h/𐬵/g
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/booksplit
|
||||
|
||||
# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
|
||||
|
||||
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
|
||||
|
||||
echo "Enter the album/book title:"; read -r booktitle
|
||||
|
||||
echo "Enter the artist/author:"; read -r author
|
||||
|
||||
echo "Enter the publication year:"; read -r year
|
||||
|
||||
inputaudio="$1"
|
||||
|
||||
# Get a safe file name from the book.
|
||||
escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
||||
|
||||
! mkdir -p "$escbook" && echo "Do you have write access in this directory?" && exit 1
|
||||
|
||||
# As long as the extension is in the tag script, it'll work.
|
||||
ext="opus"
|
||||
#ext="${1#*.}"
|
||||
|
||||
# Get the total number of tracks from the number of lines.
|
||||
total="$(wc -l < "$2")"
|
||||
|
||||
while read -r x;
|
||||
do
|
||||
end="$(echo "$x" | cut -d' ' -f1)"
|
||||
[ -n "$start" ] &&
|
||||
echo "From $start to $end; $track $title"
|
||||
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||
[ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" &&
|
||||
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
||||
title="$(echo "$x" | cut -d' ' -f 2-)"
|
||||
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
||||
track="$((track+1))"
|
||||
start="$end"
|
||||
done < "$2"
|
||||
# The last track must be done outside the loop.
|
||||
echo "From $start to the end: $title"
|
||||
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" &&
|
||||
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
ruby,
|
||||
stdenv,
|
||||
bundlerEnv,
|
||||
fetchFromGitHub,
|
||||
}: let
|
||||
src = fetchFromGitHub {
|
||||
owner = "kmein";
|
||||
repo = "bvg";
|
||||
rev = "bbfea2e0fdc91a37a34f581c4623704297275b47";
|
||||
sha256 = "1iyghksyiy4xkyjw10a7qhy796p88gm9ll6wr7iq55xg98w9mya4";
|
||||
};
|
||||
env = bundlerEnv {
|
||||
name = "bvg-env";
|
||||
inherit ruby;
|
||||
gemfile = "${src.out}/Gemfile";
|
||||
lockfile = "${src.out}/Gemfile.lock";
|
||||
gemset = "${src.out}/gemset.nix";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "bvg";
|
||||
buildInputs = [env.wrappedRuby];
|
||||
script = "${src.out}/bvg.rb";
|
||||
buildCommand = ''
|
||||
install -D -m755 $script $out/bin/bvg
|
||||
patchShebangs $out/bin/bvg
|
||||
'';
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p pdftk gnugrep
|
||||
set -efu
|
||||
|
||||
INPUT_FILE="${2:?Pass the PDF path as second argument.}"
|
||||
PAGES_PER_REPORT="${1:?Pass the chunk size as first argument.}"
|
||||
|
||||
if [ ! -f "$INPUT_FILE" ]; then
|
||||
echo >&2 "File $INPUT_FILE does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TOTAL_PAGES="$(pdftk "$INPUT_FILE" dump_data | grep NumberOfPages | cut -f2 -d' ')"
|
||||
|
||||
RUNS=$((TOTAL_PAGES/PAGES_PER_REPORT))
|
||||
|
||||
for run in $(seq 0 "$((RUNS-1))"); do
|
||||
start_page=$((run*PAGES_PER_REPORT+1))
|
||||
end_page=$(((run+1)*PAGES_PER_REPORT))
|
||||
output_file="chunk_$((run+1)).pdf"
|
||||
echo "splitting $INPUT_FILE from $start_page to $end_page into $output_file"
|
||||
pdftk "$INPUT_FILE" cat "$start_page-$end_page" output "$output_file"
|
||||
done
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
pandoc,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "daybook";
|
||||
src = fetchFromGitHub {
|
||||
owner = "kmein";
|
||||
repo = "daybook";
|
||||
rev = "cad1aef158b0df36861434eb04c953d99a122e80";
|
||||
sha256 = "07qippyry0yjf971pnqxm9i0xpvih8mvbhxwfwpwq980jik1hbl1";
|
||||
};
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
buildInputs = [pandoc];
|
||||
buildPhase = ''
|
||||
mkdir -p $out/man/man1
|
||||
pandoc --standalone --to man daybook.1.md -o $out/man/man1/daybook.1
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
install daybook $out/bin
|
||||
wrapProgram $out/bin/daybook --prefix PATH ":" ${pandoc}/bin ;
|
||||
'';
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/kmein/daybook";
|
||||
description = "A diary writing utility in sh";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
@@ -1,459 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
kpaste = pkgs.callPackage <stockholm/krebs/5pkgs/simple/kpaste> {};
|
||||
opustags = pkgs.callPackage ../opustags.nix {};
|
||||
betacode = pkgs.callPackage ../python3Packages/betacode.nix {};
|
||||
wrapScript = {
|
||||
packages ? [],
|
||||
name,
|
||||
script,
|
||||
}:
|
||||
pkgs.writers.writeDashBin name ''
|
||||
PATH=$PATH:${
|
||||
lib.makeBinPath (packages ++ [pkgs.coreutils pkgs.findutils])
|
||||
}
|
||||
${script} "$@"
|
||||
'';
|
||||
voidrice = pkgs.fetchFromGitHub {
|
||||
owner = "LukeSmithxyz";
|
||||
repo = "voidrice";
|
||||
rev = "0582b495937117d899ce8ef715a89c6cc25a36cf";
|
||||
sha256 = "0c4hkny4zkknlimc9yi9ljss2cws4zn8lzd8ip9b8mfsm094dlfl";
|
||||
};
|
||||
in
|
||||
rec {
|
||||
auc = pkgs.callPackage ./auc.nix {};
|
||||
|
||||
instaget = wrapScript {
|
||||
packages = [pkgs.jq pkgs.curl pkgs.gnugrep];
|
||||
script = ./instaget.sh;
|
||||
name = "instaget";
|
||||
};
|
||||
|
||||
infschmv = pkgs.writers.writeDashBin "InfSchMV" ''
|
||||
${pkgs.curl}/bin/curl -sSL https://www.berlin.de/corona/massnahmen/verordnung/ \
|
||||
| ${pkgs.pup}/bin/pup .textile \
|
||||
| ${pkgs.pandoc}/bin/pandoc -f html -t man -s \
|
||||
| ${pkgs.man}/bin/man -l -
|
||||
'';
|
||||
|
||||
trans = let
|
||||
script = pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/trans.awk";
|
||||
sha256 = "178r8d27bry1mzd1g8x2svp4w469hwv7nnxnmnsinx974skjx0jb";
|
||||
};
|
||||
in
|
||||
pkgs.writers.writeDashBin "trans" ''
|
||||
${pkgs.gawk}/bin/gawk -f ${script} -- "$@"
|
||||
'';
|
||||
|
||||
dns-sledgehammer = pkgs.writers.writeDashBin "dns-sledgehammer" ''
|
||||
${pkgs.coreutils}/bin/printf '%s\n' 'nameserver 1.1.1.1' 'options edns0' > /etc/resolv.conf
|
||||
'';
|
||||
|
||||
showkeys-toggle = pkgs.writers.writeDashBin "showkeys-toggle" ''
|
||||
if ${pkgs.procps}/bin/pgrep screenkey; then
|
||||
exec ${pkgs.procps}/bin/pkill screenkey
|
||||
else
|
||||
exec ${pkgs.screenkey}/bin/screenkey
|
||||
fi
|
||||
'';
|
||||
|
||||
qrpaste = pkgs.writers.writeDashBin "qrpaste" ''
|
||||
file="$(${pkgs.mktemp}/bin/mktemp --tmpdir)"
|
||||
trap clean EXIT
|
||||
clean() {
|
||||
rm "$file"
|
||||
}
|
||||
${pkgs.qrencode}/bin/qrencode "$(${pkgs.xclip}/bin/xclip -selection clipboard -out)" -o "$file"
|
||||
${pkgs.nsxiv}/bin/nsxiv "$file"
|
||||
'';
|
||||
|
||||
ttspaste = pkgs.writers.writeDashBin "ttspaste" ''
|
||||
${pkgs.xclip}/bin/xclip -selection clipboard -out | ${pkgs.curl}/bin/curl -G http://tts.r/api/tts --data-urlencode 'text@-' | ${pkgs.mpv}/bin/mpv -
|
||||
'';
|
||||
|
||||
interdimensional-cable = let
|
||||
nimaid-github-io = pkgs.fetchFromGitHub {
|
||||
owner = "nimaid";
|
||||
repo = "nimaid.github.io";
|
||||
rev = "9cb4ede215be6bb01bd2df1ef3e9689cc8c4eb9e";
|
||||
sha256 = "1g47cj5an7xgmhpc09m7qim5j9rspqxvnzfy90cnlvz4pg8hil96";
|
||||
};
|
||||
in
|
||||
pkgs.writeShellScriptBin "interdimensional-cable" ''
|
||||
export PATH=${lib.makeBinPath [pkgs.mpv pkgs.jq pkgs.gnused]}
|
||||
mpv --shuffle --playlist=<(jq -r '.videos[]' ${nimaid-github-io}/tv/interdimensional_database.json | sed 's#^#https://youtu.be/#')
|
||||
'';
|
||||
|
||||
tag = wrapScript {
|
||||
packages = [pkgs.vorbis-tools pkgs.python3Packages.eyeD3 opustags];
|
||||
script = "${voidrice}/.local/bin/tag";
|
||||
name = "tag";
|
||||
};
|
||||
|
||||
meteo = wrapScript {
|
||||
packages = [pkgs.jq pkgs.curl pkgs.xdotool pkgs.nsxiv pkgs.gnused];
|
||||
script = ./meteo.sh;
|
||||
name = "meteo";
|
||||
};
|
||||
|
||||
kirciuoklis = wrapScript {
|
||||
packages = [pkgs.curl pkgs.jq];
|
||||
script = ./kirciuoklis.sh;
|
||||
name = "kirciuoklis";
|
||||
};
|
||||
|
||||
booksplit = wrapScript {
|
||||
packages = [pkgs.ffmpeg tag pkgs.glibc.bin];
|
||||
script = "${voidrice}/.local/bin/booksplit";
|
||||
name = "booksplit";
|
||||
};
|
||||
|
||||
n = wrapScript {
|
||||
script = ./n.sh;
|
||||
name = "n";
|
||||
};
|
||||
|
||||
dirmir = wrapScript {
|
||||
name = "dirmir";
|
||||
script = ./dirmir.sh;
|
||||
};
|
||||
|
||||
liddel-scott-jones = wrapScript {
|
||||
name = "lsj";
|
||||
script = ./liddel-scott-jones.sh;
|
||||
packages = [pkgs.curl pkgs.pup betacode pkgs.gnused pkgs.pandoc pkgs.man];
|
||||
};
|
||||
|
||||
sanskrit-dictionary = pkgs.writers.writeDashBin "sa" ''
|
||||
set -efu
|
||||
|
||||
usage() {
|
||||
echo "usage: [OUTPUT=deva|roman] $0 mw|mwe|boet|bopp|apte|boro TERM"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# -eq 2 ] || usage
|
||||
|
||||
case $1 in
|
||||
mw) id=MWScan;;
|
||||
mwe) id=MWEScan;;
|
||||
bopp) id=BOPScan;;
|
||||
boet) id=PWGScan;;
|
||||
apte) id=AEScan;;
|
||||
boro) id=BORScan;;
|
||||
*) usage;;
|
||||
esac
|
||||
|
||||
shift
|
||||
|
||||
input="$*"
|
||||
|
||||
${pkgs.curl}/bin/curl -sSL "https://www.sanskrit-lexicon.uni-koeln.de/scans/$id/2020/web/webtc/getword.php?key=$input&filter=''${OUTPUT-roman}&accent=yes&transLit=hk" \
|
||||
| ${pkgs.pandoc}/bin/pandoc --standalone --variable=title:"$input" --from=html --to=man \
|
||||
| ${pkgs.gnused}/bin/sed 's/\s\+\([:.,;]\)/\1/g;s/\s\+/ /g' \
|
||||
| ${pkgs.man}/bin/man --local-file --pager="${pkgs.bat}/bin/bat -p" -
|
||||
'';
|
||||
|
||||
playlist = import ./pls.nix {inherit pkgs lib config;};
|
||||
|
||||
mpv-tv = import ./mpv-tv.nix {inherit pkgs lib;};
|
||||
|
||||
favicon = wrapScript {
|
||||
packages = [pkgs.imagemagick];
|
||||
name = "favicon";
|
||||
script = ./favicon.sh;
|
||||
};
|
||||
|
||||
closest = pkgs.writers.writeDashBin "closest" ''
|
||||
${
|
||||
pkgs.writers.writeHaskellBin "closest" {
|
||||
libraries = with pkgs.haskellPackages; [parallel optparse-applicative edit-distance];
|
||||
ghcArgs = ["-O3" "-threaded"];
|
||||
} (builtins.readFile ./distance.hs)
|
||||
}/bin/closest +RTS -N4 -RTS --dictionary ${
|
||||
pkgs.fetchurl {
|
||||
url = "https://gist.github.com/MarvinJWendt/2f4f4154b8ae218600eb091a5706b5f4/raw/36b70dd6be330aa61cd4d4cdfda6234dcb0b8784/wordlist-german.txt";
|
||||
sha256 = "0vr4lmlckgvj4s8sk502sknq9pf3297rvasj5sqqm05zzbdgpppj";
|
||||
}
|
||||
} "$@"
|
||||
'';
|
||||
|
||||
horoscope = pkgs.callPackage ./horoscope {};
|
||||
|
||||
genius = wrapScript {
|
||||
packages = [pkgs.curl pkgs.gnused pkgs.pandoc];
|
||||
name = "genius";
|
||||
script = ./genius.sh;
|
||||
};
|
||||
|
||||
literature-quote = wrapScript {
|
||||
packages = [pkgs.xsv pkgs.curl pkgs.gnused];
|
||||
name = "literature-quote";
|
||||
script = ./literature-quote.sh;
|
||||
};
|
||||
|
||||
man-pdf = wrapScript {
|
||||
packages = [pkgs.man pkgs.ghostscript];
|
||||
name = "man-pdf";
|
||||
script = ./man-pdf.sh;
|
||||
};
|
||||
|
||||
odyssey = wrapScript {
|
||||
packages = [pkgs.curl pkgs.xmlstarlet];
|
||||
name = "odyssey";
|
||||
script = ./odyssey.sh;
|
||||
};
|
||||
|
||||
tolino-screensaver = wrapScript {
|
||||
packages = [pkgs.imagemagick];
|
||||
name = "tolino-screensaver";
|
||||
script = ./tolino-screensaver.sh;
|
||||
};
|
||||
|
||||
wttr = wrapScript {
|
||||
packages = [pkgs.curl];
|
||||
name = "wttr";
|
||||
script = ./wttr.sh;
|
||||
};
|
||||
|
||||
vg = wrapScript {
|
||||
packages = [pkgs.ripgrep pkgs.fzf pkgs.gawk];
|
||||
name = "vg";
|
||||
script = ./vg.sh;
|
||||
};
|
||||
|
||||
dmenurandr = wrapScript {
|
||||
packages = [pkgs.dmenu pkgs.gnugrep pkgs.gnused pkgs.xorg.xrandr pkgs.gawk pkgs.libnotify pkgs.arandr];
|
||||
name = "dmenurandr";
|
||||
script = ./dmenurandr.sh;
|
||||
};
|
||||
|
||||
dmenubluetooth = wrapScript {
|
||||
packages = [pkgs.bluez5 pkgs.dmenu pkgs.libnotify];
|
||||
name = "dmenubluetooth";
|
||||
script = ./dmenubluetooth.sh;
|
||||
};
|
||||
|
||||
fkill = wrapScript {
|
||||
packages = [pkgs.procps pkgs.gawk pkgs.gnused pkgs.fzf pkgs.bash];
|
||||
script = ./fkill.sh;
|
||||
name = "fkill";
|
||||
};
|
||||
|
||||
nix-git = wrapScript {
|
||||
packages = [pkgs.nix-prefetch-git pkgs.jq];
|
||||
script = ./nix-git.sh;
|
||||
name = "nix-git";
|
||||
};
|
||||
|
||||
mansplain = wrapScript {
|
||||
packages = [pkgs.man pkgs.zathura pkgs.dmenu pkgs.gnused];
|
||||
script = ./mansplain.sh;
|
||||
name = "mansplain";
|
||||
};
|
||||
|
||||
notetags = wrapScript {
|
||||
script = ./notetags.sh;
|
||||
name = "notetags";
|
||||
};
|
||||
|
||||
fzfmenu = wrapScript {
|
||||
script = ./fzfmenu.sh;
|
||||
name = "fzfmenu";
|
||||
packages = [pkgs.st pkgs.fzf pkgs.dash pkgs.bash];
|
||||
};
|
||||
|
||||
swallow = wrapScript {
|
||||
script = ./swallow.sh;
|
||||
name = "swallow";
|
||||
packages = [pkgs.xdo];
|
||||
};
|
||||
|
||||
ipa = wrapScript {
|
||||
script = ./ipa.py;
|
||||
name = "ipa";
|
||||
packages = [pkgs.python3];
|
||||
};
|
||||
|
||||
default-gateway = pkgs.writers.writeDashBin "default-gateway" ''
|
||||
${pkgs.iproute2}/bin/ip -json route | ${pkgs.jq}/bin/jq --raw-output '.[0].gateway'
|
||||
'';
|
||||
|
||||
betacode =
|
||||
pkgs.writers.writeHaskellBin "betacode" {
|
||||
libraries = with pkgs; [
|
||||
(haskell.lib.unmarkBroken (haskell.lib.doJailbreak haskellPackages.betacode))
|
||||
haskellPackages.text
|
||||
];
|
||||
} ''
|
||||
import qualified Data.Text.IO as T
|
||||
import qualified Data.Text as T
|
||||
import Text.BetaCode
|
||||
main = T.interact (either (error . T.unpack) id . fromBeta)
|
||||
'';
|
||||
|
||||
devanagari = pkgs.callPackage ../devanagari {};
|
||||
|
||||
timer = pkgs.writers.writeDashBin "timer" ''
|
||||
[ $# -eq 2 ] || {
|
||||
echo "Usage: $0 TIME MESSAGE" 1>&2
|
||||
exit 1
|
||||
}
|
||||
time=$(echo "$1" | ${pkgs.bc}/bin/bc)
|
||||
echo "sleeping $time seconds, then saying: $2"
|
||||
${pkgs.coreutils}/bin/sleep "$time" && {
|
||||
echo "$2" | ${pkgs.espeak}/bin/espeak -v german-mbrola-6
|
||||
}
|
||||
'';
|
||||
|
||||
manual-sort = pkgs.writers.writeHaskellBin "manual-sort" {} ''
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
import Data.Char (toLower)
|
||||
import System.Environment (getArgs)
|
||||
import System.IO (BufferMode(NoBuffering), hSetBuffering, stdout)
|
||||
|
||||
insertionSortM :: Monad f => (a -> a -> f Ordering) -> [a] -> f [a]
|
||||
insertionSortM cmp = foldr ((=<<) . insertByM cmp) (pure [])
|
||||
where
|
||||
insertByM cmp x = \case
|
||||
[] -> pure [x]
|
||||
yys@(y : ys) -> cmp x y >>= \case
|
||||
GT -> (y :) <$> insertByM cmp x ys
|
||||
_ -> pure (x : yys)
|
||||
|
||||
ask :: Show a => a -> a -> IO Ordering
|
||||
ask a b = do
|
||||
putStr (show a ++ " > " ++ show b ++ "? (y/n) ")
|
||||
map toLower <$> getLine >>= \case
|
||||
'y' : _ -> return GT
|
||||
_ -> return LT
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
hSetBuffering stdout NoBuffering
|
||||
argv <- getArgs
|
||||
sorted <- insertionSortM ask argv
|
||||
mapM_ (\(place, thing) -> putStrLn (show place ++ ". " ++ show thing)) $ zip [1 ..] (reverse sorted)
|
||||
'';
|
||||
|
||||
scrot-dmenu = wrapScript {
|
||||
script = ./scrot-dmenu.sh;
|
||||
name = "dmenu-scrot";
|
||||
packages = [pkgs.xclip pkgs.scrot kpaste pkgs.libnotify pkgs.dmenu];
|
||||
};
|
||||
|
||||
unicodmenu = pkgs.callPackage ./unicodmenu.nix {};
|
||||
|
||||
mpv-radio = let
|
||||
streams = import ../../lib/streams.nix {
|
||||
di-fm-key = "%DI_FM_KEY%"; # lib.strings.fileContents <secrets/di.fm/key>;
|
||||
};
|
||||
streams-tsv = pkgs.writeText "streams.tsv" (lib.concatMapStringsSep "\n" ({
|
||||
desc ? "",
|
||||
stream,
|
||||
station,
|
||||
...
|
||||
}: "${station}\t${desc}\t${stream}")
|
||||
streams);
|
||||
in
|
||||
pkgs.writers.writeDashBin "mpv-radio" ''
|
||||
export DI_FM_KEY=$(cat "${config.age.secrets.di-fm-key.path}")
|
||||
exec ${pkgs.mpv}/bin/mpv --force-window=yes "$(
|
||||
${pkgs.dmenu}/bin/dmenu -i -l 5 < ${streams-tsv} \
|
||||
| ${pkgs.coreutils}/bin/cut -f3 \
|
||||
| ${pkgs.gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/
|
||||
)"
|
||||
'';
|
||||
|
||||
rfc = wrapScript {
|
||||
script = ./rfc.sh;
|
||||
name = "rfc";
|
||||
packages = [pkgs.curl pkgs.pup pkgs.gnused pkgs.gawk pkgs.gnugrep pkgs.fzf];
|
||||
};
|
||||
|
||||
new-mac = wrapScript {
|
||||
script = ./new-mac.sh;
|
||||
name = "new-mac";
|
||||
packages = [pkgs.gnused pkgs.openssl pkgs.jq pkgs.iproute2];
|
||||
};
|
||||
|
||||
bvg = pkgs.callPackage ./bvg.nix {};
|
||||
nav = pkgs.callPackage ./nav.nix {};
|
||||
k-lock = pkgs.callPackage ./k-lock.nix {};
|
||||
|
||||
menu-calc = pkgs.writers.writeDashBin "=" ''
|
||||
# https://github.com/onespaceman/menu-calc
|
||||
|
||||
answer=$(echo "$@" | ${pkgs.pari}/bin/gp -q | ${pkgs.gnused}/bin/sed '/\./ s/\.\{0,1\}0\{1,\}$//')
|
||||
|
||||
action=$(printf "copy\nclear" | ${pkgs.dmenu}/bin/dmenu -p "= $answer")
|
||||
|
||||
case $action in
|
||||
"clear") $0 ;;
|
||||
"copy") printf %s "$answer" | ${pkgs.xclip}/bin/xclip -selection clipboard;;
|
||||
"") ;;
|
||||
*) $0 "$answer $action" ;;
|
||||
esac
|
||||
'';
|
||||
|
||||
# ref https://tex.stackexchange.com/a/502542
|
||||
scanned = pkgs.writers.writeDashBin "scanned" ''
|
||||
[ $# -eq 1 -a -f "$1" -a -r "$1" ] || exit 1
|
||||
|
||||
${pkgs.imagemagick}/bin/convert -density 150 "$1" -rotate 0.5 -attenuate 0.25 +noise Multiplicative -colorspace Gray "scanned-$1"
|
||||
'';
|
||||
|
||||
nix-index-update = pkgs.writers.writeDashBin "nix-index-update" ''
|
||||
filename="index-x86_64-$(uname | tr A-Z a-z)"
|
||||
mkdir -p ~/.cache/nix-index
|
||||
cd ~/.cache/nix-index
|
||||
# -N will only download a new version if there is an update.
|
||||
${pkgs.wget}/bin/wget -q -N https://github.com/Mic92/nix-index-database/releases/latest/download/$filename
|
||||
ln -f $filename files
|
||||
'';
|
||||
|
||||
heuretes = let
|
||||
database = pkgs.fetchurl {
|
||||
url = "http://c.krebsco.de/greek.csv";
|
||||
hash = "sha256-SYL10kerNI0HzExG6JXh765+CBBCHLO95B6OKErQ/sU=";
|
||||
};
|
||||
in
|
||||
pkgs.writers.writeDashBin "heuretes" ''
|
||||
${pkgs.xsv}/bin/xsv search -s simple "^$*$" ${database} | ${pkgs.xsv}/bin/xsv table
|
||||
'';
|
||||
|
||||
# https://nitter.net/igor_chubin/status/1557793569104183298
|
||||
stackoverflow = pkgs.writers.writeDashBin "so" ''
|
||||
IFS=+
|
||||
${pkgs.curl}/bin/curl -sSL http://cht.sh/"$*"
|
||||
'';
|
||||
|
||||
rofi-hass = pkgs.writers.writeBashBin "rofi-hass" ''
|
||||
export PATH=${lib.makeBinPath [pkgs.home-assistant-cli pkgs.jq pkgs.util-linux pkgs.rofi pkgs.gnused pkgs.libnotify]}
|
||||
json=$(hass-cli -o json state list 2>/dev/null)
|
||||
idx=$(jq -r '.[] | [.entity_id, .state] | join(" ")' <<< "$json" | column -t | rofi -dmenu -i -markup-rows -format d)
|
||||
item=$(jq -r '.[].entity_id' <<< "$json" | sed "''${idx}q;d")
|
||||
itype=$(sed -r 's/\..+$//' <<< "$item")
|
||||
|
||||
case "$itype" in
|
||||
light) hass-cli state toggle "$item" &>/dev/null ;;
|
||||
scene) hass-cli service call --arguments entity_id="$item" scene.turn_on &>/dev/null ;;
|
||||
*) notify-send "Error" "Event type '$itype' not implemented yet. Do you have time to file an issue or write a PR?" ;;
|
||||
esac
|
||||
'';
|
||||
}
|
||||
// {
|
||||
devour = pkgs.callPackage ../devour.nix {};
|
||||
depp = pkgs.callPackage ../depp.nix {};
|
||||
text2pdf = pkgs.callPackage ../text2pdf.nix {};
|
||||
vimv = pkgs.callPackage ../vimv.nix {};
|
||||
when = pkgs.callPackage ../when.nix {};
|
||||
mahlzeit = pkgs.haskellPackages.callPackage ../mahlzeit.nix {};
|
||||
inherit opustags;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
writeShellScriptBin,
|
||||
}: let
|
||||
aliasFlag = name: value: "-c alias.${name}=${lib.escapeShellArg value}";
|
||||
aliases = {
|
||||
eroeffne = "init";
|
||||
machnach = "clone";
|
||||
zieh = "pull";
|
||||
fueghinzu = "add";
|
||||
drueck = "push";
|
||||
pfusch = "push --force";
|
||||
zweig = "branch";
|
||||
verzweige = "branch";
|
||||
uebergib = "commit";
|
||||
erde = "rebase";
|
||||
unterscheide = "diff";
|
||||
vereinige = "merge";
|
||||
bunkere = "stash";
|
||||
markiere = "tag";
|
||||
nimm = "checkout";
|
||||
tagebuch = "log";
|
||||
zustand = "status";
|
||||
};
|
||||
in
|
||||
writeShellScriptBin "depp" ''
|
||||
if [ $# -gt 0 ]; then
|
||||
git ${
|
||||
lib.concatStringsSep " " (lib.attrsets.mapAttrsToList aliasFlag aliases)
|
||||
} "$@"
|
||||
else
|
||||
printf "${
|
||||
lib.concatStringsSep "\n"
|
||||
(lib.attrsets.mapAttrsToList (n: v: n + " " + v) aliases)
|
||||
}\n"
|
||||
fi
|
||||
''
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
SOURCE="$1"
|
||||
TARGET="$2"
|
||||
|
||||
if [ ! -d "$SOURCE" ] || [ $# -ne 2 ]; then
|
||||
echo >/dev/stderr "Usage: dirmir SOURCE TARGET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$TARGET" ]; then
|
||||
echo >/dev/stderr "$TARGET" already exists. Please use a different name.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find "$SOURCE" | while read -r entry; do
|
||||
if [ -d "$entry" ]; then
|
||||
mkdir -p "$TARGET/$entry"
|
||||
else
|
||||
# create a file with the same permissions as $entry
|
||||
install -m "$(stat -c %a "$entry")" /dev/null "$TARGET/$entry"
|
||||
fi
|
||||
done
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
# UI for connecting to bluetooth devices
|
||||
set -efu
|
||||
|
||||
bluetooth_notify() {
|
||||
notify-send --app-name=" Bluetooth" "$@"
|
||||
}
|
||||
|
||||
chose_device() {
|
||||
# the output from `bluetoothctl {paired-,}devices` has a first column which always contains `Device` followed by a MAC address and the device name
|
||||
cut -d ' ' -f2- | dmenu -i -l 5 -p "Bluetooth device"
|
||||
}
|
||||
|
||||
bluetoothctl scan on &
|
||||
|
||||
case "$(printf "pair\nconnect\ndisconnect" | dmenu -i)" in
|
||||
pair)
|
||||
chosen="$(bluetoothctl devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Pairing ..."
|
||||
|
||||
if bluetoothctl pair "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Paired with device."
|
||||
else
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to pair with device."
|
||||
fi
|
||||
;;
|
||||
|
||||
connect)
|
||||
chosen="$(bluetoothctl paired-devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Trying to connect ..."
|
||||
|
||||
if bluetoothctl connect "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Connected to device."
|
||||
else # something was selected but it didn't work
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to connect to device."
|
||||
fi
|
||||
;;
|
||||
|
||||
disconnect)
|
||||
chosen="$(bluetoothctl paired-devices | chose_device)"
|
||||
chosen_name="$(echo "$chosen" | cut -d ' ' -f2-)"
|
||||
|
||||
bluetooth_notify "$chosen_name" "Disconnecting ..."
|
||||
|
||||
if bluetoothctl disconnect "$(echo "$chosen" | cut -d ' ' -f1)"; then
|
||||
bluetooth_notify "✔ $chosen_name" "Disconnected from device."
|
||||
else # something was selected but it didn't work
|
||||
test "$chosen" && bluetooth_notify "❌ $chosen_name" "Failed to disconnect from device."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref https://github.com/LukeSmithxyz/voidrice/blob/927a7c39c24272eeb6c7ca9e75a359314ad20025/.local/bin/displayselect
|
||||
|
||||
# A UI for detecting and selecting all displays. Probes xrandr for connected
|
||||
# displays and lets user select one to use. User may also select "manual
|
||||
# selection" which opens arandr.
|
||||
|
||||
query_direction() {
|
||||
printf "left-of\\nright-of\\nabove\\nbelow"
|
||||
}
|
||||
|
||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
|
||||
# Mirror displays using native resolution of external display and a scaled
|
||||
# version for the internal display
|
||||
if [ "$mirror" = "yes" ]; then
|
||||
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for")
|
||||
internal=$(echo "$screens" | grep -v "$external")
|
||||
|
||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
||||
res_int_x=$(echo "$res_internal" | sed 's/x.*//')
|
||||
res_int_y=$(echo "$res_internal" | sed 's/.*x//')
|
||||
|
||||
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 \
|
||||
--output "$internal" --auto --same-as "$external" \
|
||||
--scale "$scale_x"x"$scale_y"
|
||||
|
||||
else
|
||||
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display")
|
||||
secondary=$(echo "$screens" | grep -v "$primary")
|
||||
direction=$(query_direction | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction" "$primary" --auto --scale 1.0x1.0
|
||||
fi
|
||||
}
|
||||
|
||||
# If multi-monitor is selected and there are more than two screens.
|
||||
morescreen() {
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
|
||||
direction=$(query_direction | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
|
||||
xrandr --output "$primary" --auto --output "$secondary" --"$direction" "$primary" --auto --output "$tertiary" --"$(query_direction | grep -v "$direction")" "$primary" --auto
|
||||
}
|
||||
|
||||
# Multi-monitor handler.
|
||||
multimon() {
|
||||
case "$(echo "$screens" | wc -l)" in
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# If only one output available or chosen.
|
||||
onescreen() {
|
||||
xrandr --output "$1" --auto --primary --scale 1.0x1.0 $(echo "$allposs" | grep -v "$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ')
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||
|
||||
# If there's only one screen
|
||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] && {
|
||||
onescreen "$screens"
|
||||
notify-send "💻 Only one screen detected." "Using it in its optimal settings..."
|
||||
exit
|
||||
}
|
||||
|
||||
# Get user choice including multi-monitor and manual selection:
|
||||
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
||||
case "$chosen" in
|
||||
"manual selection") arandr ; exit ;;
|
||||
"multi-monitor") multimon ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
convert "$1" -define icon:auto-resize=64,48,32,16 "${2-favicon.ico}"
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$UID" != "0" ]; then
|
||||
pid=$(ps -f -u "$UID" | sed 1d | fzf -m | awk '{print $2}')
|
||||
else
|
||||
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
|
||||
fi
|
||||
|
||||
if [ "x$pid" != "x" ]
|
||||
then
|
||||
echo "$pid" | xargs kill "-${1:-9}"
|
||||
fi
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# fzfmenu - fzf as dmenu replacement
|
||||
# https://github.com/junegunn/fzf/wiki/Examples#fzf-as-dmenu-replacement
|
||||
set -efu
|
||||
|
||||
input=$(mktemp -u --suffix .fzfmenu.input)
|
||||
output=$(mktemp -u --suffix .fzfmenu.output)
|
||||
mkfifo "$input"
|
||||
mkfifo "$output"
|
||||
chmod 600 "$input" "$output"
|
||||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
-p)
|
||||
PROMPT="$2"
|
||||
shift
|
||||
shift
|
||||
break ;;
|
||||
-l)
|
||||
# no reason to filter number of lines
|
||||
shift
|
||||
shift
|
||||
break ;;
|
||||
-i)
|
||||
# we do this anyway
|
||||
shift
|
||||
break ;;
|
||||
*)
|
||||
echo "Unknown option $1" >&2
|
||||
shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# it's better to use st here (starts a lot faster than pretty much everything else)
|
||||
st -c fzfmenu -n fzfmenu -g 85x10 \
|
||||
-e dash \
|
||||
-c "cat $input | fzf --reverse --prompt='${PROMPT+> }' --print-query $* | tee $output" & disown
|
||||
|
||||
# handle ctrl+c outside child terminal window
|
||||
trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT
|
||||
|
||||
cat > "$input"
|
||||
cat "$output"
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
test "$#" -eq 2 || (
|
||||
echo "usage: $0 <artist> <song>"
|
||||
exit 1
|
||||
)
|
||||
|
||||
normalize() {
|
||||
tr -d -c '0-9A-Za-z ' | tr ' ' - | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
ARTIST=$(echo "$1" | normalize | sed 's/./\U&/')
|
||||
TITLE=$(echo "$2" | normalize)
|
||||
GENIUS_URL="https://genius.com/$ARTIST-$TITLE-lyrics"
|
||||
|
||||
curl -s "$GENIUS_URL" \
|
||||
| sed -ne '/class="lyrics"/,/<\/p>/p' \
|
||||
| pandoc -f html -s -t plain \
|
||||
| sed 's/^_/\x1b[3m/g;s/_$/\x1b[0m/g;s/^\[/\n\x1b\[1m\[/g;s/\]$/\]\x1b[0m/g'
|
||||
|
||||
printf "\n%s\n" "$GENIUS_URL" >/dev/stderr
|
||||
@@ -1,4 +0,0 @@
|
||||
{poetry2nix}:
|
||||
poetry2nix.mkPoetryApplication {
|
||||
projectDir = ./.;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
from datetime import datetime
|
||||
import click
|
||||
from flatlib.datetime import Datetime
|
||||
from flatlib.geopos import GeoPos
|
||||
from flatlib.chart import Chart
|
||||
import flatlib.const
|
||||
|
||||
sign_symbols = {
|
||||
flatlib.const.ARIES: "♈",
|
||||
flatlib.const.TAURUS: "♉",
|
||||
flatlib.const.GEMINI: "♊",
|
||||
flatlib.const.CANCER: "♋",
|
||||
flatlib.const.LEO: "♌",
|
||||
flatlib.const.VIRGO: "♍",
|
||||
flatlib.const.LIBRA: "♎",
|
||||
flatlib.const.SCORPIO: "♏",
|
||||
flatlib.const.SAGITTARIUS: "♐",
|
||||
flatlib.const.CAPRICORN: "♑",
|
||||
flatlib.const.AQUARIUS: "♒",
|
||||
flatlib.const.PISCES: "♓",
|
||||
}
|
||||
|
||||
planet_symbols = {
|
||||
flatlib.const.SUN: "☉",
|
||||
flatlib.const.MOON: "☽",
|
||||
flatlib.const.MERCURY: "☿",
|
||||
flatlib.const.VENUS: "♀",
|
||||
flatlib.const.MARS: "♂",
|
||||
flatlib.const.JUPITER: "♃",
|
||||
flatlib.const.SATURN: "♄",
|
||||
}
|
||||
|
||||
|
||||
def convert_into_stupid_flatlib_format(dt):
|
||||
return Datetime(dt.strftime("%Y/%m/%d"), dt.strftime("%H:%M"))
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--latitude", type=click.FLOAT, required=True)
|
||||
@click.option("--longitude", type=click.FLOAT, required=True)
|
||||
@click.option("--date", type=click.DateTime(), default=datetime.now())
|
||||
def main(latitude: float, longitude: float, date: datetime):
|
||||
flatlib_datetime = convert_into_stupid_flatlib_format(date)
|
||||
position = GeoPos(latitude, longitude)
|
||||
chart = Chart(flatlib_datetime, position)
|
||||
for planet in planet_symbols.keys():
|
||||
planet_position = chart.getObject(planet)
|
||||
print(
|
||||
planet_symbols[planet],
|
||||
sign_symbols[planet_position.sign],
|
||||
"℞" if planet_position.movement() == flatlib.const.RETROGRADE else "",
|
||||
end="",
|
||||
)
|
||||
print()
|
||||
81
packages/scripts/horoscope/poetry.lock
generated
81
packages/scripts/horoscope/poetry.lock
generated
@@ -1,81 +0,0 @@
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "8.1.3"
|
||||
description = "Composable command line interface toolkit"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.5"
|
||||
description = "Cross-platform colored terminal text."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "flatlib"
|
||||
version = "0.2.3"
|
||||
description = "Python library for Traditional Astrology"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
pyswisseph = "2.08.00-1"
|
||||
|
||||
[[package]]
|
||||
name = "numpy"
|
||||
version = "1.23.1"
|
||||
description = "NumPy is the fundamental package for array computing with Python."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
|
||||
[[package]]
|
||||
name = "pyswisseph"
|
||||
version = "2.08.00-1"
|
||||
description = "Python extension to the Swiss Ephemeris"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pytz"
|
||||
version = "2021.3"
|
||||
description = "World timezone definitions, modern and historical"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "timezonefinder"
|
||||
version = "5.2.0"
|
||||
description = "fast python package for finding the timezone of any point on earth (coordinates) offline"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
numpy = ">=1.16"
|
||||
|
||||
[package.extras]
|
||||
numba = ["numba (>=0.48)"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "657742383232643f2fa13df5686de0cc79c624f9ae9bdb2f0fc96c7a94b5b8bf"
|
||||
|
||||
[metadata.files]
|
||||
click = []
|
||||
colorama = []
|
||||
flatlib = []
|
||||
numpy = []
|
||||
pyswisseph = []
|
||||
pytz = []
|
||||
timezonefinder = []
|
||||
@@ -1,21 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "horoscope"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Kierán Meinhardt <kmein@posteo.de>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
flatlib = "^0.2.3"
|
||||
click = "^8.0.3"
|
||||
timezonefinder = "^5.2.0"
|
||||
pytz = "^2021.3"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
horoscope = "horoscope:main"
|
||||
transits-current = "transits:current"
|
||||
transits-forecast = "transits:forecast"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
@@ -1,181 +0,0 @@
|
||||
from flatlib import aspects, const
|
||||
from flatlib.chart import Chart
|
||||
from flatlib.datetime import Datetime
|
||||
import pytz
|
||||
from flatlib.geopos import GeoPos
|
||||
import timezonefinder
|
||||
import operator
|
||||
import click
|
||||
import itertools
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
tf = timezonefinder.TimezoneFinder()
|
||||
|
||||
planets = [
|
||||
const.SUN,
|
||||
const.MOON,
|
||||
const.MERCURY,
|
||||
const.VENUS,
|
||||
const.MARS,
|
||||
const.JUPITER,
|
||||
const.SATURN,
|
||||
const.URANUS,
|
||||
const.NEPTUNE,
|
||||
const.PLUTO,
|
||||
]
|
||||
|
||||
planet_symbols = {
|
||||
const.SUN: "☉",
|
||||
const.MOON: "☽",
|
||||
const.MERCURY: "☿",
|
||||
const.VENUS: "♀",
|
||||
const.MARS: "♂",
|
||||
const.JUPITER: "♃",
|
||||
const.SATURN: "♄",
|
||||
const.URANUS: "♅",
|
||||
const.NEPTUNE: "♆",
|
||||
const.PLUTO: "⯓",
|
||||
}
|
||||
|
||||
aspect_symbols = {
|
||||
const.NO_ASPECT: " ",
|
||||
const.CONJUNCTION: "☌",
|
||||
const.SEXTILE: "⚹",
|
||||
const.SQUARE: "□",
|
||||
const.TRINE: "△",
|
||||
const.OPPOSITION: "☍",
|
||||
}
|
||||
|
||||
|
||||
def convert_into_stupid_flatlib_format(dt):
|
||||
return Datetime(
|
||||
dt.strftime("%Y/%m/%d"),
|
||||
dt.strftime("%H:%M"),
|
||||
dt.utcoffset().total_seconds() / 3600,
|
||||
)
|
||||
|
||||
|
||||
here_latitude = 52.52
|
||||
here_longitude = 13.4
|
||||
|
||||
|
||||
def get_aspects(chart1, chart2, *, threshold):
|
||||
for planet1 in chart1.objects:
|
||||
for planet2 in chart2.objects:
|
||||
aspect = aspects.getAspect(planet1, planet2, const.MAJOR_ASPECTS)
|
||||
if aspect.exists() and aspect.orb <= threshold:
|
||||
yield aspect
|
||||
|
||||
|
||||
def get_chart(position, dt_naive):
|
||||
timezone = pytz.timezone(tf.timezone_at(lat=position.lat, lng=position.lon))
|
||||
dt_aware = timezone.localize(dt_naive)
|
||||
return Chart(convert_into_stupid_flatlib_format(dt_aware), position, IDs=planets)
|
||||
|
||||
|
||||
def show_aspect(aspect):
|
||||
return " ".join(
|
||||
[
|
||||
planet_symbols[aspect.active.id],
|
||||
aspect_symbols[aspect.type],
|
||||
planet_symbols[aspect.passive.id],
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--natal-latitude", type=click.FLOAT, default=here_latitude)
|
||||
@click.option("--natal-longitude", type=click.FLOAT, default=here_longitude)
|
||||
@click.option("--natal-date", type=click.DateTime(), default=datetime.now())
|
||||
@click.option("--transit-latitude", type=click.FLOAT, default=here_latitude)
|
||||
@click.option("--transit-longitude", type=click.FLOAT, default=here_longitude)
|
||||
@click.option("--transit-date", type=click.DateTime(), default=datetime.now())
|
||||
@click.option("--threshold", type=click.FLOAT, default=5)
|
||||
def forecast(
|
||||
natal_latitude: float,
|
||||
natal_longitude: float,
|
||||
natal_date: datetime,
|
||||
transit_latitude: float,
|
||||
transit_longitude: float,
|
||||
transit_date: datetime,
|
||||
threshold: float,
|
||||
):
|
||||
transit_position = GeoPos(transit_latitude, transit_longitude)
|
||||
natal_position = GeoPos(natal_latitude, natal_longitude)
|
||||
natal_chart = get_chart(natal_position, natal_date)
|
||||
transit_chart = get_chart(transit_position, transit_date)
|
||||
|
||||
offset = 0
|
||||
previous_aspects = set(
|
||||
show_aspect(a)
|
||||
for a in get_aspects(natal_chart, transit_chart, threshold=threshold)
|
||||
)
|
||||
while True:
|
||||
then = transit_date + timedelta(minutes=offset)
|
||||
current_chart = get_chart(transit_position, then)
|
||||
current_aspects = set(
|
||||
show_aspect(a)
|
||||
for a in get_aspects(natal_chart, current_chart, threshold=threshold)
|
||||
)
|
||||
entered = current_aspects - previous_aspects
|
||||
exited = previous_aspects - current_aspects
|
||||
if entered or exited:
|
||||
print(
|
||||
then.strftime("%Y-%m-%d %H:%M"),
|
||||
"".join([" | +" + a for a in entered] + [" | -" + a for a in exited]),
|
||||
sep="",
|
||||
)
|
||||
previous_aspects = current_aspects
|
||||
offset += 1
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--natal-latitude", type=click.FLOAT, default=here_latitude)
|
||||
@click.option("--natal-longitude", type=click.FLOAT, default=here_longitude)
|
||||
@click.option("--natal-date", "-D", type=click.DateTime(), default=datetime.now())
|
||||
@click.option("--transit-latitude", type=click.FLOAT, default=here_latitude)
|
||||
@click.option("--transit-longitude", type=click.FLOAT, default=here_longitude)
|
||||
@click.option("--transit-date", "-d", type=click.DateTime(), default=datetime.now())
|
||||
@click.option("--threshold", "-t", type=click.FLOAT, default=5)
|
||||
def current(
|
||||
natal_latitude: float,
|
||||
natal_longitude: float,
|
||||
natal_date: datetime,
|
||||
transit_latitude: float,
|
||||
transit_longitude: float,
|
||||
transit_date: datetime,
|
||||
threshold: float,
|
||||
):
|
||||
transit_position = GeoPos(transit_latitude, transit_longitude)
|
||||
natal_position = GeoPos(natal_latitude, natal_longitude)
|
||||
natal_chart = get_chart(natal_position, natal_date)
|
||||
transit_chart = get_chart(transit_position, transit_date)
|
||||
|
||||
relevant_aspects = list(
|
||||
get_aspects(natal_chart, transit_chart, threshold=threshold)
|
||||
)
|
||||
|
||||
def aspect_switch_date(aspect, *, direction=1, threshold):
|
||||
offset = 0
|
||||
while True:
|
||||
then = transit_date + direction * timedelta(days=offset)
|
||||
current_chart = get_chart(transit_position, then)
|
||||
aspects = [
|
||||
show_aspect(a)
|
||||
for a in get_aspects(natal_chart, current_chart, threshold=threshold)
|
||||
]
|
||||
if aspect not in aspects:
|
||||
return then.date()
|
||||
offset += 1
|
||||
|
||||
for aspect in sorted(relevant_aspects, key=operator.attrgetter("orb")):
|
||||
aspect_string = show_aspect(aspect)
|
||||
print(
|
||||
aspect_switch_date(
|
||||
aspect_string, direction=-1, threshold=threshold
|
||||
).isoformat(),
|
||||
aspect_switch_date(
|
||||
aspect_string, direction=1, threshold=threshold
|
||||
).isoformat(),
|
||||
aspect_string,
|
||||
)
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
writeShellScriptBin,
|
||||
wget,
|
||||
curl,
|
||||
jq,
|
||||
}:
|
||||
writeShellScriptBin "instaget" ''
|
||||
for url in "$@"; do
|
||||
json="$(${curl}/bin/curl -s "$url" \
|
||||
| grep display_url \
|
||||
| grep -o '{.*}')"
|
||||
|
||||
echo "$json"
|
||||
| ${jq}/bin/jq -r '
|
||||
.entry_data.PostPage
|
||||
| .[].graphql.shortcode_media.edge_sidecar_to_children.edges
|
||||
| .[].node.display_url' \
|
||||
| xargs ${wget}/bin/wget
|
||||
|
||||
echo "$json"
|
||||
| ${jq}/bin/jq -r '
|
||||
.entry_data.PostPage
|
||||
| .[].graphql.shortcode_media.display_url' \
|
||||
| xargs ${wget}/bin/wget
|
||||
done
|
||||
''
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
for url in "$@"; do
|
||||
json="$(curl -s "$url" \
|
||||
| grep display_url \
|
||||
| grep -o '{.*}')"
|
||||
|
||||
echo "$json" \
|
||||
| jq -r '
|
||||
.entry_data.PostPage
|
||||
| .[].graphql.shortcode_media.edge_sidecar_to_children.edges
|
||||
| .[].node.display_url' \
|
||||
| xargs wget
|
||||
|
||||
echo "$json" \
|
||||
| jq -r '
|
||||
.entry_data.PostPage
|
||||
| .[].graphql.shortcode_media.display_url' \
|
||||
| xargs wget
|
||||
done
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
curl -sSL 'https://kalbu.vdu.lt/wp-admin/admin-ajax.php' -F action=text_accents -F body="$(cat)" \
|
||||
| jq -r .message \
|
||||
| if [ "$1" = "--json" ]
|
||||
then jq .textParts
|
||||
else jq -r '
|
||||
.textParts
|
||||
| map(if has("accented") then .accented else .string end)
|
||||
| join("")
|
||||
'
|
||||
fi
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -efu
|
||||
|
||||
input="$*"
|
||||
|
||||
if echo "$input" | grep '^\w\+$'; then
|
||||
curl -sSL "https://lsj.gr/wiki/$input" | pup '#mw-content-text'
|
||||
else
|
||||
curl -sSL "https://lsj.gr/wiki/$(echo "$input" | betacode)" \
|
||||
| pup ':parent-of(#English_(LSJ)) + p' \
|
||||
| sed 's/<span class="sense">/<p>&/g'
|
||||
fi \
|
||||
| pandoc --standalone --variable=title:"$input" --from=html --to=man \
|
||||
| sed 's/\s\+\([:.,;]\)/\1/g;s/\s\+/ /g' \
|
||||
| man --local-file --pager="bat -p" -
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
ROW=$(curl -Ls http://kmein.github.io/logotheca/quotes.csv | shuf -n1)
|
||||
|
||||
(
|
||||
printf '%s\n\n— %s: _%s_, %s\n' \
|
||||
"$(echo "$ROW" | xsv select 4)" \
|
||||
"$(echo "$ROW" | xsv select 1)" \
|
||||
"$(echo "$ROW" | xsv select 2)" \
|
||||
"$(echo "$ROW" | xsv select 3 | tr : ,)"
|
||||
) | sed 's/ | /\n/g;s/ || /\n\n/g;s/"\(.*\)"/\1/'
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
if [ "$#" -eq 1 ]; then
|
||||
man_entry="$1"
|
||||
elif [ $# -eq 2 ]; then
|
||||
man_page="$1"
|
||||
man_entry="$2"
|
||||
else
|
||||
echo >/dev/stderr "Usage: $0 [MAN-PAGE] ENTRY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
man "${man_page:-}" "$man_entry" | ps2pdf - "$man_entry.pdf"
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
# https://www.youtube.com/watch?v=8E8sUNHdzG8
|
||||
man -k . \
|
||||
| cut -d" " -f1,2 \
|
||||
| dmenu -l 5 \
|
||||
| sed 's/\(.*\) (\(.*\))/\2 \1/' \
|
||||
| xargs -r man -t \
|
||||
| zathura -
|
||||
@@ -1,76 +0,0 @@
|
||||
#! /bin/sh
|
||||
# usage: meteo --list
|
||||
# usage: meteo --update
|
||||
# usage: meteo STATION
|
||||
set -efu
|
||||
|
||||
# TODO XDG
|
||||
CONFIG_DIR=$HOME/.config/wetter
|
||||
STATIONS_FILE=$CONFIG_DIR/stations.json
|
||||
|
||||
case ${1-} in
|
||||
--list)
|
||||
sed -n 's/^\s*\(--[^)]\+\))$/\1/p' "$0"
|
||||
jq -r -n \
|
||||
--slurpfile stations_file "$STATIONS_FILE" \
|
||||
'
|
||||
$stations_file[0] as $known_stations |
|
||||
|
||||
$known_stations | keys[]
|
||||
'
|
||||
exit
|
||||
;;
|
||||
--update)
|
||||
mkdir -p "$(dirname "$STATIONS_FILE")"
|
||||
exec >"$STATIONS_FILE"
|
||||
|
||||
curl -fsSL http://wetterstationen.meteomedia.de/ |
|
||||
jq -Rrs '
|
||||
def decodeHTML:
|
||||
gsub("ä";"ä") |
|
||||
gsub("ö";"ö") |
|
||||
gsub("ü";"ü") |
|
||||
gsub("Ä";"Ä") |
|
||||
gsub("Ö";"Ö") |
|
||||
gsub("Ü";"Ü") |
|
||||
gsub("ß";"ß")
|
||||
;
|
||||
[
|
||||
match(".*<option value=\"/\\?map=Deutschland&station=(?<station>[0-9]+)\">(?<name>[^<]+)</option>";"g")
|
||||
.captures |
|
||||
map({"\(.name)":(.string)}) |
|
||||
add |
|
||||
{"\(.name|decodeHTML)":(.station|tonumber)}
|
||||
] |
|
||||
add
|
||||
'
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# set -x
|
||||
|
||||
station=${1-103840}
|
||||
station=$(jq -e -n \
|
||||
--arg station "$station" \
|
||||
--slurpfile stations_file "$STATIONS_FILE" \
|
||||
'
|
||||
$stations_file[0] as $known_stations |
|
||||
|
||||
$station |
|
||||
if test("^[0-9]+$") then
|
||||
tonumber
|
||||
else
|
||||
$known_stations[.]
|
||||
end
|
||||
')
|
||||
cache="/tmp/${LOGNAME}_wetter_$station.png"
|
||||
curl -sSL \
|
||||
"http://wetterstationen.meteomedia.de/messnetz/vorhersagegrafik/$station.png" \
|
||||
-o "$cache"
|
||||
|
||||
if window_id=$(xdotool search --name "^nsxiv - $cache$"); then
|
||||
xdotool key --window "$window_id" r
|
||||
else
|
||||
nsxiv "$cache" &
|
||||
fi
|
||||
@@ -1,3 +0,0 @@
|
||||
#! /bin/sh
|
||||
set -efu
|
||||
exec curl -fSs --unix-socket /tmp/much.api.sock http://localhost/current/query
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
curl -sSL 'https://diac.alsharekh.org/Diac/DiacText' \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-raw "$(jq --raw-input '{word: ., type: 1}')" \
|
||||
--compressed \
|
||||
| jq -r .diacWord
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
nix-shell -p "$1" --run "${2:-$1}"
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
stdenv,
|
||||
fzf,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
name = "nav";
|
||||
version = "8da22b1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "huntrar";
|
||||
repo = name;
|
||||
rev = version;
|
||||
sha256 = "0aw10495901dagyfxn2pj6nh3nl1xgi5p57mwgkgn9g5hi66xa87";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin/
|
||||
install nav $out/bin/
|
||||
'';
|
||||
propagatedBuildInputs = [fzf];
|
||||
meta = {
|
||||
maintainer = [lib.maintainers.kmein];
|
||||
description = "JSON data structure navigator";
|
||||
homepage = "https://github.com/huntrar/nav";
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
random_mac() {
|
||||
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
|
||||
}
|
||||
|
||||
change_mac() {
|
||||
old_mac="$(ip -j link show "$interface" | jq -r '.[].address')"
|
||||
new_mac="$(random_mac)"
|
||||
ip link set "$interface" address "$new_mac" 2>/dev/null && echo "$old_mac -> $new_mac"
|
||||
}
|
||||
|
||||
interface="${1:-wlp3s0}"
|
||||
ip link set "$interface" down
|
||||
until change_mac; do :; done
|
||||
ip link set "$interface" up
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
nix-prefetch-git "$@" 2> /dev/null \
|
||||
| jq -r '"rev = \"\(.rev)\";\nsha256 = \"\(.sha256)\";"'
|
||||
@@ -1,93 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p coreutils gnugrep gnused graphviz
|
||||
#
|
||||
# usage: nix-haddock-index
|
||||
#
|
||||
# Run this script in an environment where either NIX_GHC is set, or the ghc
|
||||
# executable exists, to generate an HTML index file pointing to all Haddock
|
||||
# files accessible to the respective ghc version.
|
||||
#
|
||||
# Additionally, an SVG dependency graph of all packages is linked at the
|
||||
# bottom of the index file.
|
||||
#
|
||||
# Note: all files will be generated in /tmp, and won't be deleted automatically
|
||||
#
|
||||
|
||||
set -efux
|
||||
|
||||
if test -z "${NIX_GHC-}"; then
|
||||
NIX_GHC=$(readlink -f "$(type -P ghc)")
|
||||
fi
|
||||
|
||||
if ! echo $NIX_GHC | grep -q '^/nix/store/'; then
|
||||
printf '%s: error: unsupported GHC executable path (not in Nix store): %q\n' \
|
||||
"$0" \
|
||||
"$NIX_GHC" \
|
||||
>&2
|
||||
exit -1
|
||||
fi
|
||||
|
||||
NIX_GHC_PREFIX=$(dirname "$(dirname "$NIX_GHC")")
|
||||
NIX_GHC_DOCDIR=$NIX_GHC_PREFIX/share/doc/ghc/html
|
||||
|
||||
main() {
|
||||
|
||||
hash=$(echo $NIX_GHC_PREFIX | sed -n 's|^/nix/store/\([a-z0-9]\+\).*|\1|p')
|
||||
title="Haddock index for $NIX_GHC_PREFIX"
|
||||
|
||||
header=$(
|
||||
printf 'Haddock index for <a href="%s">%s</a>\n' \
|
||||
$NIX_GHC_PREFIX \
|
||||
$NIX_GHC_PREFIX \
|
||||
)
|
||||
|
||||
suffix=${hash:+-$hash}
|
||||
index_file=/tmp/haddock$suffix-index.html
|
||||
svg_file=/tmp/haddock$suffix.svg
|
||||
|
||||
#if ! test -e $index_file; then
|
||||
eval "$(
|
||||
echo 'gen_index() {'
|
||||
echo ' html_head'
|
||||
"$NIX_GHC_PREFIX"/bin/ghc-pkg dump | sed -n '
|
||||
s/^---$/ reset/p
|
||||
s/^\(name\|version\):\s*\([-A-Za-z0-9_.]\+\)$/ \1=\2/p
|
||||
s/^haddock-html:\s*\([-A-Za-z0-9_./]\+\)$/ haddock_html \1/p
|
||||
'
|
||||
echo ' html_foot'
|
||||
echo '}'
|
||||
)"
|
||||
|
||||
gen_index > $index_file
|
||||
#fi
|
||||
|
||||
#if ! test -e $svg_file; then
|
||||
"$NIX_GHC_PREFIX"/bin/ghc-pkg dot | tred | dot -Tsvg | sed '
|
||||
s/<svg width="[0-9]\+pt" height="[0-9]\+pt"/<svg width="3600px" height="100%"/
|
||||
' > $svg_file
|
||||
#fi
|
||||
|
||||
echo $index_file
|
||||
}
|
||||
reset() {
|
||||
unset name version
|
||||
}
|
||||
haddock_html() {
|
||||
printf '<li>'
|
||||
printf '<a href="%s/index.html">%s</a>' "$1" "$name-$version"
|
||||
printf '</li>\n'
|
||||
}
|
||||
html_head() {
|
||||
printf '<!doctype html>\n'
|
||||
printf '<title>%s</title>\n' "$title"
|
||||
printf '<link href="%s" rel="stylesheet" type="text/css">\n' \
|
||||
"$NIX_GHC_DOCDIR/libraries/ocean.css"
|
||||
printf '<h1>%s</h1>\n' "$header"
|
||||
printf '<ul>\n'
|
||||
}
|
||||
html_foot() {
|
||||
printf '</ul>\n'
|
||||
printf '<a href="%s">graph</a>\n' "$svg_file"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# inspired by https://github.com/connermcd/bin/blob/1d38cb98812906d8b95dc6e51e1149e29261617d/notetags
|
||||
|
||||
cd "$HOME/notes/" || exit
|
||||
|
||||
[ -f tags ] && rm tags
|
||||
grep -r 'tags:' ./* | while read -r line; do
|
||||
file=$(echo "$line" | cut -d: -f1)
|
||||
unparsed_tags=$(echo "$line" | cut -d: -f3) #
|
||||
tags=$(echo "$unparsed_tags" | sed -e 's/tags: *//g' -e 's/[][,]//g')
|
||||
for tag in $tags; do
|
||||
echo "$tag $file /^$unparsed_tags$/;" >> tags
|
||||
done
|
||||
done
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
if [ "$#" -eq 1 ] && (echo "$1" | grep -Eq '[0-9]+\.[0-9]+'); then
|
||||
curl -Gs http://www.perseus.tufts.edu/hopper/CTS \
|
||||
-d request=GetPassage \
|
||||
-d "urn=urn:cts:greekLit:tlg0012.tlg002:$1" \
|
||||
| xmlstarlet sel -t -v 'cts:GetPassage//tei:div'
|
||||
else
|
||||
echo you must supply BOOK.VERSE
|
||||
fi
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -efu
|
||||
|
||||
cache_file=/tmp/rfc-index.txt
|
||||
|
||||
fetch_index() {
|
||||
if [ -f "$cache_file" ]
|
||||
then cat "$cache_file"
|
||||
else curl -sSL https://tools.ietf.org/rfc/index | tee "$cache_file"
|
||||
fi
|
||||
}
|
||||
|
||||
rfc_list="$(fetch_index \
|
||||
| pup 'pre text{}' \
|
||||
| awk '$0 != "" {printf "%s",$0} $0 == "" {printf "\n"}' \
|
||||
| sed 's/\s\+/ /g' \
|
||||
| sed 'n;d' \
|
||||
| grep '^RFC[[:digit:]]' \
|
||||
| sed 's/RFC\([[:digit:]]\+\)/\1\t/;s/\. .*//'
|
||||
)"
|
||||
|
||||
selection="$(echo "$rfc_list" | fzf | awk '{print $1}')"
|
||||
|
||||
curl -sSL "https://tools.ietf.org/rfc/rfc$selection.txt" | less
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ref https://gitlab.com/dwt1/dotfiles/-/blob/master/.dmenu/dmenu-scrot.sh
|
||||
|
||||
APP_NAME="📸 Scrot"
|
||||
IMG_PATH="$HOME/Downloads/Screenshots"
|
||||
TIME=3000 #Miliseconds notification should remain visible
|
||||
|
||||
cmd=$(printf "fullscreen\nsection\nupload_fullscreen\nupload_section\n" | dmenu -p 'Screenshot')
|
||||
|
||||
cd "$IMG_PATH" || exit
|
||||
case ${cmd%% *} in
|
||||
fullscreen)
|
||||
scrot -d 1 \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (full screen) saved.'
|
||||
;;
|
||||
|
||||
section)
|
||||
scrot -s \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (section) saved.'
|
||||
;;
|
||||
|
||||
upload_fullscreen)
|
||||
scrot -d 1 -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (full screen) uploaded: $(xclip -selection clipboard -out)"
|
||||
;;
|
||||
|
||||
upload_section)
|
||||
scrot -s -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
|
||||
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (section) uploaded: $(xclip -selection clipboard -out)"
|
||||
;;
|
||||
esac
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
# https://github.com/salman-abedin/devour/blob/master/devour.sh
|
||||
|
||||
id=$(xdo id)
|
||||
xdo hide
|
||||
$("$@") > /dev/null 2>&1
|
||||
xdo show "$id"
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/bin/sh
|
||||
# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/tag
|
||||
|
||||
err() { echo "Usage:
|
||||
tag [OPTIONS] file
|
||||
Options:
|
||||
-a: artist/author
|
||||
-t: song/chapter title
|
||||
-A: album/book title
|
||||
-n: track/chapter number
|
||||
-N: total number of tracks/chapters
|
||||
-d: year of publication
|
||||
-g: genre
|
||||
-c: comment
|
||||
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
|
||||
|
||||
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
|
||||
a) artist="${OPTARG}" ;;
|
||||
t) title="${OPTARG}" ;;
|
||||
A) album="${OPTARG}" ;;
|
||||
n) track="${OPTARG}" ;;
|
||||
N) total="${OPTARG}" ;;
|
||||
d) date="${OPTARG}" ;;
|
||||
g) genre="${OPTARG}" ;;
|
||||
c) comment="${OPTARG}" ;;
|
||||
f) file="${OPTARG}" ;;
|
||||
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
|
||||
esac done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
file="$1"
|
||||
|
||||
[ ! -f "$file" ] && echo "Provide file to tag." && err
|
||||
|
||||
[ -z "$title" ] && echo "Enter a title." && read -r title
|
||||
[ -z "$artist" ] && echo "Enter an artist." && read -r artist
|
||||
[ -z "$album" ] && echo "Enter an album." && read -r album
|
||||
[ -z "$track" ] && echo "Enter a track number." && read -r track
|
||||
|
||||
case "$file" in
|
||||
*.ogg) echo "Title=$title
|
||||
Artist=$artist
|
||||
Album=$album
|
||||
Track=$track
|
||||
Total=$total
|
||||
Date=$date
|
||||
Genre=$genre
|
||||
Comment=$comment" | vorbiscomment -w "$file" ;;
|
||||
*.opus) echo "Title=$title
|
||||
Artist=$artist
|
||||
Album=$album
|
||||
Track=$track
|
||||
Total=$total
|
||||
Date=$date
|
||||
Genre=$genre
|
||||
Comment=$comment" | opustags -i -S "$file" ;;
|
||||
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
|
||||
*) echo "File type not implemented yet." ;;
|
||||
esac
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
source_image="$1"
|
||||
|
||||
if [ -e "$source_image" ]; then
|
||||
convert -type Grayscale -resize 758x1024 "$source_image" "suspend.jpg"
|
||||
else
|
||||
echo >/dev/stderr "$1 must exist."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
file="$(rg "$@" | fzf -0 -1 | awk -F: '{print $1}')"
|
||||
|
||||
if [ -n "$file" ]; then
|
||||
${EDITOR:-vim} "$file"
|
||||
fi
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
curl -s -H "Accept-Language: ${LANG%_*}" --compressed "wttr.in/${1-}?0"
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
buildPythonPackage,
|
||||
buildPythonApplication,
|
||||
fetchPypi,
|
||||
requests,
|
||||
urwid,
|
||||
}: let
|
||||
Simperium3 = buildPythonPackage rec {
|
||||
pname = "Simperium3";
|
||||
version = "0.1.3";
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "1j1w4dji39v44l96qq9kbrxpcjkjmika8065gwy8bf847f9fa76p";
|
||||
};
|
||||
propagatedBuildInputs = [requests];
|
||||
};
|
||||
in
|
||||
buildPythonApplication rec {
|
||||
pname = "sncli";
|
||||
version = "0.3.0";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "18s5a6s2z7k14cbiyfdf98kw92r2hf1xwaavx67dxhadxm18xr4v";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [requests urwid Simperium3];
|
||||
}
|
||||
11
packages/swallow.nix
Normal file
11
packages/swallow.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
writers,
|
||||
xdo,
|
||||
}:
|
||||
# https://github.com/salman-abedin/devour/blob/master/devour.sh
|
||||
writers.writeDashBin "swallow" ''
|
||||
id=$(${xdo}/bin/xdo id)
|
||||
${xdo}/bin/xdo hide
|
||||
$("$@") > /dev/null 2>&1
|
||||
${xdo}/bin/xdo show "$id"
|
||||
''
|
||||
17
packages/timer.nix
Normal file
17
packages/timer.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
writers,
|
||||
bc,
|
||||
coreutils,
|
||||
espeak,
|
||||
}:
|
||||
writers.writeDashBin "timer" ''
|
||||
[ $# -eq 2 ] || {
|
||||
echo "Usage: $0 TIME MESSAGE" 1>&2
|
||||
exit 1
|
||||
}
|
||||
time=$(echo "$1" | ${bc}/bin/bc)
|
||||
echo "sleeping $time seconds, then saying: $2"
|
||||
${coreutils}/bin/sleep "$time" && {
|
||||
echo "$2" | ${espeak}/bin/espeak -v german-mbrola-6
|
||||
}
|
||||
''
|
||||
@@ -22,7 +22,6 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
meta = with lib; {
|
||||
description = "Tocharian font by Lee Wilson";
|
||||
license = licenses.unfree;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [kmein];
|
||||
};
|
||||
|
||||
13
packages/trans.nix
Normal file
13
packages/trans.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
fetchurl,
|
||||
writers,
|
||||
gawk,
|
||||
}: let
|
||||
script = fetchurl {
|
||||
url = "https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/trans.awk";
|
||||
sha256 = "178r8d27bry1mzd1g8x2svp4w469hwv7nnxnmnsinx974skjx0jb";
|
||||
};
|
||||
in
|
||||
writers.writeDashBin "trans" ''
|
||||
exec ${gawk}/bin/gawk -f ${script} -- "$@"
|
||||
''
|
||||
9
packages/ttspaste.nix
Normal file
9
packages/ttspaste.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
writers,
|
||||
xclip,
|
||||
curl,
|
||||
mpv,
|
||||
}:
|
||||
writers.writeDashBin "ttspaste" ''
|
||||
${xclip}/bin/xclip -selection clipboard -out | ${curl}/bin/curl -G http://tts.r/api/tts --data-urlencode 'text@-' | ${mpv}/bin/mpv -
|
||||
''
|
||||
13
packages/vg.nix
Normal file
13
packages/vg.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
writers,
|
||||
ripgrep,
|
||||
fzf,
|
||||
gawk,
|
||||
}:
|
||||
writers.writeDashBin "vg" ''
|
||||
file="$(${ripgrep}/bin/rg "$@" | ${fzf}/bin/fzf -0 -1 | ${gawk}/bin/awk -F: '{print $1}')"
|
||||
|
||||
if [ -n "$file" ]; then
|
||||
''${EDITOR:-vim} "$file"
|
||||
fi
|
||||
''
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
perl,
|
||||
which,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "when";
|
||||
version = "1.1.40";
|
||||
|
||||
src = builtins.fetchTarball {
|
||||
url = "http://www.lightandmatter.com/when/when.tar.gz";
|
||||
sha256 = "12d0zmvg66lwzr7q8zky0kz1x3w6q8dvyzm4x7lf1vy2z4pm4cvx";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [which];
|
||||
buildInputs = [perl];
|
||||
|
||||
installFlags = ["prefix=$(out)"];
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "http://www.lightandmatter.com/when/when.html";
|
||||
description = "An extremely simple personal calendar program";
|
||||
longDescription = "When is an extremely simple personal calendar program, aimed at the Unix geek who wants something minimalistic.";
|
||||
license = licenses.gpl2;
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
7
packages/wttr.nix
Normal file
7
packages/wttr.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
writers,
|
||||
curl,
|
||||
}:
|
||||
writers.writeDashBin "wttr" ''
|
||||
${curl}/bin/curl -s -H "Accept-Language: ''${LANG%_*}" --compressed "wttr.in/''${1-}?0"
|
||||
''
|
||||
Reference in New Issue
Block a user