Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.

99 Zeilen
2.6KB

  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_linefile $timer_folder/activity.i3blocks
  6. set activity_i3blocks_socket $timer_folder/activity.i3blocks.sock
  7. set activity_current_file $timer_folder/activity.current
  8. set activity_timeclock_append_log_folder $timer_folder/activity.timeclock.d
  9. set activity_timeclock_append_log_filename $activity_timeclock_append_log_folder/(date +%Y-%m-%d)-(hostname)
  10. function activity_i3blocks_show
  11. tee $activity_i3blocks_linefile | socat - UNIX-CONNECT:$activity_i3blocks_socket
  12. end
  13. function parse_activity_timeclock
  14. sort -k2 | uniq \
  15. |begin
  16. set state o
  17. while read -L line
  18. set type (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 [ $type = '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 [ $type = '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
  42. echo "<span foreground=\"#00FF00\">★ $activity</span>" | activity_i3blocks_show
  43. else
  44. rm $activity_current_file
  45. echo "<span foreground=\"#0000FF\">☆</span>" | activity_i3blocks_show
  46. end
  47. end
  48. function merge_timeclock_append_log
  49. cat $activity_timeclock_append_log_folder/* | parse_activity_timeclock > $activity_timeclock_file
  50. end
  51. function get_current_timeclock_state
  52. merge_timeclock_append_log
  53. end
  54. function select_activity
  55. set next (cat $activity_lists_folder/* | rofi -dmenu -p activity)
  56. if [ ! -n "$next" ]
  57. exit 1
  58. end
  59. begin_activity "$next"
  60. end
  61. function begin_activity
  62. echo i (date '+%Y-%m-%d %H:%M:%S') $argv >> $activity_timeclock_append_log_filename
  63. echo "<span foreground=\"#00FF00\">★ $argv</span>" | activity_i3blocks_show
  64. end
  65. function end_activity
  66. echo o (date '+%Y-%m-%d %H:%M:%S') >> $activity_timeclock_append_log_filename
  67. echo "<span foreground=\"#0000FF\">☆</span>" | activity_i3blocks_show
  68. end
  69. set command $argv[1]
  70. switch $command
  71. case "select_activity"
  72. select_activity
  73. case "begin_activity"
  74. begin_activity $argv[2..-1]
  75. case "end_activity"
  76. end_activity
  77. case "show_activity"
  78. get_current_timeclock_state
  79. case "uniklinik"
  80. begin_activity 'Arbeit:Uniklinik Köln'
  81. end