Bug 42632

Summary: Ability to seed Math.Random ()
Product: plymouth Reporter: dendlerdev
Component: generalAssignee: Ray Strode [halfline] <rstrode>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: medium CC: arfbtwn, rstrode
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Working Seed

Description dendlerdev 2011-11-05 13:32:11 UTC
Would be nice to give the Random a seed function so that subsequent random choices (backgrounds, etc.) are truly random.

As discussed here: http://lists.freedesktop.org/archives/plymouth/2010-July/000387.html
Comment 1 Ray Strode [halfline] 2012-06-08 13:54:51 UTC
should be set in master:

http://cgit.freedesktop.org/plymouth/commit/?id=3f8bd998dcc6d592ffd5d3aefad06f0bbf28a725

script: seed random number generator

Most splash plugins that use random numbers seed the random number generator with the current time, but script fails, too. This commit fixes that. 

https://bugs.freedesktop.org/show_bug.cgi?id=42632
Comment 2 Nicholas Little 2014-08-17 21:42:02 UTC
Created attachment 104777 [details] [review]
Working Seed

Hi, I've been developing a script that uses the Math.Random function to select a splash screen but it always selects the same image.

I'm not exactly sure what the problem is but believe that it lies in the cast from double to int performed when feeding the output of ply_get_timestamp to srand.

I enclose a small patch that corrects the behaviour for scripts, but I noticed using grep that the generator is seeded in the same way throughout plymouth.

Thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.