Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timewarrior segment not showing #2603

Open
losdmi opened this issue Mar 14, 2024 · 16 comments
Open

timewarrior segment not showing #2603

losdmi opened this issue Mar 14, 2024 · 16 comments

Comments

@losdmi
Copy link

losdmi commented Mar 14, 2024

Hi! I use default config from configure command and there is no segment with timewarrior showing, only taskwarrior is shown. How to fix this? I use macos and timewarrior is installed via brew

@romkatv
Copy link
Owner

romkatv commented Mar 14, 2024

What do you expect to see?

@losdmi
Copy link
Author

losdmi commented Mar 14, 2024

I dont know to be honest. Just expected something about time that I am tracking now or some marker that time is tracking, but there is nothing. How this segment should look and on what conditions?

@romkatv
Copy link
Owner

romkatv commented Mar 16, 2024

This segment is supposed to show something when time tracking is enabled. Let's figure out why it does not work for you. Please enable time tracking and run the following command (including the parentheses):

(
  eval "$__p9k_intro"
  set -x
  : $commands[timew]
  typeset -pm 'TIMEWARRIORDB|XDG_DATA_HOME|_p9k_timewarrior*|_POWERLEVEL9K_TIMEWARRIOR*'
  prompt_timewarrior
)

@losdmi
Copy link
Author

losdmi commented Mar 16, 2024

+-zsh:10> : /opt/homebrew/bin/timew
+-zsh:11> typeset -pm 'TIMEWARRIORDB|XDG_DATA_HOME|_p9k_timewarrior*|_POWERLEVEL9K_TIMEWARRIOR*'
typeset _POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
typeset -i _p9k_timewarrior_file_mtime=0
typeset -i _p9k_timewarrior_dir_mtime=0
typeset _p9k_timewarrior_dir=''
typeset _POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
typeset _p9k_timewarrior_file_name=''
+-zsh:12> prompt_timewarrior
+prompt_timewarrior:1> local -a stat
+prompt_timewarrior:2> local dir=/Users/losdmi/.timewarrior/data
+prompt_timewarrior:3> [[ /Users/losdmi/.timewarrior/data ==  ]]
+prompt_timewarrior:3> _p9k_timewarrior_clear
+_p9k_timewarrior_clear:1> [[ -z '' ]]
+_p9k_timewarrior_clear:1> return
+prompt_timewarrior:4> [[ -n '' ]]
+prompt_timewarrior:13> [[ ! -d /Users/losdmi/.timewarrior/data ]]
+prompt_timewarrior:14> _p9k_timewarrior_clear
+_p9k_timewarrior_clear:1> [[ -z '' ]]
+_p9k_timewarrior_clear:1> return
+prompt_timewarrior:15> return
+-zsh:7> trap - INT

@losdmi
Copy link
Author

losdmi commented Mar 16, 2024

after this output i figured out what was wrong, thanks! There was no directory /Users/losdmi/.timewarrior. my version of timewarrior keeps its data in /Users/losdmi/.local/share/timewarrior. So i created symlink

ln -s /Users/losdmi/.local/share/timewarrior /Users/losdmi/.timewarrior

and segment started to show.

Thank you for your help!

@romkatv
Copy link
Owner

romkatv commented Mar 16, 2024

So the command didn't hang?

@losdmi
Copy link
Author

losdmi commented Mar 16, 2024

No it didnt

@romkatv
Copy link
Owner

romkatv commented Mar 16, 2024

Can you confirm that if you were to run zsh from the same directory where you ran the command, it would have frozen on startup (assuming timewarrior was enabled in .p10k.zsh)?

@losdmi
Copy link
Author

losdmi commented Mar 16, 2024

I tried it now and nothing's frozen

@romkatv
Copy link
Owner

romkatv commented Mar 16, 2024

Could you undo the filesystem changes, get to the state where running zsh hangs, and then run the command? I'd really like to fix this issue.

@losdmi
Copy link
Author

losdmi commented Mar 16, 2024

I tried it without filesystem changes - nothing hangs and never hanged before. Could it be because of typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet ?

@romkatv
Copy link
Owner

romkatv commented Mar 16, 2024

Oh... I've confused this issue with #2598. That must've looked deranged to you 😅

I'll try to figure out where timewarrior is reading stuff and why it's not the place p10k expects.

@feekApp
Copy link

feekApp commented Apr 25, 2024

Hi,

I stumbled upon a similar issue. My Timewarrior data directory is not located in the default $HOME/.timewarrior directory. I've set a symlink where .timewarrior is pointing to the real Timewarrior Data directory. Timewarrior is working as expected using a symlink for the data directory.

When using a symlink, the Timewarrior segment is not showing (time track is running). When moving the Timewarrior data directory back to .timewarrior (so not using a symlink anymore) the Timewarrior segment is visible again (as expected).

For your information, I'am also using Taskwarrior, also using a symlink to the data directory .task. The Taskwarrior segment is visable, using the symlink!

So it seems like the Timewarrior segment function is no following the symlink.

Below the result of the function:

Result symlink

+-zsh:21> : /opt/homebrew/bin/timew
+-zsh:22> typeset -pm 'TIMEWARRIORDB|XDG_DATA_HOME|_p9k_timewarrior*|_POWERLEVEL9K_TIMEWARRIOR*'
typeset _POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}'
typeset _POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
typeset -i _p9k_timewarrior_file_mtime=0
typeset -i _p9k_timewarrior_dir_mtime=0
typeset _p9k_timewarrior_dir=''
typeset _POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
typeset _p9k_timewarrior_file_name=''
+-zsh:23> prompt_timewarrior
+prompt_timewarrior:1> local dir
+prompt_timewarrior:2> [[ -n '' || -n '' ]]
+prompt_timewarrior:3> dir=/Users/Feek/.local/share/timewarrior
+prompt_timewarrior:4> dir+=/data
+prompt_timewarrior:5> local -a stat
+prompt_timewarrior:6> [[ /Users/Feek/.local/share/timewarrior/data ==  ]]
+prompt_timewarrior:6> _p9k_timewarrior_clear
+_p9k_timewarrior_clear:1> [[ -z '' ]]
+_p9k_timewarrior_clear:1> return
+prompt_timewarrior:7> [[ -n '' ]]
+prompt_timewarrior:16> [[ ! -d /Users/Feek/.local/share/timewarrior/data ]]
+prompt_timewarrior:17> _p9k_timewarrior_clear
+_p9k_timewarrior_clear:1> [[ -z '' ]]
+_p9k_timewarrior_clear:1> return
+prompt_timewarrior:18> return
+-zsh:18> trap - INT

Result real directory

+-zsh:29> : /opt/homebrew/bin/timew
+-zsh:30> typeset -pm 'TIMEWARRIORDB|XDG_DATA_HOME|_p9k_timewarrior*|_POWERLEVEL9K_TIMEWARRIOR*'
typeset _POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}'
typeset _POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
typeset _p9k_timewarrior_tags='LSA general'
typeset -i _p9k_timewarrior_file_mtime=1714025244
typeset -i _p9k_timewarrior_dir_mtime=1714025244
typeset _p9k_timewarrior_dir=/Users/Feek/.timewarrior/data
typeset _POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
typeset _p9k_timewarrior_file_name=/Users/Feek/.timewarrior/data/2024-04.data
+-zsh:31> prompt_timewarrior
+prompt_timewarrior:1> local dir
+prompt_timewarrior:2> [[ -n '' || -n /Users/Feek/.timewarrior ]]
+prompt_timewarrior:4> dir+=/data
+prompt_timewarrior:5> local -a stat
+prompt_timewarrior:6> [[ /Users/Feek/.timewarrior/data == /Users/Feek/.timewarrior/data ]]
+prompt_timewarrior:7> [[ -n /Users/Feek/.timewarrior/data/2024-04.data ]]
+prompt_timewarrior:8> zstat -A stat +mtime -- /Users/Feek/.timewarrior/data /Users/Feek/.timewarrior/data/2024-04.data
+prompt_timewarrior:9> [[ 1714025244 == 1714025244 && 1714025244 == 1714025244 ]]
+prompt_timewarrior:10> ((  1  ))
+prompt_timewarrior:11> _p9k_prompt_segment prompt_timewarrior grey 255 TIMEWARRIOR_ICON 0 '' 'LSA general'
+_p9k_prompt_segment:0> _p9k__prompt_segment prompt_timewarrior grey 255 TIMEWARRIOR_ICON 0 '' 'LSA general'
_p9k_prompt_segment: command not found: _p9k__prompt_segment
+prompt_timewarrior:13> return
+-zsh:26> trap - INT

@feekApp
Copy link

feekApp commented Apr 25, 2024

Hi,

I'am not an expert in zsh, but when changing the condition for checking the directory in the segment function prompt_timewarrior to (line 5128):

  [[ -n ${dir::=$TIMEWARRIORDB} || -n ${dir::=$(readlink -f ~/.timewarrior)}(#qN/) ]] ||
    dir=${XDG_DATA_HOME:-~/.local/share}/timewarrior
  dir+=/data

so reading the real path using readlink the segments works for me again, both using the real directory as well for a symlink.

== Feek

@romkatv
Copy link
Owner

romkatv commented Apr 25, 2024

@feekApp Thanks for the report. Fixed.

@feekApp
Copy link

feekApp commented Apr 25, 2024

@romkatv Thnx for the quick fix!

I can confirm, the segment is working again as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants