Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

100 строки
2.4KB

  1. #!/usr/bin/fish
  2. set timer_folder ~/.timer
  3. set activity_lists_folder $timer_folder/activity.lists
  4. set activity_timeclock_file $timer_folder/activity.timeclock
  5. set activity_i3blocks $timer_folder/activity.i3blocks
  6. set activity_current_file $timer_folder/activity.current
  7. set activity_timeclock_append_log_folder $timer_folder/activity.timeclock.d
  8. set activity_timeclock_append_log_filename $activity_timeclock_append_log_folder/(date +%Y-%m-%d)-(hostname)
  9. function set_i3blocks_activity_display
  10. echo $argv[1] > $activity_i3blocks
  11. pkill -RTMIN+1 i3blocks
  12. end
  13. function parse_activity_timeclock
  14. sort -k2 | uniq \
  15. |begin
  16. set state o
  17. while read -L line
  18. set io (string sub -l 1 "$line")
  19. set date (string sub -s 3 -l 10 "$line")
  20. set time (string sub -s 14 -l 8 "$line")
  21. if [ $state = 'i' ]
  22. echo "o $date $time"
  23. end
  24. if [ $io = 'i' ]
  25. set state i
  26. set rs (string sub -s 23 "$line")
  27. string match -r '^(.+?)(?: (.+?))? *(?:;.*)?$' "$rs" \
  28. |begin
  29. read -L null
  30. read -L activity
  31. read -L payee
  32. end
  33. echo "i $date $time $rs"
  34. else if [ $io = 'o' ]
  35. set state o
  36. end
  37. end
  38. end
  39. if [ $state = 'i' ]
  40. echo $activity > $activity_current_file
  41. set_i3blocks_activity_display "<span foreground=\"#00FF00\">★ $activity</span>"
  42. else
  43. rm $activity_current_file
  44. set_i3blocks_activity_display "<span foreground=\"#0000FF\">☆</span>"
  45. end
  46. end
  47. function merge_timeclock_append_log
  48. cat $activity_timeclock_append_log_folder/* | parse_activity_timeclock > $activity_timeclock_file
  49. end
  50. function get_current_timeclock_state
  51. merge_timeclock_append_log
  52. end
  53. function select_activity
  54. set next (cat $activity_lists_folder/* | rofi -dmenu -p activity)
  55. if [ ! -n "$next" ]
  56. exit 1
  57. end
  58. begin_activity "$next"
  59. end
  60. function begin_activity
  61. echo i (date '+%Y-%m-%d %H:%M:%S') $argv >> $activity_timeclock_append_log_filename
  62. end
  63. function end_activity
  64. echo o (date '+%Y-%m-%d %H:%M:%S') >> $activity_timeclock_append_log_filename
  65. end
  66. set command $argv[1]
  67. switch $command
  68. case "select_activity"
  69. select_activity
  70. case "begin_activity"
  71. begin_activity $argv[2..-1]
  72. case "end_activity"
  73. end_activity
  74. case "show_activity"
  75. get_current_timeclock_state
  76. case "uniklinik"
  77. begin_activity 'Arbeit:Uniklinik Köln'
  78. end
  79. merge_timeclock_append_log