2020-02-17 17:00:59 +04:00
|
|
|
{ bash, yt-utilities, libqalculate, config, lib, ... }:
|
2020-07-27 01:16:19 +04:00
|
|
|
let ec = config.home-manager.users.balsoft.programs.emacs.finalPackage;
|
|
|
|
in
|
2020-02-17 17:00:59 +04:00
|
|
|
''
|
|
|
|
#!${bash}/bin/bash
|
2020-07-27 01:16:19 +04:00
|
|
|
set -euo pipefail
|
|
|
|
export PATH="$PATH:${yt-utilities}/bin:${ec}/bin:${libqalculate}/bin"
|
2021-01-11 18:09:34 +04:00
|
|
|
WAGE=$(cat ${config.secrets.wage.decrypted})
|
2020-02-17 17:00:59 +04:00
|
|
|
HOURS_MONTH=$(yt org local --since $(date +'%Y-%m-01') | tail -1)
|
2021-01-11 18:09:34 +04:00
|
|
|
MONEY_MONTH=$(qalc -t "($HOURS_MONTH) * $WAGE")
|
2020-12-28 14:17:17 +04:00
|
|
|
'' + (if config.deviceSpecific.bigScreen then ''
|
|
|
|
HOURS_DAY=$(yt org local --since $(date +'%Y-%m-%d') | tail -1)
|
2020-02-17 17:00:59 +04:00
|
|
|
HOURS_YEAR=$(yt org local --since $(date +'%Y-01-01') | tail -1)
|
2021-01-11 18:09:34 +04:00
|
|
|
MONEY_DAY=$(qalc -t "($HOURS_DAY) * $WAGE")
|
|
|
|
MONEY_YEAR=$(qalc -t "($HOURS_YEAR) * $WAGE")
|
2020-12-28 14:17:17 +04:00
|
|
|
TASK=$(emacsclient --eval "org-mode-line-string" 2>/dev/null || echo -n none)
|
|
|
|
if ! [[ "$TASK" == "none" ]]; then
|
|
|
|
HOURS_TASK=$(echo "$TASK" | head -1 | cut -d\" -f 2 | cut -d\[ -f2 | cut -d\] -f1)h
|
2021-01-11 18:09:34 +04:00
|
|
|
MONEY_TASK=$(qalc -t -e "$HOURS_TASK * $WAGE" )
|
2020-12-28 14:17:17 +04:00
|
|
|
echo "$MONEY_TASK/$MONEY_DAY($HOURS_DAY)/$MONEY_MONTH($HOURS_MONTH)/$MONEY_YEAR"
|
|
|
|
else
|
|
|
|
echo "$MONEY_DAY($HOURS_DAY)/$MONEY_MONTH($HOURS_MONTH)/$MONEY_YEAR"
|
|
|
|
fi
|
2020-02-17 17:00:59 +04:00
|
|
|
'' else ''
|
|
|
|
echo "$MONEY_MONTH($HOURS_MONTH)"
|
|
|
|
'')
|