add new wanikani scripts
This commit is contained in:
parent
38449b87d8
commit
08cabc39de
4 changed files with 66 additions and 11 deletions
|
|
@ -3,9 +3,9 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
wanikani-script = builtins.path {
|
||||
path = ./wanikani-tmux.sh;
|
||||
};
|
||||
wanikani-current-reviews-script = builtins.path { path = ./scripts/wanikani-current-reviews.sh; };
|
||||
wanikani-level-script = builtins.path { path = ./scripts/wanikani-level.sh; };
|
||||
wanikani-progression-script = builtins.path { path = ./scripts/wanikani-progression.sh; };
|
||||
tmux-dracula = pkgs.tmuxPlugins.mkTmuxPlugin rec {
|
||||
pluginName = "dracula";
|
||||
version = "3.0.0";
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
};
|
||||
postInstall = ''
|
||||
# i am adding my custom widget to the plugin here cp the wanikani.sh script to the plugin directory
|
||||
cp ${wanikani-script} $target/scripts/wanikani.sh
|
||||
cp ${wanikani-current-reviews-script} $target/scripts/wanikani-current-reviews.sh
|
||||
cp ${wanikani-level-script} $target/scripts/wanikani-level.sh
|
||||
cp ${wanikani-progression-script} $target/scripts/wanikani-progression.sh
|
||||
'';
|
||||
meta = with pkgs.lib; {
|
||||
homepage = "https://draculatheme.com/tmux";
|
||||
|
|
@ -41,7 +43,7 @@ in {
|
|||
{
|
||||
plugin = tmux-dracula;
|
||||
extraConfig = ''
|
||||
set -g @dracula-plugins "custom:wanikani.sh cpu-usage ram-usage gpu-usage battery time"
|
||||
set -g @dracula-plugins "custom:wanikani-level.sh custom:wanikani-progression.sh custom:wanikani-current-reviews.sh cpu-usage ram-usage gpu-usage battery"
|
||||
set -g @dracula-show-left-icon hostname
|
||||
set -g @dracula-git-show-current-symbol ✓
|
||||
set -g @dracula-git-no-repo-message "no-git"
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
#!nix-shell -i bash -p jq curl
|
||||
# Description: This script is used to display the current WaniKani review count in the tmux status bar.
|
||||
|
||||
# curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/assignments?immediately_available_for_review=true" | jq '.total_count'
|
||||
|
||||
# lets store the output of the above command in a variable
|
||||
|
||||
get_wanikani()
|
||||
{
|
||||
wanikani_reviews=$(curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/assignments?immediately_available_for_review=true" | jq '.total_count')
|
||||
wanikani_lessons=$(curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/assignments?immediately_available_for_lessons=true" | jq '.total_count')
|
||||
|
||||
echo "WaniKani: $wanikani_reviews reviews, $wanikani_lessons lessons"
|
||||
echo "$wanikani_reviews reviews $wanikani_lessons lessons"
|
||||
}
|
||||
|
||||
main()
|
||||
23
home/tmux/wanikani-level.sh
Executable file
23
home/tmux/wanikani-level.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
#!nix-shell -i bash -p jq curl
|
||||
|
||||
get_wanikani()
|
||||
{
|
||||
wanikani_level_data=$(curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/level_progressions")
|
||||
wanikani_level=$(echo $wanikani_level_data | jq '.data[-1].data.level')
|
||||
wanikani_level_start_date_string=$(echo $wanikani_level_data | jq '.data[-1].data.started_at')
|
||||
wanikani_level_start_timestamp=$(date -d "${wanikani_level_start_date_string//\"/}" +%s)
|
||||
current_timestamp=$(date +%s)
|
||||
difference=$((current_timestamp - wanikani_level_start_timestamp))
|
||||
wanikani_level_creation_date=$((difference / 86400))
|
||||
echo "At $wanikani_level for $wanikani_level_creation_date days"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
get_wanikani
|
||||
# sleep for 1 hour
|
||||
sleep 3600
|
||||
}
|
||||
|
||||
main
|
||||
35
home/tmux/wanikani-progression.sh
Executable file
35
home/tmux/wanikani-progression.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
#!nix-shell -i bash -p jq curl python312
|
||||
|
||||
get_wanikani()
|
||||
{
|
||||
all_subjects=$(curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/subjects")
|
||||
total_subjects=$(echo $all_subjects | jq '.total_count')
|
||||
|
||||
total=0
|
||||
for i in {0..9}
|
||||
do
|
||||
srs_level=$(curl -s -H "Authorization: Bearer 2da24e4a-ba89-4c4a-9047-d08f21e9dd01" "https://api.wanikani.com/v2/assignments?srs_stages=$i" | jq '.total_count')
|
||||
# echo "SRS level $i: $srs_level"
|
||||
multiplied=$((srs_level * (i + 1)))
|
||||
# echo "SRS level $i multiplied: $multiplied"
|
||||
total=$((total + multiplied))
|
||||
# echo "Total: $total"
|
||||
done
|
||||
|
||||
# now i need the percentage of (total/(total_subjects*10))
|
||||
# python will be used for this and i need the result to be %23.234
|
||||
python_command="python3 -c 'print(f\"{$total/$total_subjects*10:.3f}\")'"
|
||||
# echo "Python command: $python_command"
|
||||
percentage=$(nix-shell -p python312 --run "$python_command")
|
||||
echo "%$percentage"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
get_wanikani
|
||||
# sleep for 1 hour
|
||||
sleep 3600
|
||||
}
|
||||
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue