From 4012e1cc298a477e04f187477656b919825237e1 Mon Sep 17 00:00:00 2001 From: Horhik Date: Mon, 22 Mar 2021 20:03:52 +0300 Subject: [PATCH] add toggl track timer to xmobar --- home/scripts/.local/scripts/toggl-current | 13 +++++++++++++ home/xmonad/.config/xmobar/bin/xmobarstatus | 13 ++++++++++++- home/xmonad/.config/xmobar/bin/xmobarstatus2 | 13 ++++++++++++- home/xmonad/.xmonad/xmonad.hs | 5 +++-- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 home/scripts/.local/scripts/toggl-current diff --git a/home/scripts/.local/scripts/toggl-current b/home/scripts/.local/scripts/toggl-current new file mode 100755 index 0000000..e6f8503 --- /dev/null +++ b/home/scripts/.local/scripts/toggl-current @@ -0,0 +1,13 @@ +#!/bin/sh + +#your toggl api token +TOGGL_API_TOKEN= #here +res=$(curl -u $TOGGL_API_TOKEN:api_token \ + -X GET https://api.track.toggl.com/api/v8/time_entries/current) +echo $res + +# desc=$(echo $res | jq -r '.data .description') +# dur=$(echo $res | jq -r '.data .duration') +# +# echo $desc +# echo $dur diff --git a/home/xmonad/.config/xmobar/bin/xmobarstatus b/home/xmonad/.config/xmobar/bin/xmobarstatus index b0b7316..8aa74d2 100755 --- a/home/xmonad/.config/xmobar/bin/xmobarstatus +++ b/home/xmonad/.config/xmobar/bin/xmobarstatus @@ -101,7 +101,18 @@ calendar () { echo " "$(date +'%d/%m/%Y') } +toggl_timer () { +toggl=$($HOME/.local/scripts/toggl-current) +toggl_duration=$(echo $toggl | jq -r '.data .duration') +toggl_description=$(echo $toggl | jq -r '.data .description') +curr_time=$(date +%s) +duration_sec=$((curr_time + toggl_duration)) +duration=$(echo $((duration_sec / (60 * 60))):$((duration_sec / 60 - duration_sec / (60 * 60) * 60)):$((duration_sec % 60))) +echo "—{$toggl_description("$duration")}" +} -echo "$(wifi)$(battery)$(volume)$(layout)$(diskspace)$(timeanddate)—{$(calendar)}—-" + + +echo "$(toggl_timer)$(wifi)$(battery)$(volume)$(layout)$(diskspace)$(timeanddate)—{$(calendar)}—-" #echo "                                          " diff --git a/home/xmonad/.config/xmobar/bin/xmobarstatus2 b/home/xmonad/.config/xmobar/bin/xmobarstatus2 index 7df04b7..37f7f7f 100755 --- a/home/xmonad/.config/xmobar/bin/xmobarstatus2 +++ b/home/xmonad/.config/xmobar/bin/xmobarstatus2 @@ -99,6 +99,17 @@ calendar () echo " "$(date +'%d/%m/%Y') } -echo "$(wifi)$(battery)$(volume)$(layout)$(diskspace)$(timeanddate)—{$(calendar)}——" +toggl_timer () { +toggl=$($HOME/.local/scripts/toggl-current) +toggl_duration=$(echo $toggl | jq -r '.data .duration') +toggl_description=$(echo $toggl | jq -r '.data .description') +curr_time=$(date +%s) +duration_sec=$((curr_time + toggl_duration)) +duration=$(echo $((duration_sec / (60 * 60))):$((duration_sec / 60 - duration_sec / (60 * 60) * 60)):$((duration_sec % 60))) +echo "—{$toggl_description("$duration")}" +} + + +echo "$(toggl_timer)$(wifi)$(battery)$(volume)$(layout)$(diskspace)$(timeanddate)—{$(calendar)}——" #echo "                                          " diff --git a/home/xmonad/.xmonad/xmonad.hs b/home/xmonad/.xmonad/xmonad.hs index 2e17827..21503d9 100644 --- a/home/xmonad/.xmonad/xmonad.hs +++ b/home/xmonad/.xmonad/xmonad.hs @@ -387,7 +387,7 @@ myLogHook (xmproc0, xmproc1) = dynamicLogWithPP $ xmobarPP { -- XMobar myStartupHook = do spawnOnce "nitrogen --restore &" -- spawnOnce "compton --config ~/.config/compton/compton.conf &" - spawnOnce "picom &" + spawnOnce "picom --experimental-backends &" spawnOnce "deadd-notification-center &" spawnOnce "setxkbmap us,ru &" spawnOnce "sh ssh-agent bash ; ssh-add ~/.ssh/arch" @@ -396,8 +396,9 @@ myStartupHook = do spawnOnce ("xrandr --output HDMI1 --above eDP1&") spawnOnce (home ++ ".local/scripts/status/launch &") spawnOnce (home ++ ".local/scripts/touchpad.sh &") - spawnOnce ("cd /home/horhik/Freenet/downloads/fms; ./fms --daemon &") + -- spawnOnce ("cd /home/horhik/Freenet/downloads/fms; ./fms --daemon &") spawnOnce "xautolock -time 25 -locker i3lock-fancy-multimonitor -notifier 'xkb-switch -s us' &" + spawnOnce "eval '$(ssh-agent -s)'; ssh-add ~/.ssh/id_rsa &" spawnOnce "sleep 10; pulseaudio -k" ------------------------------------------------------------------------