taskd - assistance request

Submitted scripts and programs
Forum rules
Your own work only.
User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: GTD, Pomodoro etc.

Unread post by dkeg » Mon Dec 22, 2014 4:42 am

ha, you guys will get a kick out of this. I don't use task list really. But I came across when; also some information here. Very basic, very simple. Able to choose default editor; emacs is default option if none selected.
And of course, and Joe would be proud, I piped it to bar. Wrote a pretty archaic script to take today's date, loop the file, print line with date greater than today. Simple use case; simple implementation.
pipedwhen.png
pipedwhen.png (1.51 KiB) Viewed 2738 times

Work hard; Complain less

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: GTD, Pomodoro etc.

Unread post by GekkoP » Mon Dec 22, 2014 9:27 am

Very cool, dkeg.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: GTD, Pomodoro etc.

Unread post by dkeg » Mon Dec 22, 2014 1:13 pm

Thanks.
I'm realizing this is pretty wrong. That's cool though, it's s good starting point. I have an idea of where to start, and got some ideas on how.
Hopefully I'll have a better version tonight.

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: GTD, Pomodoro etc.

Unread post by machinebacon » Tue Dec 23, 2014 1:59 am

Of course, 'when'! That's the brother of 'remind' :D Thanks for the input, Drew.
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

taskd - display upcoming tasks

Unread post by dkeg » Tue Dec 23, 2014 6:26 pm

alright, so I wrote a little script to iterate over the next few tasks and display in bar

Code: Select all

#! /bin/bash

## taskd; by dkeg; 2014
## a simple script to iterate                                            
## over the next few tasks                                                      

## Task file location 
file="$HOME/.when/calendar"

## grab upcoming tasks
today=$(when | awk 'NR==3 {$2=$3=$4="";print}')
tomorrow=$(when | awk 'NR==4 {$2=$3=$4="";print}')
upcoming=$(when | awk 'NR==5 {$2="";print}')

## How long of a delay
#delay=$(sleep 6s)

## Loop the file, display the tasks I want in intervals
    while :; do
        sleep 6; echo $today
        sleep 6; echo $tomorrow 
        sleep 6; echo $upcoming
    done < $file 
EDIT: made some improvements and fixed the stops at 3 issue
problem is that it does not work in bar. Still investigating. It runs if I execute in the terminal, but it does stop after 3 passes. As of now, I can use a simple awk string to take the 'next' task and display in bar as in the scrot above, but with a little more cleaning of unwanted values

Code: Select all

when | awk 'NR==3 {$2=$3=$4="";print}'
I know my script is quite not right even if it works. Any suggestions?

The output of when is as such

Code: Select all

+   when
Tue 2014 Dec 23   11:04

today      2014 Dec 23 Holiday Prep!
tomorrow   2014 Dec 24 Christmas Eve & Pageant
Thu        2014 Dec 25 Christmas Day

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: taskd - assistance request

Unread post by machinebacon » Wed Dec 24, 2014 3:39 am

I tried a few variants:

- in the taskd script, you don't actually need the < $file redirection at the end of the script, because the dates are read through awk before. If I keep it inside, bar doesn't show shit.

- if taskd redirects $file instead of calling when, like in cat $file | awk 'NR==1 {$2=$3=$4="";print}' I get a Segfault in bar

- throw this in the bar script:

Code: Select all

taskd() {
  cat $HOME/.when/calendar | awk 'NR==1 {$2=$3=$4="";print}'
}
and it werks. Of course then the sleep doesn't werk. I'll continue digging :)
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: taskd - assistance request

Unread post by dkeg » Wed Dec 24, 2014 4:30 am

thank you. makes sense not needing the < $file. The key is only displaying one event at a time. The goal is to sleep like 300 or so between each task display. I wonder if something in BARs code that conflicts. Runs exactly how I want it to through the terminal, and debug mode doesn't throw anything.

Yes you can set past = 0 to only show today and forward, or -1 to show yesterday forward, and so on. Default is -1; I changed to 0.

Maybe should test with coky.

EDIT: and I'll keep thinking about. I must be missing something. Maybe I can output to a tmp file and redirect each event read; overwriting the previous read; so bar is reading from a simple file with no code.

Let's see how that might work ...

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: taskd - assistance request

Unread post by machinebacon » Wed Dec 24, 2014 6:30 am

I was thinking of the tmp file too, though it's not perfect. there must be a way to directly pipe the result into the bar's STDIN, and it seems that the 'echo' in taskd doesn't go STDOUT.

One more coffee, a cig, and then try again :)

And yeah, I was thinking the same wrt BAR having a conflict. Why else would it segfault? I mean, it is clear that it cannot work like this:
1) barscript is started and executes taskd, waiting for STDOUT or an error
2) taskd is run with a loop *and* sleep
3) barscript doesn't get the output to send to bar
4) ???

You know what i mean :)

Edit: really the easiest is to put the while loop into .xinitrc, and write the taskd output to a tmpfile. Not as elegant, but hey :)
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: taskd - assistance request

Unread post by dkeg » Wed Dec 24, 2014 5:55 pm

Thank you for the help MB!! I really appreciate it.

With the working I solution I split the topic to new one, for cleanliness sake. I first wanted to rename this topic, but since I had split off the first few posts from another topic, I couldn't, so I felt this was the best solution.

taskd - display upcoming tasks

Work hard; Complain less

Post Reply