You are not logged in.

#76 2019-06-04 04:13:35

hhh
Meep!
Registered: 2015-09-17
Posts: 8,734
Website

Re: fortune notifications?

@ohnonot and everyone, @johnraff has made the push, it will be in Lithium...

https://github.com/BunsenLabs/bunsen-me … 44f8df5afc

Offline

#77 2019-06-04 07:18:53

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

^Should we enable fortune popups in autostart by default, or leave it for users to uncomment?


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#78 2019-06-04 16:36:07

hhh
Meep!
Registered: 2015-09-17
Posts: 8,734
Website

Re: fortune notifications?

@johnraff and @ohnonot, the timeout for the notification is inconsistent, and too short in general ATM. It would be great if it could inherit the timeout set in xfce4-notifyd-settings, or just set it to something long enough so you can read the longer quotes, maybe 20 seconds?

-edit- Is the inconsistency that the time-out is determined by the length of the quote? Sometimes it's the short ones that disappear too fast. Maybe it just needs a longer delay in my openbox autostart for when I reboot.

Last edited by hhh (2019-06-04 17:58:42)

Offline

#79 2019-06-05 02:24:29

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

There are two separate delays here.

## bl-fortune - have the system come up with a little adage (not yet enabled)
#(sleep 120; bl-fortune) &

1) The delay before firing off bl-fortune. This is a quite arbitary 120s in BL's file atm, but could be anything. I use a random 'sleep $((RANDOM%3600+120))' but that needs bash.

2) The time that bl-fortune decides to set for the message display. This was the subject of much discussion a while ago. Now it's simply the # of words x 500ms, but I think it needs a fixed time adding on (as well as possibly increasing the 500) because humans need a certain time just to recognize that the message has appeared, before starting to read it.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#80 2019-06-06 05:52:35

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

johnraff wrote:

The time that bl-fortune decides to set for the message display. This was the subject of much discussion a while ago. Now it's simply the # of words x 500ms, but I think it needs a fixed time adding on (as well as possibly increasing the 500) because humans need a certain time just to recognize that the message has appeared, before starting to read it.

but then I overturned my own statement (to simply stick with notify-send timeouts), and we had a second, much longer discussion (where?) about an additional script, resulting in this.
the help text:

#~ It is said that average reading speed is ~250 words per minute for adults.
#~ That means 4.166667 words per second.
#~ I think it's fair to assume that the text should linger quite a bit longer,
#~ about twice as long. make that 2 words per second, that's a delay of 500ms
#~ per word:
delay=500

HELP="  bl-fortune is a script to display custom fortunes.

Usage:  bl-fortune [OPTIONS]

Options:
        -i <icon>, --icon=<icon>    use different icon
                                    (default is $msg_icon)
        -d <time>, --word-delay=<time> set delay per word, calculates
                                    message expiry time based on text length
                                    (default is ${delay}ms)
                                    (overrides -t)
        -t <time>, --expiry-time=<time> set message expiry time
                                    (default is ${msg_time}ms)
                                    (overrides -d)
        -c <name>, --cookie='<name>[ name]'  set fortune cookie list(s)
                                    (default is $cookie)
                                    (this can contain multiple fortunes and
                                    options to fortune. Example:
                                    \"-ae cbbl fortunes\")
        -D                          debug - enable some terminal messages
        -h, --help  show this message

Description:
        This is a wrapper round notify-send
        - the icon and time options are the same.
        Normally run without options,
        the default behaviour is to choose a fortune
        from the 'cbbl' collection, which is gathered
        from CrunchBang and BunsenLabs forum posts.
"

so particularly the mutually exclusive -d and -t options.
Is that not sufficient?

BTW, the topic of this thread still stands! If you really want sth added to the quotes, please make a request here, or here! thanks!

Offline

#81 2019-06-06 06:14:12

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

ohnonot wrote:
johnraff wrote:

The time that bl-fortune decides to set for the message display...

...the help text:

...
delay=500

HELP="  bl-fortune is a script to display custom fortunes.

Usage:  bl-fortune [OPTIONS]

Options:
        -i <icon>, --icon=<icon>    use different icon
                                    (default is $msg_icon)
        -d <time>, --word-delay=<time> set delay per word, calculates
                                    message expiry time based on text length
                                    (default is ${delay}ms)
                                    (overrides -t)
        -t <time>, --expiry-time=<time> set message expiry time
                                    (default is ${msg_time}ms)
                                    (overrides -d)
        -c <name>, --cookie='<name>[ name]'  set fortune cookie list(s)
                                    (default is $cookie)
                                    (this can contain multiple fortunes and
                                    options to fortune. Example:
                                    \"-ae cbbl fortunes\")
        -D                          debug - enable some terminal messages
        -h, --help  show this message

..."

so particularly the mutually exclusive -d and -t options.
Is that not sufficient?

Apparently not, according to hhh (post 12). To be honest, I doubt if many users are going to tweak those -t and -d options attached to the bl-fortune call.

@hhh would you like to have a look at this part of /usr/bin/bl-fortune:

text="$(fortune $cookie)"

if (( delay > 0 )); then
    words="$(wc -w <<<"$text")"
    if (( words > 0 )); then
        msg_time="$(( words * delay ))"
    else
        msg_time=$msg_time_default
    fi
fi

and maybe see if you can tweak it to your satisfaction?
Maybe add a fixed delay (so short messages don't get missed) and a number-of-characters factor (so messages with long words get a bit more time), something like this?

text="$(fortune $cookie)"
fixed_delay=2000
word_delay=500
char_delay=30
if (( delay > 0 )); then
    words="$(wc -w <<<"$text")"
    chars="$(wc -m <<<"$text")"
    if (( words > 0 )); then
        msg_time="$(( fixed_delay + (words * word_delay) + (chars * char_delay)))"
    else
        msg_time=$msg_time_default
    fi
fi

And play with fixed_delay, word_delay and char_delay till the display time seems reasonable for a range of messages...


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#82 2019-06-06 06:36:55

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

^ i don't think you need to tweak the source code.
there's an option for either
- a dynamic (based on word count) delay this is adjustable! defaults to 500ms, but feel free to raise it.
or
- a simple static delay
If you add to that the possibility of a startup delay in autostart, I don't understand what the not implemented option could be?
If you tell me, I can look at it tonight.

Offline

#83 2019-06-06 07:40:17

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

ohnonot wrote:

I don't understand what the not implemented option could be?

As in the code I posted above, instead of a simple word_count x delay_factor I suggested a more sophisticated automation:
Fixed_delay + (words x word_delay) + (characters x character_delay)

But I leave the decision up to you and hhh.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#84 2019-06-12 06:04:25

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

Sorry, I was away for a few days.

To whomever this may concern, person or persons:

So the fortune should linger, cumulatively, for:

- a fixed (adjustable) time, plus
- a defined time per word, plus
- a defined time per character

???

I am happy to put in the extra effort, but please explain to me the logical reasoning behind this complexity.
I simply don't see the need.

I did expansive tests when I wrote it and decided that - presuming that you want to read every fortune - a fairly exaggerated time-per-word is the best solution.

The alternative is a simple fixed timeout.

What point is this much more complex solution, and how is the user supposed to be able to adjust it?

BTW, when you say "delay", it sounds to me like you're talking about the delay before the fortune even appears; something I did not even implement deliberately, because it's so common to have "sleep X; bl-fortune" in your autostart.
I assume you really mean notification timeout; please correct me if I'm wrong.

Offline

#85 2019-06-14 03:09:15

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

^The word "delay" comes from your code.

#~ It is said that average reading speed is ~250 words per minute for adults.
#~ That means 4.166667 words per second.
#~ I think it's fair to assume that the text should linger quite a bit longer,
#~ about twice as long. make that 2 words per second, that's a delay of 500ms
#~ per word:
delay=500

You appear to be using it to indicate the time the text is displayed. I don't think anyone is talking about the delay before displaying the message.

Anyway, I've more-or-less written the code to implement the more sophisticated algorithm, and already - I think - explained why it might be considered an improvement, but anyway:

johnraff wrote:

Maybe add a fixed delay (so short messages don't get missed) and a number-of-characters factor (so messages with long words get a bit more time)...

text="$(fortune $cookie)"
fixed_delay=2000
word_delay=500
char_delay=30
if (( delay > 0 )); then
    words="$(wc -w <<<"$text")"
    chars="$(wc -m <<<"$text")"
    if (( words > 0 )); then
        msg_time="$(( fixed_delay + (words * word_delay) + (chars * char_delay)))"
    else
        msg_time=$msg_time_default
    fi
fi

People need a certain time just to recognize that something has appeared, before they start reading, hence fixed_delay
Time needed is related to the number of words: word_delay
Long words need longer to read, so: char_delay
An even more sophisticated algorithm might do a reading-time calculation on each word separately but that would surely be going too far. It was just a suggestion, to make sure the message is displayed long enough to be read, without annoying users with an excessively long display time. If that annoyance is considered negligable then it would simply be enough to use a very long display time - long enough for the longest message and the slowest reader.

I don't have anything to add - the package is yours to implement how you see fit.
Others may have different opinions.

Last edited by johnraff (2019-06-14 05:19:40)


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#86 2019-09-14 09:34:37

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

I have dry-implemented your & hhh's suggestions to a separate branch (for now).
Hopefully in time for the upcoming release.
Would you mind testing it?
https://framagit.org/ohnonot/fortune-mo … /soph_algo
https://notabug.org/ohnonot/fortune-mod … /soph_algo

Offline

#87 2019-09-15 04:40:32

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

^Nearly missed this - it's in "Off Topic" - but I'll have a look, thanks!

Just installed in ~/bin and it certainly still works OK.
First impression - the total time might be a little bit long, especially for long messages. The numbers I posted above for the three delays were quite arbitary with the expectation that the developer might play around with them till it seemed to be right. smile

Anyway, will now try it for a while with default word_delay down to 300...


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#88 2019-09-17 06:47:08

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

johnraff wrote:

Nearly missed this - it's in "Off Topic"

Aren't you using the Posted link?
Always the first thing I do after logging in.

Anyhow:

the total time might be a little bit long, especially for long messages.

It's all adjustable via command line.
If someone (maybe @hhh?) could fiddle with it and tell me what a sane default for all 3 values would be, I will mplement it.

Offline

#89 2019-09-17 08:28:29

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

ohnonot wrote:

If someone (maybe @hhh?) could fiddle with it and tell me what a sane default for all 3 values would be, I will implement it.

This is what I was hoping might happen...

(Right now I'm using word_delay=300 and char_delay=30 which for an 8-character word would give a total of 540 - close to the previous setting. The initial delay of 2000 might possibly be dropped a little bit (1500?), but the end result seems reasonable atm.)

---
I don't check "Posted" first, but "New".
But if I'm short of time, skip the Off Topic and graphicsy threads, for example.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#90 2019-09-23 06:54:30

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

johnraff wrote:

Right now I'm using word_delay=300 and char_delay=30 which for an 8-character word would give a total of 540 - close to the previous setting. The initial delay of 2000 might possibly be dropped a little bit (1500?)

I have incorporated these changes into the soph_algo branch:
https://framagit.org/ohnonot/fortune-mo … /soph_algo
https://notabug.org/ohnonot/fortune-mod … /soph_algo
(also did some cleanup, hopefully didn't break anything)

Give me the heads-up, I will merge it into master.

But if I'm short of time, skip the Off Topic and graphicsy threads, for example.

Well you're a mod, you can move this thread out of Off Topic if you want!

Offline

#91 2019-09-24 02:14:40

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

^Yup that seems to be working OK.
Those times should be good enough to release for now. A future package upgrade could easily tweak them if it was thought a good idea.

EDIT: Just a moment... my general feeling after using 1500 300 30 for the last few days is that long posts get plenty of time, while for short ones it's just enough. I'll try putting the fixed delay up to 1800 for a bit, to try and balance things.

I've no idea how the word-count and character-count figures should be balanced, though. It would need a collection of posts with a lot of short words to compare with some with mostly long words...

[ MODNOTE ] Recent (2019) posts merged in here from https://forums.bunsenlabs.org/viewtopic … 246#p91246

Last edited by johnraff (2019-09-24 02:58:15)


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#92 2019-09-24 06:23:31

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

johnraff wrote:

EDIT: Just a moment... my general feeling after using 1500 300 30 for the last few days is that long posts get plenty of time, while for short ones it's just enough. I'll try putting the fixed delay up to 1800 for a bit, to try and balance things.

If that's the case then the fixed delay should be much longer (5000?), and the word/char delay much shorter.
Scratch that.
There was an error in the script; the fixed delay wasn't being applied at all!
Even so, 1500ms seems a bit short, I have raised that to 2500.
Try now.

johnraff wrote:

It would need a collection of posts with a lot of short words to compare with some with mostly long words...

You can mix the bl cookies with others, or use other cookies entirely:

./bl-fortune -h | grep -A4 cookie
        -C <name>, --cookie='<name>[ name]'  set fortune cookie list(s)
                                    Default is cbbl
                                    This can contain multiple fortunes and
                                    options to fortune. Example:
                                    "-ae cbbl fortunes"

Offline

#93 2019-09-24 07:20:32

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

ohnonot wrote:

There was an error in the script; the fixed delay wasn't being applied at all!

Indeed there was. Also, some of the CLI options are not being applied correctly. Especially '-t <time>, --expire-time' (--expiry-time in --help) needs some logic to override the dynamic times and set msg_time.

Even so, 1500ms seems a bit short, I have raised that to 2500.

johnraff wrote:

It would need a collection of posts with a lot of short words to compare with some with mostly long words...

You can mix the bl cookies with others, or use other cookies entirely:

./bl-fortune -h | grep -A4 cookie
        -C <name>, --cookie='<name>[ name]'  set fortune cookie list(s)
                                    Default is cbbl
                                    This can contain multiple fortunes and
                                    options to fortune. Example:
                                    "-ae cbbl fortunes"

Indeed, but I don't really have the time for a proper investigation into this right now.

Playing with the numbers for a few minutes and running 'bl-fortune' (I never use the CLI options), and working on the basis that I'd like enough time to read the popup twice, I got these figures:
fixed_delay=1500
word_delay=250
char_delay=25
But non-native readers will need longer times than me.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#94 2019-09-24 20:00:18

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

johnraff wrote:

But non-native readers will need longer times than me.

Hmm.
Is the initial 2000/300/30 a suitable compromise then? In any case these are just default values, all changeable.
Or just tell me some values, I'll put it in and we're done.

johnraff wrote:

some of the CLI options are not being applied correctly. Especially '-t <time>, --expire-time' (--expiry-time in --help) needs some logic to override the dynamic times and set msg_time.

Oh my, there was so much wrong with that.
I changed that just to '--time' now, made it actually work (!), and hopefully explained the logic in the usage text.

I am deliberately not dealing with cases where the user passes conflicting options on the command line.

Pushed to soph_algo again.

I hope people can do more testing! Links in post #90.

Last edited by ohnonot (2019-09-24 20:01:30)

Offline

#95 2019-09-25 03:39:28

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

With 2000 300 30 I was finding display times a little bit too long with long messages, but now with 2000 250 25 it seems reasonably balanced between long and short posts. A very long post (XY problem by Bronto) was just displayed with enough time for me to read it twice, which might be about right. Short posts also seem OK.  So, that's what I would currently suggest for the defaults. See how it works for you.

Though I have no idea what the ideal balance between word & character counts should be. With 250/25 a 10-character word would have a total delay of 500ms which is what the former script used. 1-char word: 275ms, 20-chars: 750ms. But such deep research could perhaps be left for later, considering as you say, the default values can be overruled by the command options, and can be adjusted later by a package upgrade if necessary.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#96 2019-09-25 19:28:24

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

OK, I changed it to 2000/250/25, and pushed to the soph_algo branch.
More testing, please, anybody?
It seems OK to me (not the delays, but the robustness of the command line options in general), but I'm a little out of sorts atm...

Offline

#97 2019-10-03 08:27:36

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

After some more testing I made a few more changes.
Still testing the soph_algo branch... links in post #90.

Offline

#98 2019-10-04 02:46:43

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

^OK copied into ~/bin/bl-fortune and we'll see how it goes. Looks good though.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#99 2019-10-07 08:29:57

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
Website

Re: fortune notifications?

Is it time to merge?

Offline

#100 2019-10-09 03:20:58

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,073
Website

Re: fortune notifications?

No problems from this side.


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

Board footer

Powered by FluxBB