add traewelling integration
This commit is contained in:
parent
e7e1e04d56
commit
5e0acac0bb
2 changed files with 35 additions and 4 deletions
9
home.nix
9
home.nix
|
@ -40,6 +40,7 @@ in
|
|||
tcpdump
|
||||
hyfetch
|
||||
libreoffice
|
||||
(import ./traewelling.script.nix)
|
||||
] ++ (with pkgs; [
|
||||
freecad
|
||||
nheko
|
||||
|
@ -89,14 +90,14 @@ in
|
|||
echo "> Your TODOs from ~/sync/todo.txt:"
|
||||
set_color brblue
|
||||
cat ~/sync/todo.txt
|
||||
set_color normal
|
||||
echo
|
||||
else
|
||||
set_color red
|
||||
echo "> Sync is not mounted."
|
||||
set_color normal
|
||||
echo
|
||||
end
|
||||
# check träwelling
|
||||
traewelling
|
||||
set_color normal
|
||||
echo
|
||||
end
|
||||
function edit-todo
|
||||
hx ~/sync/todo.txt
|
||||
|
|
30
traewelling.script.nix
Normal file
30
traewelling.script.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
with import <nixpkgs> {};
|
||||
|
||||
pkgs.writeShellScriptBin "traewelling" ''
|
||||
#!/bin/sh
|
||||
|
||||
function color() {
|
||||
echo -ne "\e[38;5;$1"m
|
||||
}
|
||||
function j() {
|
||||
jq -r $1 <<< "$json"
|
||||
}
|
||||
|
||||
user=tudbut
|
||||
if ! [ "$1" = "" ] ; then
|
||||
user="$1"
|
||||
fi
|
||||
|
||||
json="$(curl -s "https://traewelling.de/api/v1/user/$user/statuses" | jq .data[0])"
|
||||
if [ "$(($(date -d "$(j .train.destination.arrival)" +%s) - $(date +%s) ))" -gt 0 ] ; then
|
||||
color 9
|
||||
echo "> Traewelling"
|
||||
color 4
|
||||
echo "In train $(j .train.lineName) to $(j .train.destination.name)"
|
||||
echo "Arrival: in $(
|
||||
date -d "@$(( $(date -d "$(j .train.destination.arrival)" +%s) - $(date +%s) - 60 * 60))" +%H:%M
|
||||
) at $(j .train.destination.rilIdentifier) $(j .train.destination.arrivalPlatformReal)"
|
||||
echo "bahn.expert: https://bahn.expert/details/$(j .train.lineName | sed -E 's/(.*?) .*/\1/g')%20$(j .train.journeyNumber)"
|
||||
fi
|
||||
''
|
||||
|
Loading…
Add table
Reference in a new issue