From 83686acb7ad04bccb34cadf5d9d116a94e1441fd Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 16 May 2025 09:55:39 +0300 Subject: can share through taskwarrior --- dotfiles/scripts/taskwarriorfeeder.rb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dotfiles/scripts/taskwarriorfeeder.rb b/dotfiles/scripts/taskwarriorfeeder.rb index dbea9c2..e6721da 100644 --- a/dotfiles/scripts/taskwarriorfeeder.rb +++ b/dotfiles/scripts/taskwarriorfeeder.rb @@ -2,6 +2,7 @@ require 'optparse' require 'digest' +require 'json' require 'set' PERSONAL_TIMESPAN_D = 30 @@ -18,10 +19,6 @@ def run_from_personal_device? `uname`.chomp == 'Linux' end -def gos_there? - Dir.exist?(GOS_DIR) -end - def random_count MAX_PENDING_RANDOM_TASKS - `task status:pending +random count`.to_i end @@ -117,7 +114,7 @@ end # Randomly schedule all unscheduled tasks but the ones with the +unsched tag def unscheduled_tasks - lines = `task -unsched -nosched -notes -note -meeting -track due: 2>/dev/null`.split("\n").drop(1) + lines = `task -lowhigh -unsched -nosched -notes -note -meeting -track due: 2>/dev/null`.split("\n").drop(1) lines.pop lines.map { |line| line.split.first }.each do |id| yield id if id.to_i.positive? @@ -142,13 +139,6 @@ begin end opt_parser.parse!(ARGV) - if gos_there? - Dir["#{GOS_DIR}/tw-gos-*.json"].each do |tw_gos| - p tw_gos - end - end - - exit 0 (run_from_personal_device? ? %w[ql pl] : %w[wl]).each do |prefix| notes(opts[:notes_dirs].split(','), prefix, opts[:dry_run]) do |tags, note, due| @@ -178,6 +168,19 @@ begin end end + if Dir.exist?(GOS_DIR) + Dir["#{WORKTIME_DIR}/tw-gos-*.json"].each do |tw_gos| + JSON.parse(File.read(tw_gos)).each_with_index do |entry, i| + File.write("#{GOS_DIR}/tw-#{Time.now.to_i}-#{i}.txt", <<~GOS_ENTRY) + #{entry['tags'].join(',')} + + #{entry['description']} + GOS_ENTRY + File.delete(tw_gos) + end + end + end + unscheduled_tasks do |id| task_schedule!(id, "#{rand(0..PERSONAL_TIMESPAN_D)}d", opts[:dry_run]) end -- cgit v1.2.3