1
0
mirror of https://github.com/kmein/niveum synced 2026-03-22 04:41:07 +01:00

10 Commits

8 changed files with 152 additions and 23 deletions

29
.bin/anki-poem.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
file="${1?please supply a poetry file}"
[ -f "$file" ] || {
echo "'$file' is no file"
exit 1
}
poem="$(mktemp)"
clean () {
rm "$poem"
}
trap clean EXIT
sed '/^$/d' "$file" > "$poem"
htmlize() {
awk 'ORS="<br/>"' \
| head -c -5 # remove final <br/> characters
}
for line_number in $(seq 1 "$(wc -l "$poem" | cut -d' ' -f1)"); do
if [ "$line_number" -gt 3 ] && [ "$line_number" -gt 1 ]; then
sed -n "$((line_number - 3)),$((line_number - 1))p" "$poem"
else
sed -n "1,$((line_number - 1))p" "$poem"
fi | htmlize
printf '\t'
sed -n "${line_number},+1p" "$poem" | htmlize
printf '\n'
done

26
.bin/watson2fdf.sh Executable file
View File

@@ -0,0 +1,26 @@
project=Filli
year=2022
for month in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
from="$(date +%F -d "$month 1, $year")"
to="$(date +%F -d "$month 1, $year + 1 month")"
watson report --json --from "$from" --to "$to" --project "$project"
done | jq --slurp '
def in_array($arr):
. as $value | any($arr[]; . == $value);
map(
["engadin-app","fysiweb","val-muestair","mia-engiadina","ol"] as $official_projects
| (.timespan.from | .[0:7]) as $timespan
| .projects | .[0]
| .time as $total_time
| .tags
| select(. != null)
| map(select(.name | in_array($official_projects)))
| (map(.time)|add) as $official_time
| map({key:.name, value:.time}) | from_entries
| .other |= ($total_time - $official_time)
| map_values(. / (60*60) | ceil)
| .month |= $timespan
)
'

View File

@@ -17,7 +17,7 @@
(pkgs.writers.writeDashBin "hora-filli" ''
${pkgs.hledger}/bin/hledger -f "${timeLedger}" register fillidefilla -O csv \
-b "$(date -d "$(date +%Y-%m)-20 last month" +%Y-%m-%d)" \
-e "$(date -d "$(date +%Y-%m)-19" +%Y-%m-%d)" \
-e "$(date -d "$(date +%Y-%m)-20" +%Y-%m-%d)" \
| sed 's/(fillidefilla:\(.*\))/\1/g' \
| xsv select date,amount,total,account,description
'')

View File

@@ -76,11 +76,14 @@ in {
environment.systemPackages = [
pkgs.newsboat
(pkgs.writers.writeDashBin "newsboat-unread-count" ''
printf "🆕"
if [ -f ${newsboat-home}/cache.db.lock ]; then
echo
${pkgs.jq}/bin/jq -n '{state: "Info", text: "", icon: "update"}'
else
${pkgs.sqlite}/bin/sqlite3 ${newsboat-home}/cache.db "SELECT COUNT(DISTINCT id) FROM rss_item WHERE unread=1"
${pkgs.sqlite}/bin/sqlite3 ${newsboat-home}/cache.db "SELECT COUNT(DISTINCT id) FROM rss_item WHERE unread=1" | ${pkgs.jq}/bin/jq '{
state: (if . > 0 then "Good" else "Idle" end),
text: . | tostring,
icon: "update"
}'
fi
'')
(pkgs.writers.writeDashBin "mpv-watch-later" ''

View File

@@ -28,7 +28,7 @@ in {
critical_fg = colours.red.bright;
good_fg = colours.green.bright;
idle_fg = colours.foreground;
info_fg = colours.foreground;
info_fg = colours.cyan.bright;
warning_fg = colours.yellow.bright;
warning_bg = colours.background;
alternating_tint_bg = colours.background;
@@ -69,9 +69,11 @@ in {
net_wired = "🌐";
net_wireless = "📶";
pomodoro = "🍅 ";
tasks = "";
time = "📅 ";
toggle_off = "👎";
toggle_on = "👍";
update = "🆕";
volume_empty = "🔈 ";
volume_full = "🔊 ";
volume_half = "🔉 ";
@@ -85,11 +87,6 @@ in {
};
};
block = [
{
block = "custom";
interval = 5;
command = "newsboat-unread-count";
}
{
block = "weather";
autolocate = true;
@@ -136,14 +133,45 @@ in {
print("🌅 {} 🌇 {} {} {}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase], round(current_phase, 1)))
'';
}
{
block = "custom";
interval = 10;
command = "newsboat-unread-count";
json = true;
}
{
block = "custom";
interval = 10;
command = pkgs.writers.writeDash "todo" ''
${pkgs.todoman}/bin/todo --porcelain | ${pkgs.jq}/bin/jq -r '
map(select(.due != null))
| (map(select(.due < now)) | length) as $overdue
| (map(select(.due >= now and .due < now + (60 * 60 * 24))) | length) as $dueToday
| {
icon: "tasks",
text: "\($overdue)+\($dueToday)",
state: (
if $overdue > 0 then
"Critical"
elif $dueToday > 0 then
"Warning"
else
"Idle"
end
)
}
'
'';
json = true;
}
{
block = "custom";
interval = 5;
command = pkgs.writers.writeDash "hu-berlin-vpn" ''
PATH=${lib.makeBinPath [pkgs.systemd]}
(systemctl is-active --quiet openvpn-hu-berlin.service && echo "🎓👍 (OpenVPN)") \
|| (systemctl is-active --quiet hu-vpn.service && echo "🎓👍 (PPP+SSL)") \
|| echo "🎓👎"
(systemctl is-active --quiet openvpn-hu-berlin.service && echo "OVPN") \
|| (systemctl is-active --quiet hu-vpn.service && echo "PPP-VPN") \
|| :
'';
}
{
@@ -171,9 +199,35 @@ in {
}
{block = "load";}
{
block = "time";
interval = 1;
format = "%Y-%m-%d (%W %a) %H:%M";
block = "custom";
interval = 10;
json = true;
command = pkgs.writers.writeDash "time" ''
${pkgs.jq}/bin/jq -n \
--arg now "$(${pkgs.coreutils}/bin/date +'%Y-%m-%d (%W %a) %H:%M')" \
--argjson nextEvent "$(
${pkgs.khal}/bin/khal list --format "{start}" --day-format "" $(${pkgs.coreutils}/bin/date +'%Y-%m-%d %H:%M') 2>/dev/null \
| ${pkgs.gnugrep}/bin/grep -E '[0-9]{2}:[0-9]{2}' \
| ${pkgs.coreutils}/bin/head -1 \
| ${pkgs.coreutils}/bin/date --date="$(cat)" +%s
)" \
'{
text: $now,
icon: "time",
state: (
($nextEvent - now) as $deltaT
| if $deltaT < (5 * 60) then
"Critical"
elif $deltaT < (15 * 60) then
"Warning"
elif $deltaT < (60 * 60) then
"Info"
else
"Idle"
end
)
}'
'';
}
];
}

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node
const { createInterface } = require("readline");
const Sanscript = require("@sanskrit-coders/sanscript");
const Sanscript = require("@indic-transliteration/sanscript");
const rl = createInterface({
input: process.stdin,
@@ -9,5 +9,9 @@ const rl = createInterface({
});
rl.on("line", (line) => {
console.log(Sanscript.t(line, "hk", "devanagari"));
console.log(
Sanscript.t(line, "hk", "devanagari")
.replace(/\.\./g, "॥")
.replace(/[,.]/g, "।")
);
});

View File

@@ -5,6 +5,6 @@
"bin": "devanagari.js",
"author": "kmein",
"devDependencies": {
"@sanskrit-coders/sanscript": "^1.1.5"
"@indic-transliteration/sanscript": "^1.2.7"
}
}

View File

@@ -2,7 +2,20 @@
# yarn lockfile v1
"@sanskrit-coders/sanscript@^1.1.5":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@sanskrit-coders/sanscript/-/sanscript-1.1.5.tgz#a22222cf7a5d55f7b19e210242c59f6f819fd643"
integrity sha512-YA7MchP2CD2JnAOkj+ORDUFrISiPqx3muvhKvRO3KFOx9UfvpIdEUORoKWJ88lr1uH9T32jDxjns/MSclmDczA==
"@indic-transliteration/common_maps@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@indic-transliteration/common_maps/-/common_maps-1.0.0.tgz#c1f1c893ae49e01fe498ef1877bdd0153bc90b42"
integrity sha512-NUza2GKxc6/0YiWWew3qsFenEgksnFSZWvNGqyyKYnII9wZS/U+w1jY/yYN9aR+foA/rPymvckM2/hKv9Ow2dQ==
"@indic-transliteration/sanscript@^1.2.7":
version "1.2.7"
resolved "https://registry.yarnpkg.com/@indic-transliteration/sanscript/-/sanscript-1.2.7.tgz#c07aaa979f6d60fb0bbf35cdbd1d3bb1c487d931"
integrity sha512-Jm5z+wWxMUlw6dGHK7BHQUBjRnVHmfidmB7NiTbkdKPP89BDOB16zIKvXZY5XTsvkXmcyqF+DbJqiB9zzUhDKA==
dependencies:
"@indic-transliteration/common_maps" "^1.0.0"
toml "^2.3.6"
toml@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/toml/-/toml-2.3.6.tgz#25b0866483a9722474895559088b436fd11f861b"
integrity sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ==